Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / prettier-eslint / node_modules / typescript / lib / tsc.js
1 /*! *****************************************************************************
2 Copyright (c) Microsoft Corporation. All rights reserved.
3 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4 this file except in compliance with the License. You may obtain a copy of the
5 License at http://www.apache.org/licenses/LICENSE-2.0
6
7 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10 MERCHANTABLITY OR NON-INFRINGEMENT.
11
12 See the Apache Version 2.0 License for specific language governing permissions
13 and limitations under the License.
14 ***************************************************************************** */
15
16
17 "use strict";
18 var __spreadArrays = (this && this.__spreadArrays) || function () {
19     for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
20     for (var r = Array(s), k = 0, i = 0; i < il; i++)
21         for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
22             r[k] = a[j];
23     return r;
24 };
25 var __assign = (this && this.__assign) || function () {
26     __assign = Object.assign || function(t) {
27         for (var s, i = 1, n = arguments.length; i < n; i++) {
28             s = arguments[i];
29             for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
30                 t[p] = s[p];
31         }
32         return t;
33     };
34     return __assign.apply(this, arguments);
35 };
36 var __generator = (this && this.__generator) || function (thisArg, body) {
37     var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
38     return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
39     function verb(n) { return function (v) { return step([n, v]); }; }
40     function step(op) {
41         if (f) throw new TypeError("Generator is already executing.");
42         while (_) try {
43             if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
44             if (y = 0, t) op = [op[0] & 2, t.value];
45             switch (op[0]) {
46                 case 0: case 1: t = op; break;
47                 case 4: _.label++; return { value: op[1], done: false };
48                 case 5: _.label++; y = op[1]; op = [0]; continue;
49                 case 7: op = _.ops.pop(); _.trys.pop(); continue;
50                 default:
51                     if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
52                     if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
53                     if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
54                     if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
55                     if (t[2]) _.ops.pop();
56                     _.trys.pop(); continue;
57             }
58             op = body.call(thisArg, _);
59         } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
60         if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
61     }
62 };
63 var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
64     if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
65     return cooked;
66 };
67 var ts;
68 (function (ts) {
69     ts.versionMajorMinor = "3.9";
70     ts.version = "3.9.7";
71     function tryGetNativeMap() {
72         return typeof Map !== "undefined" && "entries" in Map.prototype ? Map : undefined;
73     }
74     ts.tryGetNativeMap = tryGetNativeMap;
75     ts.Map = tryGetNativeMap() || (function () {
76         if (typeof ts.createMapShim === "function") {
77             return ts.createMapShim();
78         }
79         throw new Error("TypeScript requires an environment that provides a compatible native Map implementation.");
80     })();
81 })(ts || (ts = {}));
82 var ts;
83 (function (ts) {
84     ts.emptyArray = [];
85     function createMap() {
86         return new ts.Map();
87     }
88     ts.createMap = createMap;
89     function createMapFromEntries(entries) {
90         var map = createMap();
91         for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
92             var _a = entries_1[_i], key = _a[0], value = _a[1];
93             map.set(key, value);
94         }
95         return map;
96     }
97     ts.createMapFromEntries = createMapFromEntries;
98     function createMapFromTemplate(template) {
99         var map = new ts.Map();
100         for (var key in template) {
101             if (hasOwnProperty.call(template, key)) {
102                 map.set(key, template[key]);
103             }
104         }
105         return map;
106     }
107     ts.createMapFromTemplate = createMapFromTemplate;
108     function length(array) {
109         return array ? array.length : 0;
110     }
111     ts.length = length;
112     function forEach(array, callback) {
113         if (array) {
114             for (var i = 0; i < array.length; i++) {
115                 var result = callback(array[i], i);
116                 if (result) {
117                     return result;
118                 }
119             }
120         }
121         return undefined;
122     }
123     ts.forEach = forEach;
124     function forEachRight(array, callback) {
125         if (array) {
126             for (var i = array.length - 1; i >= 0; i--) {
127                 var result = callback(array[i], i);
128                 if (result) {
129                     return result;
130                 }
131             }
132         }
133         return undefined;
134     }
135     ts.forEachRight = forEachRight;
136     function firstDefined(array, callback) {
137         if (array === undefined) {
138             return undefined;
139         }
140         for (var i = 0; i < array.length; i++) {
141             var result = callback(array[i], i);
142             if (result !== undefined) {
143                 return result;
144             }
145         }
146         return undefined;
147     }
148     ts.firstDefined = firstDefined;
149     function firstDefinedIterator(iter, callback) {
150         while (true) {
151             var iterResult = iter.next();
152             if (iterResult.done) {
153                 return undefined;
154             }
155             var result = callback(iterResult.value);
156             if (result !== undefined) {
157                 return result;
158             }
159         }
160     }
161     ts.firstDefinedIterator = firstDefinedIterator;
162     function zipWith(arrayA, arrayB, callback) {
163         var result = [];
164         ts.Debug.assertEqual(arrayA.length, arrayB.length);
165         for (var i = 0; i < arrayA.length; i++) {
166             result.push(callback(arrayA[i], arrayB[i], i));
167         }
168         return result;
169     }
170     ts.zipWith = zipWith;
171     function zipToIterator(arrayA, arrayB) {
172         ts.Debug.assertEqual(arrayA.length, arrayB.length);
173         var i = 0;
174         return {
175             next: function () {
176                 if (i === arrayA.length) {
177                     return { value: undefined, done: true };
178                 }
179                 i++;
180                 return { value: [arrayA[i - 1], arrayB[i - 1]], done: false };
181             }
182         };
183     }
184     ts.zipToIterator = zipToIterator;
185     function zipToMap(keys, values) {
186         ts.Debug.assert(keys.length === values.length);
187         var map = createMap();
188         for (var i = 0; i < keys.length; ++i) {
189             map.set(keys[i], values[i]);
190         }
191         return map;
192     }
193     ts.zipToMap = zipToMap;
194     function every(array, callback) {
195         if (array) {
196             for (var i = 0; i < array.length; i++) {
197                 if (!callback(array[i], i)) {
198                     return false;
199                 }
200             }
201         }
202         return true;
203     }
204     ts.every = every;
205     function find(array, predicate) {
206         for (var i = 0; i < array.length; i++) {
207             var value = array[i];
208             if (predicate(value, i)) {
209                 return value;
210             }
211         }
212         return undefined;
213     }
214     ts.find = find;
215     function findLast(array, predicate) {
216         for (var i = array.length - 1; i >= 0; i--) {
217             var value = array[i];
218             if (predicate(value, i)) {
219                 return value;
220             }
221         }
222         return undefined;
223     }
224     ts.findLast = findLast;
225     function findIndex(array, predicate, startIndex) {
226         for (var i = startIndex || 0; i < array.length; i++) {
227             if (predicate(array[i], i)) {
228                 return i;
229             }
230         }
231         return -1;
232     }
233     ts.findIndex = findIndex;
234     function findLastIndex(array, predicate, startIndex) {
235         for (var i = startIndex === undefined ? array.length - 1 : startIndex; i >= 0; i--) {
236             if (predicate(array[i], i)) {
237                 return i;
238             }
239         }
240         return -1;
241     }
242     ts.findLastIndex = findLastIndex;
243     function findMap(array, callback) {
244         for (var i = 0; i < array.length; i++) {
245             var result = callback(array[i], i);
246             if (result) {
247                 return result;
248             }
249         }
250         return ts.Debug.fail();
251     }
252     ts.findMap = findMap;
253     function contains(array, value, equalityComparer) {
254         if (equalityComparer === void 0) { equalityComparer = equateValues; }
255         if (array) {
256             for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
257                 var v = array_1[_i];
258                 if (equalityComparer(v, value)) {
259                     return true;
260                 }
261             }
262         }
263         return false;
264     }
265     ts.contains = contains;
266     function arraysEqual(a, b, equalityComparer) {
267         if (equalityComparer === void 0) { equalityComparer = equateValues; }
268         return a.length === b.length && a.every(function (x, i) { return equalityComparer(x, b[i]); });
269     }
270     ts.arraysEqual = arraysEqual;
271     function indexOfAnyCharCode(text, charCodes, start) {
272         for (var i = start || 0; i < text.length; i++) {
273             if (contains(charCodes, text.charCodeAt(i))) {
274                 return i;
275             }
276         }
277         return -1;
278     }
279     ts.indexOfAnyCharCode = indexOfAnyCharCode;
280     function countWhere(array, predicate) {
281         var count = 0;
282         if (array) {
283             for (var i = 0; i < array.length; i++) {
284                 var v = array[i];
285                 if (predicate(v, i)) {
286                     count++;
287                 }
288             }
289         }
290         return count;
291     }
292     ts.countWhere = countWhere;
293     function filter(array, f) {
294         if (array) {
295             var len = array.length;
296             var i = 0;
297             while (i < len && f(array[i]))
298                 i++;
299             if (i < len) {
300                 var result = array.slice(0, i);
301                 i++;
302                 while (i < len) {
303                     var item = array[i];
304                     if (f(item)) {
305                         result.push(item);
306                     }
307                     i++;
308                 }
309                 return result;
310             }
311         }
312         return array;
313     }
314     ts.filter = filter;
315     function filterMutate(array, f) {
316         var outIndex = 0;
317         for (var i = 0; i < array.length; i++) {
318             if (f(array[i], i, array)) {
319                 array[outIndex] = array[i];
320                 outIndex++;
321             }
322         }
323         array.length = outIndex;
324     }
325     ts.filterMutate = filterMutate;
326     function clear(array) {
327         array.length = 0;
328     }
329     ts.clear = clear;
330     function map(array, f) {
331         var result;
332         if (array) {
333             result = [];
334             for (var i = 0; i < array.length; i++) {
335                 result.push(f(array[i], i));
336             }
337         }
338         return result;
339     }
340     ts.map = map;
341     function mapIterator(iter, mapFn) {
342         return {
343             next: function () {
344                 var iterRes = iter.next();
345                 return iterRes.done ? iterRes : { value: mapFn(iterRes.value), done: false };
346             }
347         };
348     }
349     ts.mapIterator = mapIterator;
350     function sameMap(array, f) {
351         if (array) {
352             for (var i = 0; i < array.length; i++) {
353                 var item = array[i];
354                 var mapped = f(item, i);
355                 if (item !== mapped) {
356                     var result = array.slice(0, i);
357                     result.push(mapped);
358                     for (i++; i < array.length; i++) {
359                         result.push(f(array[i], i));
360                     }
361                     return result;
362                 }
363             }
364         }
365         return array;
366     }
367     ts.sameMap = sameMap;
368     function flatten(array) {
369         var result = [];
370         for (var _i = 0, array_2 = array; _i < array_2.length; _i++) {
371             var v = array_2[_i];
372             if (v) {
373                 if (isArray(v)) {
374                     addRange(result, v);
375                 }
376                 else {
377                     result.push(v);
378                 }
379             }
380         }
381         return result;
382     }
383     ts.flatten = flatten;
384     function flatMap(array, mapfn) {
385         var result;
386         if (array) {
387             for (var i = 0; i < array.length; i++) {
388                 var v = mapfn(array[i], i);
389                 if (v) {
390                     if (isArray(v)) {
391                         result = addRange(result, v);
392                     }
393                     else {
394                         result = append(result, v);
395                     }
396                 }
397             }
398         }
399         return result || ts.emptyArray;
400     }
401     ts.flatMap = flatMap;
402     function flatMapToMutable(array, mapfn) {
403         var result = [];
404         if (array) {
405             for (var i = 0; i < array.length; i++) {
406                 var v = mapfn(array[i], i);
407                 if (v) {
408                     if (isArray(v)) {
409                         addRange(result, v);
410                     }
411                     else {
412                         result.push(v);
413                     }
414                 }
415             }
416         }
417         return result;
418     }
419     ts.flatMapToMutable = flatMapToMutable;
420     function flatMapIterator(iter, mapfn) {
421         var first = iter.next();
422         if (first.done) {
423             return ts.emptyIterator;
424         }
425         var currentIter = getIterator(first.value);
426         return {
427             next: function () {
428                 while (true) {
429                     var currentRes = currentIter.next();
430                     if (!currentRes.done) {
431                         return currentRes;
432                     }
433                     var iterRes = iter.next();
434                     if (iterRes.done) {
435                         return iterRes;
436                     }
437                     currentIter = getIterator(iterRes.value);
438                 }
439             },
440         };
441         function getIterator(x) {
442             var res = mapfn(x);
443             return res === undefined ? ts.emptyIterator : isArray(res) ? arrayIterator(res) : res;
444         }
445     }
446     ts.flatMapIterator = flatMapIterator;
447     function sameFlatMap(array, mapfn) {
448         var result;
449         if (array) {
450             for (var i = 0; i < array.length; i++) {
451                 var item = array[i];
452                 var mapped = mapfn(item, i);
453                 if (result || item !== mapped || isArray(mapped)) {
454                     if (!result) {
455                         result = array.slice(0, i);
456                     }
457                     if (isArray(mapped)) {
458                         addRange(result, mapped);
459                     }
460                     else {
461                         result.push(mapped);
462                     }
463                 }
464             }
465         }
466         return result || array;
467     }
468     ts.sameFlatMap = sameFlatMap;
469     function mapAllOrFail(array, mapFn) {
470         var result = [];
471         for (var i = 0; i < array.length; i++) {
472             var mapped = mapFn(array[i], i);
473             if (mapped === undefined) {
474                 return undefined;
475             }
476             result.push(mapped);
477         }
478         return result;
479     }
480     ts.mapAllOrFail = mapAllOrFail;
481     function mapDefined(array, mapFn) {
482         var result = [];
483         if (array) {
484             for (var i = 0; i < array.length; i++) {
485                 var mapped = mapFn(array[i], i);
486                 if (mapped !== undefined) {
487                     result.push(mapped);
488                 }
489             }
490         }
491         return result;
492     }
493     ts.mapDefined = mapDefined;
494     function mapDefinedIterator(iter, mapFn) {
495         return {
496             next: function () {
497                 while (true) {
498                     var res = iter.next();
499                     if (res.done) {
500                         return res;
501                     }
502                     var value = mapFn(res.value);
503                     if (value !== undefined) {
504                         return { value: value, done: false };
505                     }
506                 }
507             }
508         };
509     }
510     ts.mapDefinedIterator = mapDefinedIterator;
511     function mapDefinedMap(map, mapValue, mapKey) {
512         if (mapKey === void 0) { mapKey = identity; }
513         var result = createMap();
514         map.forEach(function (value, key) {
515             var mapped = mapValue(value, key);
516             if (mapped !== undefined) {
517                 result.set(mapKey(key), mapped);
518             }
519         });
520         return result;
521     }
522     ts.mapDefinedMap = mapDefinedMap;
523     ts.emptyIterator = { next: function () { return ({ value: undefined, done: true }); } };
524     function singleIterator(value) {
525         var done = false;
526         return {
527             next: function () {
528                 var wasDone = done;
529                 done = true;
530                 return wasDone ? { value: undefined, done: true } : { value: value, done: false };
531             }
532         };
533     }
534     ts.singleIterator = singleIterator;
535     function spanMap(array, keyfn, mapfn) {
536         var result;
537         if (array) {
538             result = [];
539             var len = array.length;
540             var previousKey = void 0;
541             var key = void 0;
542             var start = 0;
543             var pos = 0;
544             while (start < len) {
545                 while (pos < len) {
546                     var value = array[pos];
547                     key = keyfn(value, pos);
548                     if (pos === 0) {
549                         previousKey = key;
550                     }
551                     else if (key !== previousKey) {
552                         break;
553                     }
554                     pos++;
555                 }
556                 if (start < pos) {
557                     var v = mapfn(array.slice(start, pos), previousKey, start, pos);
558                     if (v) {
559                         result.push(v);
560                     }
561                     start = pos;
562                 }
563                 previousKey = key;
564                 pos++;
565             }
566         }
567         return result;
568     }
569     ts.spanMap = spanMap;
570     function mapEntries(map, f) {
571         if (!map) {
572             return undefined;
573         }
574         var result = createMap();
575         map.forEach(function (value, key) {
576             var _a = f(key, value), newKey = _a[0], newValue = _a[1];
577             result.set(newKey, newValue);
578         });
579         return result;
580     }
581     ts.mapEntries = mapEntries;
582     function some(array, predicate) {
583         if (array) {
584             if (predicate) {
585                 for (var _i = 0, array_3 = array; _i < array_3.length; _i++) {
586                     var v = array_3[_i];
587                     if (predicate(v)) {
588                         return true;
589                     }
590                 }
591             }
592             else {
593                 return array.length > 0;
594             }
595         }
596         return false;
597     }
598     ts.some = some;
599     function getRangesWhere(arr, pred, cb) {
600         var start;
601         for (var i = 0; i < arr.length; i++) {
602             if (pred(arr[i])) {
603                 start = start === undefined ? i : start;
604             }
605             else {
606                 if (start !== undefined) {
607                     cb(start, i);
608                     start = undefined;
609                 }
610             }
611         }
612         if (start !== undefined)
613             cb(start, arr.length);
614     }
615     ts.getRangesWhere = getRangesWhere;
616     function concatenate(array1, array2) {
617         if (!some(array2))
618             return array1;
619         if (!some(array1))
620             return array2;
621         return __spreadArrays(array1, array2);
622     }
623     ts.concatenate = concatenate;
624     function selectIndex(_, i) {
625         return i;
626     }
627     function indicesOf(array) {
628         return array.map(selectIndex);
629     }
630     ts.indicesOf = indicesOf;
631     function deduplicateRelational(array, equalityComparer, comparer) {
632         var indices = indicesOf(array);
633         stableSortIndices(array, indices, comparer);
634         var last = array[indices[0]];
635         var deduplicated = [indices[0]];
636         for (var i = 1; i < indices.length; i++) {
637             var index = indices[i];
638             var item = array[index];
639             if (!equalityComparer(last, item)) {
640                 deduplicated.push(index);
641                 last = item;
642             }
643         }
644         deduplicated.sort();
645         return deduplicated.map(function (i) { return array[i]; });
646     }
647     function deduplicateEquality(array, equalityComparer) {
648         var result = [];
649         for (var _i = 0, array_4 = array; _i < array_4.length; _i++) {
650             var item = array_4[_i];
651             pushIfUnique(result, item, equalityComparer);
652         }
653         return result;
654     }
655     function deduplicate(array, equalityComparer, comparer) {
656         return array.length === 0 ? [] :
657             array.length === 1 ? array.slice() :
658                 comparer ? deduplicateRelational(array, equalityComparer, comparer) :
659                     deduplicateEquality(array, equalityComparer);
660     }
661     ts.deduplicate = deduplicate;
662     function deduplicateSorted(array, comparer) {
663         if (array.length === 0)
664             return ts.emptyArray;
665         var last = array[0];
666         var deduplicated = [last];
667         for (var i = 1; i < array.length; i++) {
668             var next = array[i];
669             switch (comparer(next, last)) {
670                 case true:
671                 case 0:
672                     continue;
673                 case -1:
674                     return ts.Debug.fail("Array is unsorted.");
675             }
676             deduplicated.push(last = next);
677         }
678         return deduplicated;
679     }
680     function insertSorted(array, insert, compare) {
681         if (array.length === 0) {
682             array.push(insert);
683             return;
684         }
685         var insertIndex = binarySearch(array, insert, identity, compare);
686         if (insertIndex < 0) {
687             array.splice(~insertIndex, 0, insert);
688         }
689     }
690     ts.insertSorted = insertSorted;
691     function sortAndDeduplicate(array, comparer, equalityComparer) {
692         return deduplicateSorted(sort(array, comparer), equalityComparer || comparer || compareStringsCaseSensitive);
693     }
694     ts.sortAndDeduplicate = sortAndDeduplicate;
695     function arrayIsEqualTo(array1, array2, equalityComparer) {
696         if (equalityComparer === void 0) { equalityComparer = equateValues; }
697         if (!array1 || !array2) {
698             return array1 === array2;
699         }
700         if (array1.length !== array2.length) {
701             return false;
702         }
703         for (var i = 0; i < array1.length; i++) {
704             if (!equalityComparer(array1[i], array2[i], i)) {
705                 return false;
706             }
707         }
708         return true;
709     }
710     ts.arrayIsEqualTo = arrayIsEqualTo;
711     function compact(array) {
712         var result;
713         if (array) {
714             for (var i = 0; i < array.length; i++) {
715                 var v = array[i];
716                 if (result || !v) {
717                     if (!result) {
718                         result = array.slice(0, i);
719                     }
720                     if (v) {
721                         result.push(v);
722                     }
723                 }
724             }
725         }
726         return result || array;
727     }
728     ts.compact = compact;
729     function relativeComplement(arrayA, arrayB, comparer) {
730         if (!arrayB || !arrayA || arrayB.length === 0 || arrayA.length === 0)
731             return arrayB;
732         var result = [];
733         loopB: for (var offsetA = 0, offsetB = 0; offsetB < arrayB.length; offsetB++) {
734             if (offsetB > 0) {
735                 ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0);
736             }
737             loopA: for (var startA = offsetA; offsetA < arrayA.length; offsetA++) {
738                 if (offsetA > startA) {
739                     ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0);
740                 }
741                 switch (comparer(arrayB[offsetB], arrayA[offsetA])) {
742                     case -1:
743                         result.push(arrayB[offsetB]);
744                         continue loopB;
745                     case 0:
746                         continue loopB;
747                     case 1:
748                         continue loopA;
749                 }
750             }
751         }
752         return result;
753     }
754     ts.relativeComplement = relativeComplement;
755     function sum(array, prop) {
756         var result = 0;
757         for (var _i = 0, array_5 = array; _i < array_5.length; _i++) {
758             var v = array_5[_i];
759             result += v[prop];
760         }
761         return result;
762     }
763     ts.sum = sum;
764     function append(to, value) {
765         if (value === undefined)
766             return to;
767         if (to === undefined)
768             return [value];
769         to.push(value);
770         return to;
771     }
772     ts.append = append;
773     function combine(xs, ys) {
774         if (xs === undefined)
775             return ys;
776         if (ys === undefined)
777             return xs;
778         if (isArray(xs))
779             return isArray(ys) ? concatenate(xs, ys) : append(xs, ys);
780         if (isArray(ys))
781             return append(ys, xs);
782         return [xs, ys];
783     }
784     ts.combine = combine;
785     function toOffset(array, offset) {
786         return offset < 0 ? array.length + offset : offset;
787     }
788     function addRange(to, from, start, end) {
789         if (from === undefined || from.length === 0)
790             return to;
791         if (to === undefined)
792             return from.slice(start, end);
793         start = start === undefined ? 0 : toOffset(from, start);
794         end = end === undefined ? from.length : toOffset(from, end);
795         for (var i = start; i < end && i < from.length; i++) {
796             if (from[i] !== undefined) {
797                 to.push(from[i]);
798             }
799         }
800         return to;
801     }
802     ts.addRange = addRange;
803     function pushIfUnique(array, toAdd, equalityComparer) {
804         if (contains(array, toAdd, equalityComparer)) {
805             return false;
806         }
807         else {
808             array.push(toAdd);
809             return true;
810         }
811     }
812     ts.pushIfUnique = pushIfUnique;
813     function appendIfUnique(array, toAdd, equalityComparer) {
814         if (array) {
815             pushIfUnique(array, toAdd, equalityComparer);
816             return array;
817         }
818         else {
819             return [toAdd];
820         }
821     }
822     ts.appendIfUnique = appendIfUnique;
823     function stableSortIndices(array, indices, comparer) {
824         indices.sort(function (x, y) { return comparer(array[x], array[y]) || compareValues(x, y); });
825     }
826     function sort(array, comparer) {
827         return (array.length === 0 ? array : array.slice().sort(comparer));
828     }
829     ts.sort = sort;
830     function arrayIterator(array) {
831         var i = 0;
832         return { next: function () {
833                 if (i === array.length) {
834                     return { value: undefined, done: true };
835                 }
836                 else {
837                     i++;
838                     return { value: array[i - 1], done: false };
839                 }
840             } };
841     }
842     ts.arrayIterator = arrayIterator;
843     function arrayReverseIterator(array) {
844         var i = array.length;
845         return {
846             next: function () {
847                 if (i === 0) {
848                     return { value: undefined, done: true };
849                 }
850                 else {
851                     i--;
852                     return { value: array[i], done: false };
853                 }
854             }
855         };
856     }
857     ts.arrayReverseIterator = arrayReverseIterator;
858     function stableSort(array, comparer) {
859         var indices = indicesOf(array);
860         stableSortIndices(array, indices, comparer);
861         return indices.map(function (i) { return array[i]; });
862     }
863     ts.stableSort = stableSort;
864     function rangeEquals(array1, array2, pos, end) {
865         while (pos < end) {
866             if (array1[pos] !== array2[pos]) {
867                 return false;
868             }
869             pos++;
870         }
871         return true;
872     }
873     ts.rangeEquals = rangeEquals;
874     function elementAt(array, offset) {
875         if (array) {
876             offset = toOffset(array, offset);
877             if (offset < array.length) {
878                 return array[offset];
879             }
880         }
881         return undefined;
882     }
883     ts.elementAt = elementAt;
884     function firstOrUndefined(array) {
885         return array.length === 0 ? undefined : array[0];
886     }
887     ts.firstOrUndefined = firstOrUndefined;
888     function first(array) {
889         ts.Debug.assert(array.length !== 0);
890         return array[0];
891     }
892     ts.first = first;
893     function lastOrUndefined(array) {
894         return array.length === 0 ? undefined : array[array.length - 1];
895     }
896     ts.lastOrUndefined = lastOrUndefined;
897     function last(array) {
898         ts.Debug.assert(array.length !== 0);
899         return array[array.length - 1];
900     }
901     ts.last = last;
902     function singleOrUndefined(array) {
903         return array && array.length === 1
904             ? array[0]
905             : undefined;
906     }
907     ts.singleOrUndefined = singleOrUndefined;
908     function singleOrMany(array) {
909         return array && array.length === 1
910             ? array[0]
911             : array;
912     }
913     ts.singleOrMany = singleOrMany;
914     function replaceElement(array, index, value) {
915         var result = array.slice(0);
916         result[index] = value;
917         return result;
918     }
919     ts.replaceElement = replaceElement;
920     function binarySearch(array, value, keySelector, keyComparer, offset) {
921         return binarySearchKey(array, keySelector(value), keySelector, keyComparer, offset);
922     }
923     ts.binarySearch = binarySearch;
924     function binarySearchKey(array, key, keySelector, keyComparer, offset) {
925         if (!some(array)) {
926             return -1;
927         }
928         var low = offset || 0;
929         var high = array.length - 1;
930         while (low <= high) {
931             var middle = low + ((high - low) >> 1);
932             var midKey = keySelector(array[middle]);
933             switch (keyComparer(midKey, key)) {
934                 case -1:
935                     low = middle + 1;
936                     break;
937                 case 0:
938                     return middle;
939                 case 1:
940                     high = middle - 1;
941                     break;
942             }
943         }
944         return ~low;
945     }
946     ts.binarySearchKey = binarySearchKey;
947     function reduceLeft(array, f, initial, start, count) {
948         if (array && array.length > 0) {
949             var size = array.length;
950             if (size > 0) {
951                 var pos = start === undefined || start < 0 ? 0 : start;
952                 var end = count === undefined || pos + count > size - 1 ? size - 1 : pos + count;
953                 var result = void 0;
954                 if (arguments.length <= 2) {
955                     result = array[pos];
956                     pos++;
957                 }
958                 else {
959                     result = initial;
960                 }
961                 while (pos <= end) {
962                     result = f(result, array[pos], pos);
963                     pos++;
964                 }
965                 return result;
966             }
967         }
968         return initial;
969     }
970     ts.reduceLeft = reduceLeft;
971     var hasOwnProperty = Object.prototype.hasOwnProperty;
972     function hasProperty(map, key) {
973         return hasOwnProperty.call(map, key);
974     }
975     ts.hasProperty = hasProperty;
976     function getProperty(map, key) {
977         return hasOwnProperty.call(map, key) ? map[key] : undefined;
978     }
979     ts.getProperty = getProperty;
980     function getOwnKeys(map) {
981         var keys = [];
982         for (var key in map) {
983             if (hasOwnProperty.call(map, key)) {
984                 keys.push(key);
985             }
986         }
987         return keys;
988     }
989     ts.getOwnKeys = getOwnKeys;
990     function getAllKeys(obj) {
991         var result = [];
992         do {
993             var names = Object.getOwnPropertyNames(obj);
994             for (var _i = 0, names_1 = names; _i < names_1.length; _i++) {
995                 var name = names_1[_i];
996                 pushIfUnique(result, name);
997             }
998         } while (obj = Object.getPrototypeOf(obj));
999         return result;
1000     }
1001     ts.getAllKeys = getAllKeys;
1002     function getOwnValues(sparseArray) {
1003         var values = [];
1004         for (var key in sparseArray) {
1005             if (hasOwnProperty.call(sparseArray, key)) {
1006                 values.push(sparseArray[key]);
1007             }
1008         }
1009         return values;
1010     }
1011     ts.getOwnValues = getOwnValues;
1012     function arrayFrom(iterator, map) {
1013         var result = [];
1014         for (var iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) {
1015             result.push(map ? map(iterResult.value) : iterResult.value);
1016         }
1017         return result;
1018     }
1019     ts.arrayFrom = arrayFrom;
1020     function assign(t) {
1021         var args = [];
1022         for (var _i = 1; _i < arguments.length; _i++) {
1023             args[_i - 1] = arguments[_i];
1024         }
1025         for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
1026             var arg = args_1[_a];
1027             if (arg === undefined)
1028                 continue;
1029             for (var p in arg) {
1030                 if (hasProperty(arg, p)) {
1031                     t[p] = arg[p];
1032                 }
1033             }
1034         }
1035         return t;
1036     }
1037     ts.assign = assign;
1038     function equalOwnProperties(left, right, equalityComparer) {
1039         if (equalityComparer === void 0) { equalityComparer = equateValues; }
1040         if (left === right)
1041             return true;
1042         if (!left || !right)
1043             return false;
1044         for (var key in left) {
1045             if (hasOwnProperty.call(left, key)) {
1046                 if (!hasOwnProperty.call(right, key))
1047                     return false;
1048                 if (!equalityComparer(left[key], right[key]))
1049                     return false;
1050             }
1051         }
1052         for (var key in right) {
1053             if (hasOwnProperty.call(right, key)) {
1054                 if (!hasOwnProperty.call(left, key))
1055                     return false;
1056             }
1057         }
1058         return true;
1059     }
1060     ts.equalOwnProperties = equalOwnProperties;
1061     function arrayToMap(array, makeKey, makeValue) {
1062         if (makeValue === void 0) { makeValue = identity; }
1063         var result = createMap();
1064         for (var _i = 0, array_6 = array; _i < array_6.length; _i++) {
1065             var value = array_6[_i];
1066             var key = makeKey(value);
1067             if (key !== undefined)
1068                 result.set(key, makeValue(value));
1069         }
1070         return result;
1071     }
1072     ts.arrayToMap = arrayToMap;
1073     function arrayToNumericMap(array, makeKey, makeValue) {
1074         if (makeValue === void 0) { makeValue = identity; }
1075         var result = [];
1076         for (var _i = 0, array_7 = array; _i < array_7.length; _i++) {
1077             var value = array_7[_i];
1078             result[makeKey(value)] = makeValue(value);
1079         }
1080         return result;
1081     }
1082     ts.arrayToNumericMap = arrayToNumericMap;
1083     function arrayToMultiMap(values, makeKey, makeValue) {
1084         if (makeValue === void 0) { makeValue = identity; }
1085         var result = createMultiMap();
1086         for (var _i = 0, values_1 = values; _i < values_1.length; _i++) {
1087             var value = values_1[_i];
1088             result.add(makeKey(value), makeValue(value));
1089         }
1090         return result;
1091     }
1092     ts.arrayToMultiMap = arrayToMultiMap;
1093     function group(values, getGroupId, resultSelector) {
1094         if (resultSelector === void 0) { resultSelector = identity; }
1095         return arrayFrom(arrayToMultiMap(values, getGroupId).values(), resultSelector);
1096     }
1097     ts.group = group;
1098     function clone(object) {
1099         var result = {};
1100         for (var id in object) {
1101             if (hasOwnProperty.call(object, id)) {
1102                 result[id] = object[id];
1103             }
1104         }
1105         return result;
1106     }
1107     ts.clone = clone;
1108     function extend(first, second) {
1109         var result = {};
1110         for (var id in second) {
1111             if (hasOwnProperty.call(second, id)) {
1112                 result[id] = second[id];
1113             }
1114         }
1115         for (var id in first) {
1116             if (hasOwnProperty.call(first, id)) {
1117                 result[id] = first[id];
1118             }
1119         }
1120         return result;
1121     }
1122     ts.extend = extend;
1123     function copyProperties(first, second) {
1124         for (var id in second) {
1125             if (hasOwnProperty.call(second, id)) {
1126                 first[id] = second[id];
1127             }
1128         }
1129     }
1130     ts.copyProperties = copyProperties;
1131     function maybeBind(obj, fn) {
1132         return fn ? fn.bind(obj) : undefined;
1133     }
1134     ts.maybeBind = maybeBind;
1135     function mapMap(map, f) {
1136         var result = createMap();
1137         map.forEach(function (t, key) { return result.set.apply(result, (f(t, key))); });
1138         return result;
1139     }
1140     ts.mapMap = mapMap;
1141     function createMultiMap() {
1142         var map = createMap();
1143         map.add = multiMapAdd;
1144         map.remove = multiMapRemove;
1145         return map;
1146     }
1147     ts.createMultiMap = createMultiMap;
1148     function multiMapAdd(key, value) {
1149         var values = this.get(key);
1150         if (values) {
1151             values.push(value);
1152         }
1153         else {
1154             this.set(key, values = [value]);
1155         }
1156         return values;
1157     }
1158     function multiMapRemove(key, value) {
1159         var values = this.get(key);
1160         if (values) {
1161             unorderedRemoveItem(values, value);
1162             if (!values.length) {
1163                 this.delete(key);
1164             }
1165         }
1166     }
1167     function createUnderscoreEscapedMultiMap() {
1168         return createMultiMap();
1169     }
1170     ts.createUnderscoreEscapedMultiMap = createUnderscoreEscapedMultiMap;
1171     function isArray(value) {
1172         return Array.isArray ? Array.isArray(value) : value instanceof Array;
1173     }
1174     ts.isArray = isArray;
1175     function toArray(value) {
1176         return isArray(value) ? value : [value];
1177     }
1178     ts.toArray = toArray;
1179     function isString(text) {
1180         return typeof text === "string";
1181     }
1182     ts.isString = isString;
1183     function isNumber(x) {
1184         return typeof x === "number";
1185     }
1186     ts.isNumber = isNumber;
1187     function tryCast(value, test) {
1188         return value !== undefined && test(value) ? value : undefined;
1189     }
1190     ts.tryCast = tryCast;
1191     function cast(value, test) {
1192         if (value !== undefined && test(value))
1193             return value;
1194         return ts.Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + ts.Debug.getFunctionName(test) + "'.");
1195     }
1196     ts.cast = cast;
1197     function noop(_) { }
1198     ts.noop = noop;
1199     function returnFalse() { return false; }
1200     ts.returnFalse = returnFalse;
1201     function returnTrue() { return true; }
1202     ts.returnTrue = returnTrue;
1203     function returnUndefined() { return undefined; }
1204     ts.returnUndefined = returnUndefined;
1205     function identity(x) { return x; }
1206     ts.identity = identity;
1207     function toLowerCase(x) { return x.toLowerCase(); }
1208     ts.toLowerCase = toLowerCase;
1209     var fileNameLowerCaseRegExp = /[^\u0130\u0131\u00DFa-z0-9\\/:\-_\. ]+/g;
1210     function toFileNameLowerCase(x) {
1211         return fileNameLowerCaseRegExp.test(x) ?
1212             x.replace(fileNameLowerCaseRegExp, toLowerCase) :
1213             x;
1214     }
1215     ts.toFileNameLowerCase = toFileNameLowerCase;
1216     function notImplemented() {
1217         throw new Error("Not implemented");
1218     }
1219     ts.notImplemented = notImplemented;
1220     function memoize(callback) {
1221         var value;
1222         return function () {
1223             if (callback) {
1224                 value = callback();
1225                 callback = undefined;
1226             }
1227             return value;
1228         };
1229     }
1230     ts.memoize = memoize;
1231     function compose(a, b, c, d, e) {
1232         if (!!e) {
1233             var args_2 = [];
1234             for (var i = 0; i < arguments.length; i++) {
1235                 args_2[i] = arguments[i];
1236             }
1237             return function (t) { return reduceLeft(args_2, function (u, f) { return f(u); }, t); };
1238         }
1239         else if (d) {
1240             return function (t) { return d(c(b(a(t)))); };
1241         }
1242         else if (c) {
1243             return function (t) { return c(b(a(t))); };
1244         }
1245         else if (b) {
1246             return function (t) { return b(a(t)); };
1247         }
1248         else if (a) {
1249             return function (t) { return a(t); };
1250         }
1251         else {
1252             return function (t) { return t; };
1253         }
1254     }
1255     ts.compose = compose;
1256     function equateValues(a, b) {
1257         return a === b;
1258     }
1259     ts.equateValues = equateValues;
1260     function equateStringsCaseInsensitive(a, b) {
1261         return a === b
1262             || a !== undefined
1263                 && b !== undefined
1264                 && a.toUpperCase() === b.toUpperCase();
1265     }
1266     ts.equateStringsCaseInsensitive = equateStringsCaseInsensitive;
1267     function equateStringsCaseSensitive(a, b) {
1268         return equateValues(a, b);
1269     }
1270     ts.equateStringsCaseSensitive = equateStringsCaseSensitive;
1271     function compareComparableValues(a, b) {
1272         return a === b ? 0 :
1273             a === undefined ? -1 :
1274                 b === undefined ? 1 :
1275                     a < b ? -1 :
1276                         1;
1277     }
1278     function compareValues(a, b) {
1279         return compareComparableValues(a, b);
1280     }
1281     ts.compareValues = compareValues;
1282     function compareTextSpans(a, b) {
1283         return compareValues(a === null || a === void 0 ? void 0 : a.start, b === null || b === void 0 ? void 0 : b.start) || compareValues(a === null || a === void 0 ? void 0 : a.length, b === null || b === void 0 ? void 0 : b.length);
1284     }
1285     ts.compareTextSpans = compareTextSpans;
1286     function min(a, b, compare) {
1287         return compare(a, b) === -1 ? a : b;
1288     }
1289     ts.min = min;
1290     function compareStringsCaseInsensitive(a, b) {
1291         if (a === b)
1292             return 0;
1293         if (a === undefined)
1294             return -1;
1295         if (b === undefined)
1296             return 1;
1297         a = a.toUpperCase();
1298         b = b.toUpperCase();
1299         return a < b ? -1 : a > b ? 1 : 0;
1300     }
1301     ts.compareStringsCaseInsensitive = compareStringsCaseInsensitive;
1302     function compareStringsCaseSensitive(a, b) {
1303         return compareComparableValues(a, b);
1304     }
1305     ts.compareStringsCaseSensitive = compareStringsCaseSensitive;
1306     function getStringComparer(ignoreCase) {
1307         return ignoreCase ? compareStringsCaseInsensitive : compareStringsCaseSensitive;
1308     }
1309     ts.getStringComparer = getStringComparer;
1310     var createUIStringComparer = (function () {
1311         var defaultComparer;
1312         var enUSComparer;
1313         var stringComparerFactory = getStringComparerFactory();
1314         return createStringComparer;
1315         function compareWithCallback(a, b, comparer) {
1316             if (a === b)
1317                 return 0;
1318             if (a === undefined)
1319                 return -1;
1320             if (b === undefined)
1321                 return 1;
1322             var value = comparer(a, b);
1323             return value < 0 ? -1 : value > 0 ? 1 : 0;
1324         }
1325         function createIntlCollatorStringComparer(locale) {
1326             var comparer = new Intl.Collator(locale, { usage: "sort", sensitivity: "variant" }).compare;
1327             return function (a, b) { return compareWithCallback(a, b, comparer); };
1328         }
1329         function createLocaleCompareStringComparer(locale) {
1330             if (locale !== undefined)
1331                 return createFallbackStringComparer();
1332             return function (a, b) { return compareWithCallback(a, b, compareStrings); };
1333             function compareStrings(a, b) {
1334                 return a.localeCompare(b);
1335             }
1336         }
1337         function createFallbackStringComparer() {
1338             return function (a, b) { return compareWithCallback(a, b, compareDictionaryOrder); };
1339             function compareDictionaryOrder(a, b) {
1340                 return compareStrings(a.toUpperCase(), b.toUpperCase()) || compareStrings(a, b);
1341             }
1342             function compareStrings(a, b) {
1343                 return a < b ? -1 : a > b ? 1 : 0;
1344             }
1345         }
1346         function getStringComparerFactory() {
1347             if (typeof Intl === "object" && typeof Intl.Collator === "function") {
1348                 return createIntlCollatorStringComparer;
1349             }
1350             if (typeof String.prototype.localeCompare === "function" &&
1351                 typeof String.prototype.toLocaleUpperCase === "function" &&
1352                 "a".localeCompare("B") < 0) {
1353                 return createLocaleCompareStringComparer;
1354             }
1355             return createFallbackStringComparer;
1356         }
1357         function createStringComparer(locale) {
1358             if (locale === undefined) {
1359                 return defaultComparer || (defaultComparer = stringComparerFactory(locale));
1360             }
1361             else if (locale === "en-US") {
1362                 return enUSComparer || (enUSComparer = stringComparerFactory(locale));
1363             }
1364             else {
1365                 return stringComparerFactory(locale);
1366             }
1367         }
1368     })();
1369     var uiComparerCaseSensitive;
1370     var uiLocale;
1371     function getUILocale() {
1372         return uiLocale;
1373     }
1374     ts.getUILocale = getUILocale;
1375     function setUILocale(value) {
1376         if (uiLocale !== value) {
1377             uiLocale = value;
1378             uiComparerCaseSensitive = undefined;
1379         }
1380     }
1381     ts.setUILocale = setUILocale;
1382     function compareStringsCaseSensitiveUI(a, b) {
1383         var comparer = uiComparerCaseSensitive || (uiComparerCaseSensitive = createUIStringComparer(uiLocale));
1384         return comparer(a, b);
1385     }
1386     ts.compareStringsCaseSensitiveUI = compareStringsCaseSensitiveUI;
1387     function compareProperties(a, b, key, comparer) {
1388         return a === b ? 0 :
1389             a === undefined ? -1 :
1390                 b === undefined ? 1 :
1391                     comparer(a[key], b[key]);
1392     }
1393     ts.compareProperties = compareProperties;
1394     function compareBooleans(a, b) {
1395         return compareValues(a ? 1 : 0, b ? 1 : 0);
1396     }
1397     ts.compareBooleans = compareBooleans;
1398     function getSpellingSuggestion(name, candidates, getName) {
1399         var maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34));
1400         var bestDistance = Math.floor(name.length * 0.4) + 1;
1401         var bestCandidate;
1402         var justCheckExactMatches = false;
1403         var nameLowerCase = name.toLowerCase();
1404         for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
1405             var candidate = candidates_1[_i];
1406             var candidateName = getName(candidate);
1407             if (candidateName !== undefined && Math.abs(candidateName.length - nameLowerCase.length) <= maximumLengthDifference) {
1408                 var candidateNameLowerCase = candidateName.toLowerCase();
1409                 if (candidateNameLowerCase === nameLowerCase) {
1410                     if (candidateName === name) {
1411                         continue;
1412                     }
1413                     return candidate;
1414                 }
1415                 if (justCheckExactMatches) {
1416                     continue;
1417                 }
1418                 if (candidateName.length < 3) {
1419                     continue;
1420                 }
1421                 var distance = levenshteinWithMax(nameLowerCase, candidateNameLowerCase, bestDistance - 1);
1422                 if (distance === undefined) {
1423                     continue;
1424                 }
1425                 if (distance < 3) {
1426                     justCheckExactMatches = true;
1427                     bestCandidate = candidate;
1428                 }
1429                 else {
1430                     ts.Debug.assert(distance < bestDistance);
1431                     bestDistance = distance;
1432                     bestCandidate = candidate;
1433                 }
1434             }
1435         }
1436         return bestCandidate;
1437     }
1438     ts.getSpellingSuggestion = getSpellingSuggestion;
1439     function levenshteinWithMax(s1, s2, max) {
1440         var previous = new Array(s2.length + 1);
1441         var current = new Array(s2.length + 1);
1442         var big = max + 1;
1443         for (var i = 0; i <= s2.length; i++) {
1444             previous[i] = i;
1445         }
1446         for (var i = 1; i <= s1.length; i++) {
1447             var c1 = s1.charCodeAt(i - 1);
1448             var minJ = i > max ? i - max : 1;
1449             var maxJ = s2.length > max + i ? max + i : s2.length;
1450             current[0] = i;
1451             var colMin = i;
1452             for (var j = 1; j < minJ; j++) {
1453                 current[j] = big;
1454             }
1455             for (var j = minJ; j <= maxJ; j++) {
1456                 var dist = c1 === s2.charCodeAt(j - 1)
1457                     ? previous[j - 1]
1458                     : Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + 2);
1459                 current[j] = dist;
1460                 colMin = Math.min(colMin, dist);
1461             }
1462             for (var j = maxJ + 1; j <= s2.length; j++) {
1463                 current[j] = big;
1464             }
1465             if (colMin > max) {
1466                 return undefined;
1467             }
1468             var temp = previous;
1469             previous = current;
1470             current = temp;
1471         }
1472         var res = previous[s2.length];
1473         return res > max ? undefined : res;
1474     }
1475     function endsWith(str, suffix) {
1476         var expectedPos = str.length - suffix.length;
1477         return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos;
1478     }
1479     ts.endsWith = endsWith;
1480     function removeSuffix(str, suffix) {
1481         return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : str;
1482     }
1483     ts.removeSuffix = removeSuffix;
1484     function tryRemoveSuffix(str, suffix) {
1485         return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : undefined;
1486     }
1487     ts.tryRemoveSuffix = tryRemoveSuffix;
1488     function stringContains(str, substring) {
1489         return str.indexOf(substring) !== -1;
1490     }
1491     ts.stringContains = stringContains;
1492     function removeMinAndVersionNumbers(fileName) {
1493         var trailingMinOrVersion = /[.-]((min)|(\d+(\.\d+)*))$/;
1494         return fileName.replace(trailingMinOrVersion, "").replace(trailingMinOrVersion, "");
1495     }
1496     ts.removeMinAndVersionNumbers = removeMinAndVersionNumbers;
1497     function orderedRemoveItem(array, item) {
1498         for (var i = 0; i < array.length; i++) {
1499             if (array[i] === item) {
1500                 orderedRemoveItemAt(array, i);
1501                 return true;
1502             }
1503         }
1504         return false;
1505     }
1506     ts.orderedRemoveItem = orderedRemoveItem;
1507     function orderedRemoveItemAt(array, index) {
1508         for (var i = index; i < array.length - 1; i++) {
1509             array[i] = array[i + 1];
1510         }
1511         array.pop();
1512     }
1513     ts.orderedRemoveItemAt = orderedRemoveItemAt;
1514     function unorderedRemoveItemAt(array, index) {
1515         array[index] = array[array.length - 1];
1516         array.pop();
1517     }
1518     ts.unorderedRemoveItemAt = unorderedRemoveItemAt;
1519     function unorderedRemoveItem(array, item) {
1520         return unorderedRemoveFirstItemWhere(array, function (element) { return element === item; });
1521     }
1522     ts.unorderedRemoveItem = unorderedRemoveItem;
1523     function unorderedRemoveFirstItemWhere(array, predicate) {
1524         for (var i = 0; i < array.length; i++) {
1525             if (predicate(array[i])) {
1526                 unorderedRemoveItemAt(array, i);
1527                 return true;
1528             }
1529         }
1530         return false;
1531     }
1532     function createGetCanonicalFileName(useCaseSensitiveFileNames) {
1533         return useCaseSensitiveFileNames ? identity : toFileNameLowerCase;
1534     }
1535     ts.createGetCanonicalFileName = createGetCanonicalFileName;
1536     function patternText(_a) {
1537         var prefix = _a.prefix, suffix = _a.suffix;
1538         return prefix + "*" + suffix;
1539     }
1540     ts.patternText = patternText;
1541     function matchedText(pattern, candidate) {
1542         ts.Debug.assert(isPatternMatch(pattern, candidate));
1543         return candidate.substring(pattern.prefix.length, candidate.length - pattern.suffix.length);
1544     }
1545     ts.matchedText = matchedText;
1546     function findBestPatternMatch(values, getPattern, candidate) {
1547         var matchedValue;
1548         var longestMatchPrefixLength = -1;
1549         for (var _i = 0, values_2 = values; _i < values_2.length; _i++) {
1550             var v = values_2[_i];
1551             var pattern = getPattern(v);
1552             if (isPatternMatch(pattern, candidate) && pattern.prefix.length > longestMatchPrefixLength) {
1553                 longestMatchPrefixLength = pattern.prefix.length;
1554                 matchedValue = v;
1555             }
1556         }
1557         return matchedValue;
1558     }
1559     ts.findBestPatternMatch = findBestPatternMatch;
1560     function startsWith(str, prefix) {
1561         return str.lastIndexOf(prefix, 0) === 0;
1562     }
1563     ts.startsWith = startsWith;
1564     function removePrefix(str, prefix) {
1565         return startsWith(str, prefix) ? str.substr(prefix.length) : str;
1566     }
1567     ts.removePrefix = removePrefix;
1568     function tryRemovePrefix(str, prefix, getCanonicalFileName) {
1569         if (getCanonicalFileName === void 0) { getCanonicalFileName = identity; }
1570         return startsWith(getCanonicalFileName(str), getCanonicalFileName(prefix)) ? str.substring(prefix.length) : undefined;
1571     }
1572     ts.tryRemovePrefix = tryRemovePrefix;
1573     function isPatternMatch(_a, candidate) {
1574         var prefix = _a.prefix, suffix = _a.suffix;
1575         return candidate.length >= prefix.length + suffix.length &&
1576             startsWith(candidate, prefix) &&
1577             endsWith(candidate, suffix);
1578     }
1579     function and(f, g) {
1580         return function (arg) { return f(arg) && g(arg); };
1581     }
1582     ts.and = and;
1583     function or() {
1584         var fs = [];
1585         for (var _i = 0; _i < arguments.length; _i++) {
1586             fs[_i] = arguments[_i];
1587         }
1588         return function () {
1589             var args = [];
1590             for (var _i = 0; _i < arguments.length; _i++) {
1591                 args[_i] = arguments[_i];
1592             }
1593             for (var _a = 0, fs_1 = fs; _a < fs_1.length; _a++) {
1594                 var f = fs_1[_a];
1595                 if (f.apply(void 0, args)) {
1596                     return true;
1597                 }
1598             }
1599             return false;
1600         };
1601     }
1602     ts.or = or;
1603     function not(fn) {
1604         return function () {
1605             var args = [];
1606             for (var _i = 0; _i < arguments.length; _i++) {
1607                 args[_i] = arguments[_i];
1608             }
1609             return !fn.apply(void 0, args);
1610         };
1611     }
1612     ts.not = not;
1613     function assertType(_) { }
1614     ts.assertType = assertType;
1615     function singleElementArray(t) {
1616         return t === undefined ? undefined : [t];
1617     }
1618     ts.singleElementArray = singleElementArray;
1619     function enumerateInsertsAndDeletes(newItems, oldItems, comparer, inserted, deleted, unchanged) {
1620         unchanged = unchanged || noop;
1621         var newIndex = 0;
1622         var oldIndex = 0;
1623         var newLen = newItems.length;
1624         var oldLen = oldItems.length;
1625         while (newIndex < newLen && oldIndex < oldLen) {
1626             var newItem = newItems[newIndex];
1627             var oldItem = oldItems[oldIndex];
1628             var compareResult = comparer(newItem, oldItem);
1629             if (compareResult === -1) {
1630                 inserted(newItem);
1631                 newIndex++;
1632             }
1633             else if (compareResult === 1) {
1634                 deleted(oldItem);
1635                 oldIndex++;
1636             }
1637             else {
1638                 unchanged(oldItem, newItem);
1639                 newIndex++;
1640                 oldIndex++;
1641             }
1642         }
1643         while (newIndex < newLen) {
1644             inserted(newItems[newIndex++]);
1645         }
1646         while (oldIndex < oldLen) {
1647             deleted(oldItems[oldIndex++]);
1648         }
1649     }
1650     ts.enumerateInsertsAndDeletes = enumerateInsertsAndDeletes;
1651     function fill(length, cb) {
1652         var result = Array(length);
1653         for (var i = 0; i < length; i++) {
1654             result[i] = cb(i);
1655         }
1656         return result;
1657     }
1658     ts.fill = fill;
1659     function cartesianProduct(arrays) {
1660         var result = [];
1661         cartesianProductWorker(arrays, result, undefined, 0);
1662         return result;
1663     }
1664     ts.cartesianProduct = cartesianProduct;
1665     function cartesianProductWorker(arrays, result, outer, index) {
1666         for (var _i = 0, _a = arrays[index]; _i < _a.length; _i++) {
1667             var element = _a[_i];
1668             var inner = void 0;
1669             if (outer) {
1670                 inner = outer.slice();
1671                 inner.push(element);
1672             }
1673             else {
1674                 inner = [element];
1675             }
1676             if (index === arrays.length - 1) {
1677                 result.push(inner);
1678             }
1679             else {
1680                 cartesianProductWorker(arrays, result, inner, index + 1);
1681             }
1682         }
1683     }
1684     function padLeft(s, length) {
1685         while (s.length < length) {
1686             s = " " + s;
1687         }
1688         return s;
1689     }
1690     ts.padLeft = padLeft;
1691     function padRight(s, length) {
1692         while (s.length < length) {
1693             s = s + " ";
1694         }
1695         return s;
1696     }
1697     ts.padRight = padRight;
1698 })(ts || (ts = {}));
1699 var ts;
1700 (function (ts) {
1701     var Debug;
1702     (function (Debug) {
1703         var currentAssertionLevel = 0;
1704         Debug.isDebugging = false;
1705         var assertionCache = {};
1706         function getAssertionLevel() {
1707             return currentAssertionLevel;
1708         }
1709         Debug.getAssertionLevel = getAssertionLevel;
1710         function setAssertionLevel(level) {
1711             var prevAssertionLevel = currentAssertionLevel;
1712             currentAssertionLevel = level;
1713             if (level > prevAssertionLevel) {
1714                 for (var _i = 0, _a = ts.getOwnKeys(assertionCache); _i < _a.length; _i++) {
1715                     var key = _a[_i];
1716                     var cachedFunc = assertionCache[key];
1717                     if (cachedFunc !== undefined && Debug[key] !== cachedFunc.assertion && level >= cachedFunc.level) {
1718                         Debug[key] = cachedFunc;
1719                         assertionCache[key] = undefined;
1720                     }
1721                 }
1722             }
1723         }
1724         Debug.setAssertionLevel = setAssertionLevel;
1725         function shouldAssert(level) {
1726             return currentAssertionLevel >= level;
1727         }
1728         Debug.shouldAssert = shouldAssert;
1729         function shouldAssertFunction(level, name) {
1730             if (!shouldAssert(level)) {
1731                 assertionCache[name] = { level: level, assertion: Debug[name] };
1732                 Debug[name] = ts.noop;
1733                 return false;
1734             }
1735             return true;
1736         }
1737         function fail(message, stackCrawlMark) {
1738             debugger;
1739             var e = new Error(message ? "Debug Failure. " + message : "Debug Failure.");
1740             if (Error.captureStackTrace) {
1741                 Error.captureStackTrace(e, stackCrawlMark || fail);
1742             }
1743             throw e;
1744         }
1745         Debug.fail = fail;
1746         function failBadSyntaxKind(node, message, stackCrawlMark) {
1747             return fail((message || "Unexpected node.") + "\r\nNode " + formatSyntaxKind(node.kind) + " was unexpected.", stackCrawlMark || failBadSyntaxKind);
1748         }
1749         Debug.failBadSyntaxKind = failBadSyntaxKind;
1750         function assert(expression, message, verboseDebugInfo, stackCrawlMark) {
1751             if (!expression) {
1752                 message = message ? "False expression: " + message : "False expression.";
1753                 if (verboseDebugInfo) {
1754                     message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo());
1755                 }
1756                 fail(message, stackCrawlMark || assert);
1757             }
1758         }
1759         Debug.assert = assert;
1760         function assertEqual(a, b, msg, msg2, stackCrawlMark) {
1761             if (a !== b) {
1762                 var message = msg ? msg2 ? msg + " " + msg2 : msg : "";
1763                 fail("Expected " + a + " === " + b + ". " + message, stackCrawlMark || assertEqual);
1764             }
1765         }
1766         Debug.assertEqual = assertEqual;
1767         function assertLessThan(a, b, msg, stackCrawlMark) {
1768             if (a >= b) {
1769                 fail("Expected " + a + " < " + b + ". " + (msg || ""), stackCrawlMark || assertLessThan);
1770             }
1771         }
1772         Debug.assertLessThan = assertLessThan;
1773         function assertLessThanOrEqual(a, b, stackCrawlMark) {
1774             if (a > b) {
1775                 fail("Expected " + a + " <= " + b, stackCrawlMark || assertLessThanOrEqual);
1776             }
1777         }
1778         Debug.assertLessThanOrEqual = assertLessThanOrEqual;
1779         function assertGreaterThanOrEqual(a, b, stackCrawlMark) {
1780             if (a < b) {
1781                 fail("Expected " + a + " >= " + b, stackCrawlMark || assertGreaterThanOrEqual);
1782             }
1783         }
1784         Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual;
1785         function assertIsDefined(value, message, stackCrawlMark) {
1786             if (value === undefined || value === null) {
1787                 fail(message, stackCrawlMark || assertIsDefined);
1788             }
1789         }
1790         Debug.assertIsDefined = assertIsDefined;
1791         function checkDefined(value, message, stackCrawlMark) {
1792             assertIsDefined(value, message, stackCrawlMark || checkDefined);
1793             return value;
1794         }
1795         Debug.checkDefined = checkDefined;
1796         Debug.assertDefined = checkDefined;
1797         function assertEachIsDefined(value, message, stackCrawlMark) {
1798             for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
1799                 var v = value_1[_i];
1800                 assertIsDefined(v, message, stackCrawlMark || assertEachIsDefined);
1801             }
1802         }
1803         Debug.assertEachIsDefined = assertEachIsDefined;
1804         function checkEachDefined(value, message, stackCrawlMark) {
1805             assertEachIsDefined(value, message, stackCrawlMark || checkEachDefined);
1806             return value;
1807         }
1808         Debug.checkEachDefined = checkEachDefined;
1809         Debug.assertEachDefined = checkEachDefined;
1810         function assertNever(member, message, stackCrawlMark) {
1811             if (message === void 0) { message = "Illegal value:"; }
1812             var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
1813             return fail(message + " " + detail, stackCrawlMark || assertNever);
1814         }
1815         Debug.assertNever = assertNever;
1816         function assertEachNode(nodes, test, message, stackCrawlMark) {
1817             if (shouldAssertFunction(1, "assertEachNode")) {
1818                 assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertEachNode);
1819             }
1820         }
1821         Debug.assertEachNode = assertEachNode;
1822         function assertNode(node, test, message, stackCrawlMark) {
1823             if (shouldAssertFunction(1, "assertNode")) {
1824                 assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNode);
1825             }
1826         }
1827         Debug.assertNode = assertNode;
1828         function assertNotNode(node, test, message, stackCrawlMark) {
1829             if (shouldAssertFunction(1, "assertNotNode")) {
1830                 assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNotNode);
1831             }
1832         }
1833         Debug.assertNotNode = assertNotNode;
1834         function assertOptionalNode(node, test, message, stackCrawlMark) {
1835             if (shouldAssertFunction(1, "assertOptionalNode")) {
1836                 assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertOptionalNode);
1837             }
1838         }
1839         Debug.assertOptionalNode = assertOptionalNode;
1840         function assertOptionalToken(node, kind, message, stackCrawlMark) {
1841             if (shouldAssertFunction(1, "assertOptionalToken")) {
1842                 assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was not a '" + formatSyntaxKind(kind) + "' token."; }, stackCrawlMark || assertOptionalToken);
1843             }
1844         }
1845         Debug.assertOptionalToken = assertOptionalToken;
1846         function assertMissingNode(node, message, stackCrawlMark) {
1847             if (shouldAssertFunction(1, "assertMissingNode")) {
1848                 assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, stackCrawlMark || assertMissingNode);
1849             }
1850         }
1851         Debug.assertMissingNode = assertMissingNode;
1852         function getFunctionName(func) {
1853             if (typeof func !== "function") {
1854                 return "";
1855             }
1856             else if (func.hasOwnProperty("name")) {
1857                 return func.name;
1858             }
1859             else {
1860                 var text = Function.prototype.toString.call(func);
1861                 var match = /^function\s+([\w\$]+)\s*\(/.exec(text);
1862                 return match ? match[1] : "";
1863             }
1864         }
1865         Debug.getFunctionName = getFunctionName;
1866         function formatSymbol(symbol) {
1867             return "{ name: " + ts.unescapeLeadingUnderscores(symbol.escapedName) + "; flags: " + formatSymbolFlags(symbol.flags) + "; declarations: " + ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }) + " }";
1868         }
1869         Debug.formatSymbol = formatSymbol;
1870         function formatEnum(value, enumObject, isFlags) {
1871             if (value === void 0) { value = 0; }
1872             var members = getEnumMembers(enumObject);
1873             if (value === 0) {
1874                 return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
1875             }
1876             if (isFlags) {
1877                 var result = "";
1878                 var remainingFlags = value;
1879                 for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
1880                     var _a = members_1[_i], enumValue = _a[0], enumName = _a[1];
1881                     if (enumValue > value) {
1882                         break;
1883                     }
1884                     if (enumValue !== 0 && enumValue & value) {
1885                         result = "" + result + (result ? "|" : "") + enumName;
1886                         remainingFlags &= ~enumValue;
1887                     }
1888                 }
1889                 if (remainingFlags === 0) {
1890                     return result;
1891                 }
1892             }
1893             else {
1894                 for (var _b = 0, members_2 = members; _b < members_2.length; _b++) {
1895                     var _c = members_2[_b], enumValue = _c[0], enumName = _c[1];
1896                     if (enumValue === value) {
1897                         return enumName;
1898                     }
1899                 }
1900             }
1901             return value.toString();
1902         }
1903         Debug.formatEnum = formatEnum;
1904         function getEnumMembers(enumObject) {
1905             var result = [];
1906             for (var name in enumObject) {
1907                 var value = enumObject[name];
1908                 if (typeof value === "number") {
1909                     result.push([value, name]);
1910                 }
1911             }
1912             return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
1913         }
1914         function formatSyntaxKind(kind) {
1915             return formatEnum(kind, ts.SyntaxKind, false);
1916         }
1917         Debug.formatSyntaxKind = formatSyntaxKind;
1918         function formatNodeFlags(flags) {
1919             return formatEnum(flags, ts.NodeFlags, true);
1920         }
1921         Debug.formatNodeFlags = formatNodeFlags;
1922         function formatModifierFlags(flags) {
1923             return formatEnum(flags, ts.ModifierFlags, true);
1924         }
1925         Debug.formatModifierFlags = formatModifierFlags;
1926         function formatTransformFlags(flags) {
1927             return formatEnum(flags, ts.TransformFlags, true);
1928         }
1929         Debug.formatTransformFlags = formatTransformFlags;
1930         function formatEmitFlags(flags) {
1931             return formatEnum(flags, ts.EmitFlags, true);
1932         }
1933         Debug.formatEmitFlags = formatEmitFlags;
1934         function formatSymbolFlags(flags) {
1935             return formatEnum(flags, ts.SymbolFlags, true);
1936         }
1937         Debug.formatSymbolFlags = formatSymbolFlags;
1938         function formatTypeFlags(flags) {
1939             return formatEnum(flags, ts.TypeFlags, true);
1940         }
1941         Debug.formatTypeFlags = formatTypeFlags;
1942         function formatObjectFlags(flags) {
1943             return formatEnum(flags, ts.ObjectFlags, true);
1944         }
1945         Debug.formatObjectFlags = formatObjectFlags;
1946         var isDebugInfoEnabled = false;
1947         var extendedDebugModule;
1948         function extendedDebug() {
1949             enableDebugInfo();
1950             if (!extendedDebugModule) {
1951                 throw new Error("Debugging helpers could not be loaded.");
1952             }
1953             return extendedDebugModule;
1954         }
1955         function printControlFlowGraph(flowNode) {
1956             return console.log(formatControlFlowGraph(flowNode));
1957         }
1958         Debug.printControlFlowGraph = printControlFlowGraph;
1959         function formatControlFlowGraph(flowNode) {
1960             return extendedDebug().formatControlFlowGraph(flowNode);
1961         }
1962         Debug.formatControlFlowGraph = formatControlFlowGraph;
1963         function attachFlowNodeDebugInfo(flowNode) {
1964             if (isDebugInfoEnabled) {
1965                 if (!("__debugFlowFlags" in flowNode)) {
1966                     Object.defineProperties(flowNode, {
1967                         __debugFlowFlags: { get: function () { return formatEnum(this.flags, ts.FlowFlags, true); } },
1968                         __debugToString: { value: function () { return formatControlFlowGraph(this); } }
1969                     });
1970                 }
1971             }
1972         }
1973         Debug.attachFlowNodeDebugInfo = attachFlowNodeDebugInfo;
1974         function enableDebugInfo() {
1975             if (isDebugInfoEnabled)
1976                 return;
1977             Object.defineProperties(ts.objectAllocator.getSymbolConstructor().prototype, {
1978                 __debugFlags: { get: function () { return formatSymbolFlags(this.flags); } }
1979             });
1980             Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, {
1981                 __debugFlags: { get: function () { return formatTypeFlags(this.flags); } },
1982                 __debugObjectFlags: { get: function () { return this.flags & 524288 ? formatObjectFlags(this.objectFlags) : ""; } },
1983                 __debugTypeToString: { value: function () { return this.checker.typeToString(this); } },
1984             });
1985             var nodeConstructors = [
1986                 ts.objectAllocator.getNodeConstructor(),
1987                 ts.objectAllocator.getIdentifierConstructor(),
1988                 ts.objectAllocator.getTokenConstructor(),
1989                 ts.objectAllocator.getSourceFileConstructor()
1990             ];
1991             for (var _i = 0, nodeConstructors_1 = nodeConstructors; _i < nodeConstructors_1.length; _i++) {
1992                 var ctor = nodeConstructors_1[_i];
1993                 if (!ctor.prototype.hasOwnProperty("__debugKind")) {
1994                     Object.defineProperties(ctor.prototype, {
1995                         __debugKind: { get: function () { return formatSyntaxKind(this.kind); } },
1996                         __debugNodeFlags: { get: function () { return formatNodeFlags(this.flags); } },
1997                         __debugModifierFlags: { get: function () { return formatModifierFlags(ts.getModifierFlagsNoCache(this)); } },
1998                         __debugTransformFlags: { get: function () { return formatTransformFlags(this.transformFlags); } },
1999                         __debugIsParseTreeNode: { get: function () { return ts.isParseTreeNode(this); } },
2000                         __debugEmitFlags: { get: function () { return formatEmitFlags(ts.getEmitFlags(this)); } },
2001                         __debugGetText: {
2002                             value: function (includeTrivia) {
2003                                 if (ts.nodeIsSynthesized(this))
2004                                     return "";
2005                                 var parseNode = ts.getParseTreeNode(this);
2006                                 var sourceFile = parseNode && ts.getSourceFileOfNode(parseNode);
2007                                 return sourceFile ? ts.getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : "";
2008                             }
2009                         }
2010                     });
2011                 }
2012             }
2013             try {
2014                 if (ts.sys && ts.sys.require) {
2015                     var basePath = ts.getDirectoryPath(ts.resolvePath(ts.sys.getExecutingFilePath()));
2016                     var result = ts.sys.require(basePath, "./compiler-debug");
2017                     if (!result.error) {
2018                         result.module.init(ts);
2019                         extendedDebugModule = result.module;
2020                     }
2021                 }
2022             }
2023             catch (_a) {
2024             }
2025             isDebugInfoEnabled = true;
2026         }
2027         Debug.enableDebugInfo = enableDebugInfo;
2028     })(Debug = ts.Debug || (ts.Debug = {}));
2029 })(ts || (ts = {}));
2030 var ts;
2031 (function (ts) {
2032     ts.timestamp = typeof performance !== "undefined" && performance.now ? function () { return performance.now(); } : Date.now ? Date.now : function () { return +(new Date()); };
2033 })(ts || (ts = {}));
2034 var ts;
2035 (function (ts) {
2036     var performance;
2037     (function (performance) {
2038         var profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true ? onProfilerEvent : function () { };
2039         var enabled = false;
2040         var profilerStart = 0;
2041         var counts;
2042         var marks;
2043         var measures;
2044         function createTimerIf(condition, measureName, startMarkName, endMarkName) {
2045             return condition ? createTimer(measureName, startMarkName, endMarkName) : performance.nullTimer;
2046         }
2047         performance.createTimerIf = createTimerIf;
2048         function createTimer(measureName, startMarkName, endMarkName) {
2049             var enterCount = 0;
2050             return {
2051                 enter: enter,
2052                 exit: exit
2053             };
2054             function enter() {
2055                 if (++enterCount === 1) {
2056                     mark(startMarkName);
2057                 }
2058             }
2059             function exit() {
2060                 if (--enterCount === 0) {
2061                     mark(endMarkName);
2062                     measure(measureName, startMarkName, endMarkName);
2063                 }
2064                 else if (enterCount < 0) {
2065                     ts.Debug.fail("enter/exit count does not match.");
2066                 }
2067             }
2068         }
2069         performance.createTimer = createTimer;
2070         performance.nullTimer = { enter: ts.noop, exit: ts.noop };
2071         function mark(markName) {
2072             if (enabled) {
2073                 marks.set(markName, ts.timestamp());
2074                 counts.set(markName, (counts.get(markName) || 0) + 1);
2075                 profilerEvent(markName);
2076             }
2077         }
2078         performance.mark = mark;
2079         function measure(measureName, startMarkName, endMarkName) {
2080             if (enabled) {
2081                 var end = endMarkName && marks.get(endMarkName) || ts.timestamp();
2082                 var start = startMarkName && marks.get(startMarkName) || profilerStart;
2083                 measures.set(measureName, (measures.get(measureName) || 0) + (end - start));
2084             }
2085         }
2086         performance.measure = measure;
2087         function getCount(markName) {
2088             return counts && counts.get(markName) || 0;
2089         }
2090         performance.getCount = getCount;
2091         function getDuration(measureName) {
2092             return measures && measures.get(measureName) || 0;
2093         }
2094         performance.getDuration = getDuration;
2095         function forEachMeasure(cb) {
2096             measures.forEach(function (measure, key) {
2097                 cb(key, measure);
2098             });
2099         }
2100         performance.forEachMeasure = forEachMeasure;
2101         function enable() {
2102             counts = ts.createMap();
2103             marks = ts.createMap();
2104             measures = ts.createMap();
2105             enabled = true;
2106             profilerStart = ts.timestamp();
2107         }
2108         performance.enable = enable;
2109         function disable() {
2110             enabled = false;
2111         }
2112         performance.disable = disable;
2113     })(performance = ts.performance || (ts.performance = {}));
2114 })(ts || (ts = {}));
2115 var ts;
2116 (function (ts) {
2117     var _a;
2118     var nullLogger = {
2119         logEvent: ts.noop,
2120         logErrEvent: ts.noop,
2121         logPerfEvent: ts.noop,
2122         logInfoEvent: ts.noop,
2123         logStartCommand: ts.noop,
2124         logStopCommand: ts.noop,
2125         logStartUpdateProgram: ts.noop,
2126         logStopUpdateProgram: ts.noop,
2127         logStartUpdateGraph: ts.noop,
2128         logStopUpdateGraph: ts.noop,
2129         logStartResolveModule: ts.noop,
2130         logStopResolveModule: ts.noop,
2131         logStartParseSourceFile: ts.noop,
2132         logStopParseSourceFile: ts.noop,
2133         logStartReadFile: ts.noop,
2134         logStopReadFile: ts.noop,
2135         logStartBindFile: ts.noop,
2136         logStopBindFile: ts.noop,
2137         logStartScheduledOperation: ts.noop,
2138         logStopScheduledOperation: ts.noop,
2139     };
2140     var etwModule;
2141     try {
2142         var etwModulePath = (_a = process.env.TS_ETW_MODULE_PATH) !== null && _a !== void 0 ? _a : "./node_modules/@microsoft/typescript-etw";
2143         etwModule = require(etwModulePath);
2144     }
2145     catch (e) {
2146         etwModule = undefined;
2147     }
2148     ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger;
2149 })(ts || (ts = {}));
2150 var ts;
2151 (function (ts) {
2152     var versionRegExp = /^(0|[1-9]\d*)(?:\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*)(?:\-([a-z0-9-.]+))?(?:\+([a-z0-9-.]+))?)?)?$/i;
2153     var prereleaseRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)(?:\.(?:0|[1-9]\d*|[a-z-][a-z0-9-]*))*$/i;
2154     var buildRegExp = /^[a-z0-9-]+(?:\.[a-z0-9-]+)*$/i;
2155     var numericIdentifierRegExp = /^(0|[1-9]\d*)$/;
2156     var Version = (function () {
2157         function Version(major, minor, patch, prerelease, build) {
2158             if (minor === void 0) { minor = 0; }
2159             if (patch === void 0) { patch = 0; }
2160             if (prerelease === void 0) { prerelease = ""; }
2161             if (build === void 0) { build = ""; }
2162             if (typeof major === "string") {
2163                 var result = ts.Debug.checkDefined(tryParseComponents(major), "Invalid version");
2164                 (major = result.major, minor = result.minor, patch = result.patch, prerelease = result.prerelease, build = result.build);
2165             }
2166             ts.Debug.assert(major >= 0, "Invalid argument: major");
2167             ts.Debug.assert(minor >= 0, "Invalid argument: minor");
2168             ts.Debug.assert(patch >= 0, "Invalid argument: patch");
2169             ts.Debug.assert(!prerelease || prereleaseRegExp.test(prerelease), "Invalid argument: prerelease");
2170             ts.Debug.assert(!build || buildRegExp.test(build), "Invalid argument: build");
2171             this.major = major;
2172             this.minor = minor;
2173             this.patch = patch;
2174             this.prerelease = prerelease ? prerelease.split(".") : ts.emptyArray;
2175             this.build = build ? build.split(".") : ts.emptyArray;
2176         }
2177         Version.tryParse = function (text) {
2178             var result = tryParseComponents(text);
2179             if (!result)
2180                 return undefined;
2181             var major = result.major, minor = result.minor, patch = result.patch, prerelease = result.prerelease, build = result.build;
2182             return new Version(major, minor, patch, prerelease, build);
2183         };
2184         Version.prototype.compareTo = function (other) {
2185             if (this === other)
2186                 return 0;
2187             if (other === undefined)
2188                 return 1;
2189             return ts.compareValues(this.major, other.major)
2190                 || ts.compareValues(this.minor, other.minor)
2191                 || ts.compareValues(this.patch, other.patch)
2192                 || comparePrerelaseIdentifiers(this.prerelease, other.prerelease);
2193         };
2194         Version.prototype.increment = function (field) {
2195             switch (field) {
2196                 case "major": return new Version(this.major + 1, 0, 0);
2197                 case "minor": return new Version(this.major, this.minor + 1, 0);
2198                 case "patch": return new Version(this.major, this.minor, this.patch + 1);
2199                 default: return ts.Debug.assertNever(field);
2200             }
2201         };
2202         Version.prototype.toString = function () {
2203             var result = this.major + "." + this.minor + "." + this.patch;
2204             if (ts.some(this.prerelease))
2205                 result += "-" + this.prerelease.join(".");
2206             if (ts.some(this.build))
2207                 result += "+" + this.build.join(".");
2208             return result;
2209         };
2210         Version.zero = new Version(0, 0, 0);
2211         return Version;
2212     }());
2213     ts.Version = Version;
2214     function tryParseComponents(text) {
2215         var match = versionRegExp.exec(text);
2216         if (!match)
2217             return undefined;
2218         var major = match[1], _a = match[2], minor = _a === void 0 ? "0" : _a, _b = match[3], patch = _b === void 0 ? "0" : _b, _c = match[4], prerelease = _c === void 0 ? "" : _c, _d = match[5], build = _d === void 0 ? "" : _d;
2219         if (prerelease && !prereleaseRegExp.test(prerelease))
2220             return undefined;
2221         if (build && !buildRegExp.test(build))
2222             return undefined;
2223         return {
2224             major: parseInt(major, 10),
2225             minor: parseInt(minor, 10),
2226             patch: parseInt(patch, 10),
2227             prerelease: prerelease,
2228             build: build
2229         };
2230     }
2231     function comparePrerelaseIdentifiers(left, right) {
2232         if (left === right)
2233             return 0;
2234         if (left.length === 0)
2235             return right.length === 0 ? 0 : 1;
2236         if (right.length === 0)
2237             return -1;
2238         var length = Math.min(left.length, right.length);
2239         for (var i = 0; i < length; i++) {
2240             var leftIdentifier = left[i];
2241             var rightIdentifier = right[i];
2242             if (leftIdentifier === rightIdentifier)
2243                 continue;
2244             var leftIsNumeric = numericIdentifierRegExp.test(leftIdentifier);
2245             var rightIsNumeric = numericIdentifierRegExp.test(rightIdentifier);
2246             if (leftIsNumeric || rightIsNumeric) {
2247                 if (leftIsNumeric !== rightIsNumeric)
2248                     return leftIsNumeric ? -1 : 1;
2249                 var result = ts.compareValues(+leftIdentifier, +rightIdentifier);
2250                 if (result)
2251                     return result;
2252             }
2253             else {
2254                 var result = ts.compareStringsCaseSensitive(leftIdentifier, rightIdentifier);
2255                 if (result)
2256                     return result;
2257             }
2258         }
2259         return ts.compareValues(left.length, right.length);
2260     }
2261     var VersionRange = (function () {
2262         function VersionRange(spec) {
2263             this._alternatives = spec ? ts.Debug.checkDefined(parseRange(spec), "Invalid range spec.") : ts.emptyArray;
2264         }
2265         VersionRange.tryParse = function (text) {
2266             var sets = parseRange(text);
2267             if (sets) {
2268                 var range = new VersionRange("");
2269                 range._alternatives = sets;
2270                 return range;
2271             }
2272             return undefined;
2273         };
2274         VersionRange.prototype.test = function (version) {
2275             if (typeof version === "string")
2276                 version = new Version(version);
2277             return testDisjunction(version, this._alternatives);
2278         };
2279         VersionRange.prototype.toString = function () {
2280             return formatDisjunction(this._alternatives);
2281         };
2282         return VersionRange;
2283     }());
2284     ts.VersionRange = VersionRange;
2285     var logicalOrRegExp = /\s*\|\|\s*/g;
2286     var whitespaceRegExp = /\s+/g;
2287     var partialRegExp = /^([xX*0]|[1-9]\d*)(?:\.([xX*0]|[1-9]\d*)(?:\.([xX*0]|[1-9]\d*)(?:-([a-z0-9-.]+))?(?:\+([a-z0-9-.]+))?)?)?$/i;
2288     var hyphenRegExp = /^\s*([a-z0-9-+.*]+)\s+-\s+([a-z0-9-+.*]+)\s*$/i;
2289     var rangeRegExp = /^\s*(~|\^|<|<=|>|>=|=)?\s*([a-z0-9-+.*]+)$/i;
2290     function parseRange(text) {
2291         var alternatives = [];
2292         for (var _i = 0, _a = text.trim().split(logicalOrRegExp); _i < _a.length; _i++) {
2293             var range = _a[_i];
2294             if (!range)
2295                 continue;
2296             var comparators = [];
2297             var match = hyphenRegExp.exec(range);
2298             if (match) {
2299                 if (!parseHyphen(match[1], match[2], comparators))
2300                     return undefined;
2301             }
2302             else {
2303                 for (var _b = 0, _c = range.split(whitespaceRegExp); _b < _c.length; _b++) {
2304                     var simple = _c[_b];
2305                     var match_1 = rangeRegExp.exec(simple);
2306                     if (!match_1 || !parseComparator(match_1[1], match_1[2], comparators))
2307                         return undefined;
2308                 }
2309             }
2310             alternatives.push(comparators);
2311         }
2312         return alternatives;
2313     }
2314     function parsePartial(text) {
2315         var match = partialRegExp.exec(text);
2316         if (!match)
2317             return undefined;
2318         var major = match[1], _a = match[2], minor = _a === void 0 ? "*" : _a, _b = match[3], patch = _b === void 0 ? "*" : _b, prerelease = match[4], build = match[5];
2319         var version = new Version(isWildcard(major) ? 0 : parseInt(major, 10), isWildcard(major) || isWildcard(minor) ? 0 : parseInt(minor, 10), isWildcard(major) || isWildcard(minor) || isWildcard(patch) ? 0 : parseInt(patch, 10), prerelease, build);
2320         return { version: version, major: major, minor: minor, patch: patch };
2321     }
2322     function parseHyphen(left, right, comparators) {
2323         var leftResult = parsePartial(left);
2324         if (!leftResult)
2325             return false;
2326         var rightResult = parsePartial(right);
2327         if (!rightResult)
2328             return false;
2329         if (!isWildcard(leftResult.major)) {
2330             comparators.push(createComparator(">=", leftResult.version));
2331         }
2332         if (!isWildcard(rightResult.major)) {
2333             comparators.push(isWildcard(rightResult.minor) ? createComparator("<", rightResult.version.increment("major")) :
2334                 isWildcard(rightResult.patch) ? createComparator("<", rightResult.version.increment("minor")) :
2335                     createComparator("<=", rightResult.version));
2336         }
2337         return true;
2338     }
2339     function parseComparator(operator, text, comparators) {
2340         var result = parsePartial(text);
2341         if (!result)
2342             return false;
2343         var version = result.version, major = result.major, minor = result.minor, patch = result.patch;
2344         if (!isWildcard(major)) {
2345             switch (operator) {
2346                 case "~":
2347                     comparators.push(createComparator(">=", version));
2348                     comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" :
2349                         "minor")));
2350                     break;
2351                 case "^":
2352                     comparators.push(createComparator(">=", version));
2353                     comparators.push(createComparator("<", version.increment(version.major > 0 || isWildcard(minor) ? "major" :
2354                         version.minor > 0 || isWildcard(patch) ? "minor" :
2355                             "patch")));
2356                     break;
2357                 case "<":
2358                 case ">=":
2359                     comparators.push(createComparator(operator, version));
2360                     break;
2361                 case "<=":
2362                 case ">":
2363                     comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major")) :
2364                         isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor")) :
2365                             createComparator(operator, version));
2366                     break;
2367                 case "=":
2368                 case undefined:
2369                     if (isWildcard(minor) || isWildcard(patch)) {
2370                         comparators.push(createComparator(">=", version));
2371                         comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor")));
2372                     }
2373                     else {
2374                         comparators.push(createComparator("=", version));
2375                     }
2376                     break;
2377                 default:
2378                     return false;
2379             }
2380         }
2381         else if (operator === "<" || operator === ">") {
2382             comparators.push(createComparator("<", Version.zero));
2383         }
2384         return true;
2385     }
2386     function isWildcard(part) {
2387         return part === "*" || part === "x" || part === "X";
2388     }
2389     function createComparator(operator, operand) {
2390         return { operator: operator, operand: operand };
2391     }
2392     function testDisjunction(version, alternatives) {
2393         if (alternatives.length === 0)
2394             return true;
2395         for (var _i = 0, alternatives_1 = alternatives; _i < alternatives_1.length; _i++) {
2396             var alternative = alternatives_1[_i];
2397             if (testAlternative(version, alternative))
2398                 return true;
2399         }
2400         return false;
2401     }
2402     function testAlternative(version, comparators) {
2403         for (var _i = 0, comparators_1 = comparators; _i < comparators_1.length; _i++) {
2404             var comparator = comparators_1[_i];
2405             if (!testComparator(version, comparator.operator, comparator.operand))
2406                 return false;
2407         }
2408         return true;
2409     }
2410     function testComparator(version, operator, operand) {
2411         var cmp = version.compareTo(operand);
2412         switch (operator) {
2413             case "<": return cmp < 0;
2414             case "<=": return cmp <= 0;
2415             case ">": return cmp > 0;
2416             case ">=": return cmp >= 0;
2417             case "=": return cmp === 0;
2418             default: return ts.Debug.assertNever(operator);
2419         }
2420     }
2421     function formatDisjunction(alternatives) {
2422         return ts.map(alternatives, formatAlternative).join(" || ") || "*";
2423     }
2424     function formatAlternative(comparators) {
2425         return ts.map(comparators, formatComparator).join(" ");
2426     }
2427     function formatComparator(comparator) {
2428         return "" + comparator.operator + comparator.operand;
2429     }
2430 })(ts || (ts = {}));
2431 var ts;
2432 (function (ts) {
2433     var OperationCanceledException = (function () {
2434         function OperationCanceledException() {
2435         }
2436         return OperationCanceledException;
2437     }());
2438     ts.OperationCanceledException = OperationCanceledException;
2439     var RefFileKind;
2440     (function (RefFileKind) {
2441         RefFileKind[RefFileKind["Import"] = 0] = "Import";
2442         RefFileKind[RefFileKind["ReferenceFile"] = 1] = "ReferenceFile";
2443         RefFileKind[RefFileKind["TypeReferenceDirective"] = 2] = "TypeReferenceDirective";
2444     })(RefFileKind = ts.RefFileKind || (ts.RefFileKind = {}));
2445     var ExitStatus;
2446     (function (ExitStatus) {
2447         ExitStatus[ExitStatus["Success"] = 0] = "Success";
2448         ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped";
2449         ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated";
2450         ExitStatus[ExitStatus["InvalidProject_OutputsSkipped"] = 3] = "InvalidProject_OutputsSkipped";
2451         ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkipped"] = 4] = "ProjectReferenceCycle_OutputsSkipped";
2452         ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped";
2453     })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {}));
2454     var TypeReferenceSerializationKind;
2455     (function (TypeReferenceSerializationKind) {
2456         TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown";
2457         TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue";
2458         TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType";
2459         TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType";
2460         TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType";
2461         TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType";
2462         TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType";
2463         TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType";
2464         TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType";
2465         TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise";
2466         TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature";
2467         TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType";
2468     })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {}));
2469     var DiagnosticCategory;
2470     (function (DiagnosticCategory) {
2471         DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning";
2472         DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error";
2473         DiagnosticCategory[DiagnosticCategory["Suggestion"] = 2] = "Suggestion";
2474         DiagnosticCategory[DiagnosticCategory["Message"] = 3] = "Message";
2475     })(DiagnosticCategory = ts.DiagnosticCategory || (ts.DiagnosticCategory = {}));
2476     function diagnosticCategoryName(d, lowerCase) {
2477         if (lowerCase === void 0) { lowerCase = true; }
2478         var name = DiagnosticCategory[d.category];
2479         return lowerCase ? name.toLowerCase() : name;
2480     }
2481     ts.diagnosticCategoryName = diagnosticCategoryName;
2482     var ModuleResolutionKind;
2483     (function (ModuleResolutionKind) {
2484         ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic";
2485         ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs";
2486     })(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {}));
2487     var WatchFileKind;
2488     (function (WatchFileKind) {
2489         WatchFileKind[WatchFileKind["FixedPollingInterval"] = 0] = "FixedPollingInterval";
2490         WatchFileKind[WatchFileKind["PriorityPollingInterval"] = 1] = "PriorityPollingInterval";
2491         WatchFileKind[WatchFileKind["DynamicPriorityPolling"] = 2] = "DynamicPriorityPolling";
2492         WatchFileKind[WatchFileKind["UseFsEvents"] = 3] = "UseFsEvents";
2493         WatchFileKind[WatchFileKind["UseFsEventsOnParentDirectory"] = 4] = "UseFsEventsOnParentDirectory";
2494     })(WatchFileKind = ts.WatchFileKind || (ts.WatchFileKind = {}));
2495     var WatchDirectoryKind;
2496     (function (WatchDirectoryKind) {
2497         WatchDirectoryKind[WatchDirectoryKind["UseFsEvents"] = 0] = "UseFsEvents";
2498         WatchDirectoryKind[WatchDirectoryKind["FixedPollingInterval"] = 1] = "FixedPollingInterval";
2499         WatchDirectoryKind[WatchDirectoryKind["DynamicPriorityPolling"] = 2] = "DynamicPriorityPolling";
2500     })(WatchDirectoryKind = ts.WatchDirectoryKind || (ts.WatchDirectoryKind = {}));
2501     var PollingWatchKind;
2502     (function (PollingWatchKind) {
2503         PollingWatchKind[PollingWatchKind["FixedInterval"] = 0] = "FixedInterval";
2504         PollingWatchKind[PollingWatchKind["PriorityInterval"] = 1] = "PriorityInterval";
2505         PollingWatchKind[PollingWatchKind["DynamicPriority"] = 2] = "DynamicPriority";
2506     })(PollingWatchKind = ts.PollingWatchKind || (ts.PollingWatchKind = {}));
2507     var ModuleKind;
2508     (function (ModuleKind) {
2509         ModuleKind[ModuleKind["None"] = 0] = "None";
2510         ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS";
2511         ModuleKind[ModuleKind["AMD"] = 2] = "AMD";
2512         ModuleKind[ModuleKind["UMD"] = 3] = "UMD";
2513         ModuleKind[ModuleKind["System"] = 4] = "System";
2514         ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015";
2515         ModuleKind[ModuleKind["ES2020"] = 6] = "ES2020";
2516         ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext";
2517     })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {}));
2518     ts.commentPragmas = {
2519         "reference": {
2520             args: [
2521                 { name: "types", optional: true, captureSpan: true },
2522                 { name: "lib", optional: true, captureSpan: true },
2523                 { name: "path", optional: true, captureSpan: true },
2524                 { name: "no-default-lib", optional: true }
2525             ],
2526             kind: 1
2527         },
2528         "amd-dependency": {
2529             args: [{ name: "path" }, { name: "name", optional: true }],
2530             kind: 1
2531         },
2532         "amd-module": {
2533             args: [{ name: "name" }],
2534             kind: 1
2535         },
2536         "ts-check": {
2537             kind: 2
2538         },
2539         "ts-nocheck": {
2540             kind: 2
2541         },
2542         "jsx": {
2543             args: [{ name: "factory" }],
2544             kind: 4
2545         },
2546     };
2547 })(ts || (ts = {}));
2548 var ts;
2549 (function (ts) {
2550     function generateDjb2Hash(data) {
2551         var acc = 5381;
2552         for (var i = 0; i < data.length; i++) {
2553             acc = ((acc << 5) + acc) + data.charCodeAt(i);
2554         }
2555         return acc.toString();
2556     }
2557     ts.generateDjb2Hash = generateDjb2Hash;
2558     function setStackTraceLimit() {
2559         if (Error.stackTraceLimit < 100) {
2560             Error.stackTraceLimit = 100;
2561         }
2562     }
2563     ts.setStackTraceLimit = setStackTraceLimit;
2564     var FileWatcherEventKind;
2565     (function (FileWatcherEventKind) {
2566         FileWatcherEventKind[FileWatcherEventKind["Created"] = 0] = "Created";
2567         FileWatcherEventKind[FileWatcherEventKind["Changed"] = 1] = "Changed";
2568         FileWatcherEventKind[FileWatcherEventKind["Deleted"] = 2] = "Deleted";
2569     })(FileWatcherEventKind = ts.FileWatcherEventKind || (ts.FileWatcherEventKind = {}));
2570     var PollingInterval;
2571     (function (PollingInterval) {
2572         PollingInterval[PollingInterval["High"] = 2000] = "High";
2573         PollingInterval[PollingInterval["Medium"] = 500] = "Medium";
2574         PollingInterval[PollingInterval["Low"] = 250] = "Low";
2575     })(PollingInterval = ts.PollingInterval || (ts.PollingInterval = {}));
2576     ts.missingFileModifiedTime = new Date(0);
2577     function createPollingIntervalBasedLevels(levels) {
2578         var _a;
2579         return _a = {},
2580             _a[PollingInterval.Low] = levels.Low,
2581             _a[PollingInterval.Medium] = levels.Medium,
2582             _a[PollingInterval.High] = levels.High,
2583             _a;
2584     }
2585     var defaultChunkLevels = { Low: 32, Medium: 64, High: 256 };
2586     var pollingChunkSize = createPollingIntervalBasedLevels(defaultChunkLevels);
2587     ts.unchangedPollThresholds = createPollingIntervalBasedLevels(defaultChunkLevels);
2588     function setCustomPollingValues(system) {
2589         if (!system.getEnvironmentVariable) {
2590             return;
2591         }
2592         var pollingIntervalChanged = setCustomLevels("TSC_WATCH_POLLINGINTERVAL", PollingInterval);
2593         pollingChunkSize = getCustomPollingBasedLevels("TSC_WATCH_POLLINGCHUNKSIZE", defaultChunkLevels) || pollingChunkSize;
2594         ts.unchangedPollThresholds = getCustomPollingBasedLevels("TSC_WATCH_UNCHANGEDPOLLTHRESHOLDS", defaultChunkLevels) || ts.unchangedPollThresholds;
2595         function getLevel(envVar, level) {
2596             return system.getEnvironmentVariable(envVar + "_" + level.toUpperCase());
2597         }
2598         function getCustomLevels(baseVariable) {
2599             var customLevels;
2600             setCustomLevel("Low");
2601             setCustomLevel("Medium");
2602             setCustomLevel("High");
2603             return customLevels;
2604             function setCustomLevel(level) {
2605                 var customLevel = getLevel(baseVariable, level);
2606                 if (customLevel) {
2607                     (customLevels || (customLevels = {}))[level] = Number(customLevel);
2608                 }
2609             }
2610         }
2611         function setCustomLevels(baseVariable, levels) {
2612             var customLevels = getCustomLevels(baseVariable);
2613             if (customLevels) {
2614                 setLevel("Low");
2615                 setLevel("Medium");
2616                 setLevel("High");
2617                 return true;
2618             }
2619             return false;
2620             function setLevel(level) {
2621                 levels[level] = customLevels[level] || levels[level];
2622             }
2623         }
2624         function getCustomPollingBasedLevels(baseVariable, defaultLevels) {
2625             var customLevels = getCustomLevels(baseVariable);
2626             return (pollingIntervalChanged || customLevels) &&
2627                 createPollingIntervalBasedLevels(customLevels ? __assign(__assign({}, defaultLevels), customLevels) : defaultLevels);
2628         }
2629     }
2630     ts.setCustomPollingValues = setCustomPollingValues;
2631     function createDynamicPriorityPollingWatchFile(host) {
2632         var watchedFiles = [];
2633         var changedFilesInLastPoll = [];
2634         var lowPollingIntervalQueue = createPollingIntervalQueue(PollingInterval.Low);
2635         var mediumPollingIntervalQueue = createPollingIntervalQueue(PollingInterval.Medium);
2636         var highPollingIntervalQueue = createPollingIntervalQueue(PollingInterval.High);
2637         return watchFile;
2638         function watchFile(fileName, callback, defaultPollingInterval) {
2639             var file = {
2640                 fileName: fileName,
2641                 callback: callback,
2642                 unchangedPolls: 0,
2643                 mtime: getModifiedTime(fileName)
2644             };
2645             watchedFiles.push(file);
2646             addToPollingIntervalQueue(file, defaultPollingInterval);
2647             return {
2648                 close: function () {
2649                     file.isClosed = true;
2650                     ts.unorderedRemoveItem(watchedFiles, file);
2651                 }
2652             };
2653         }
2654         function createPollingIntervalQueue(pollingInterval) {
2655             var queue = [];
2656             queue.pollingInterval = pollingInterval;
2657             queue.pollIndex = 0;
2658             queue.pollScheduled = false;
2659             return queue;
2660         }
2661         function pollPollingIntervalQueue(queue) {
2662             queue.pollIndex = pollQueue(queue, queue.pollingInterval, queue.pollIndex, pollingChunkSize[queue.pollingInterval]);
2663             if (queue.length) {
2664                 scheduleNextPoll(queue.pollingInterval);
2665             }
2666             else {
2667                 ts.Debug.assert(queue.pollIndex === 0);
2668                 queue.pollScheduled = false;
2669             }
2670         }
2671         function pollLowPollingIntervalQueue(queue) {
2672             pollQueue(changedFilesInLastPoll, PollingInterval.Low, 0, changedFilesInLastPoll.length);
2673             pollPollingIntervalQueue(queue);
2674             if (!queue.pollScheduled && changedFilesInLastPoll.length) {
2675                 scheduleNextPoll(PollingInterval.Low);
2676             }
2677         }
2678         function pollQueue(queue, pollingInterval, pollIndex, chunkSize) {
2679             var needsVisit = queue.length;
2680             var definedValueCopyToIndex = pollIndex;
2681             for (var polled = 0; polled < chunkSize && needsVisit > 0; nextPollIndex(), needsVisit--) {
2682                 var watchedFile = queue[pollIndex];
2683                 if (!watchedFile) {
2684                     continue;
2685                 }
2686                 else if (watchedFile.isClosed) {
2687                     queue[pollIndex] = undefined;
2688                     continue;
2689                 }
2690                 polled++;
2691                 var fileChanged = onWatchedFileStat(watchedFile, getModifiedTime(watchedFile.fileName));
2692                 if (watchedFile.isClosed) {
2693                     queue[pollIndex] = undefined;
2694                 }
2695                 else if (fileChanged) {
2696                     watchedFile.unchangedPolls = 0;
2697                     if (queue !== changedFilesInLastPoll) {
2698                         queue[pollIndex] = undefined;
2699                         addChangedFileToLowPollingIntervalQueue(watchedFile);
2700                     }
2701                 }
2702                 else if (watchedFile.unchangedPolls !== ts.unchangedPollThresholds[pollingInterval]) {
2703                     watchedFile.unchangedPolls++;
2704                 }
2705                 else if (queue === changedFilesInLastPoll) {
2706                     watchedFile.unchangedPolls = 1;
2707                     queue[pollIndex] = undefined;
2708                     addToPollingIntervalQueue(watchedFile, PollingInterval.Low);
2709                 }
2710                 else if (pollingInterval !== PollingInterval.High) {
2711                     watchedFile.unchangedPolls++;
2712                     queue[pollIndex] = undefined;
2713                     addToPollingIntervalQueue(watchedFile, pollingInterval === PollingInterval.Low ? PollingInterval.Medium : PollingInterval.High);
2714                 }
2715                 if (queue[pollIndex]) {
2716                     if (definedValueCopyToIndex < pollIndex) {
2717                         queue[definedValueCopyToIndex] = watchedFile;
2718                         queue[pollIndex] = undefined;
2719                     }
2720                     definedValueCopyToIndex++;
2721                 }
2722             }
2723             return pollIndex;
2724             function nextPollIndex() {
2725                 pollIndex++;
2726                 if (pollIndex === queue.length) {
2727                     if (definedValueCopyToIndex < pollIndex) {
2728                         queue.length = definedValueCopyToIndex;
2729                     }
2730                     pollIndex = 0;
2731                     definedValueCopyToIndex = 0;
2732                 }
2733             }
2734         }
2735         function pollingIntervalQueue(pollingInterval) {
2736             switch (pollingInterval) {
2737                 case PollingInterval.Low:
2738                     return lowPollingIntervalQueue;
2739                 case PollingInterval.Medium:
2740                     return mediumPollingIntervalQueue;
2741                 case PollingInterval.High:
2742                     return highPollingIntervalQueue;
2743             }
2744         }
2745         function addToPollingIntervalQueue(file, pollingInterval) {
2746             pollingIntervalQueue(pollingInterval).push(file);
2747             scheduleNextPollIfNotAlreadyScheduled(pollingInterval);
2748         }
2749         function addChangedFileToLowPollingIntervalQueue(file) {
2750             changedFilesInLastPoll.push(file);
2751             scheduleNextPollIfNotAlreadyScheduled(PollingInterval.Low);
2752         }
2753         function scheduleNextPollIfNotAlreadyScheduled(pollingInterval) {
2754             if (!pollingIntervalQueue(pollingInterval).pollScheduled) {
2755                 scheduleNextPoll(pollingInterval);
2756             }
2757         }
2758         function scheduleNextPoll(pollingInterval) {
2759             pollingIntervalQueue(pollingInterval).pollScheduled = host.setTimeout(pollingInterval === PollingInterval.Low ? pollLowPollingIntervalQueue : pollPollingIntervalQueue, pollingInterval, pollingIntervalQueue(pollingInterval));
2760         }
2761         function getModifiedTime(fileName) {
2762             return host.getModifiedTime(fileName) || ts.missingFileModifiedTime;
2763         }
2764     }
2765     ts.createDynamicPriorityPollingWatchFile = createDynamicPriorityPollingWatchFile;
2766     function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames) {
2767         var fileWatcherCallbacks = ts.createMultiMap();
2768         var dirWatchers = ts.createMap();
2769         var toCanonicalName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
2770         return nonPollingWatchFile;
2771         function nonPollingWatchFile(fileName, callback, _pollingInterval, fallbackOptions) {
2772             var filePath = toCanonicalName(fileName);
2773             fileWatcherCallbacks.add(filePath, callback);
2774             var dirPath = ts.getDirectoryPath(filePath) || ".";
2775             var watcher = dirWatchers.get(dirPath) ||
2776                 createDirectoryWatcher(ts.getDirectoryPath(fileName) || ".", dirPath, fallbackOptions);
2777             watcher.referenceCount++;
2778             return {
2779                 close: function () {
2780                     if (watcher.referenceCount === 1) {
2781                         watcher.close();
2782                         dirWatchers.delete(dirPath);
2783                     }
2784                     else {
2785                         watcher.referenceCount--;
2786                     }
2787                     fileWatcherCallbacks.remove(filePath, callback);
2788                 }
2789             };
2790         }
2791         function createDirectoryWatcher(dirName, dirPath, fallbackOptions) {
2792             var watcher = fsWatch(dirName, 1, function (_eventName, relativeFileName) {
2793                 if (!ts.isString(relativeFileName)) {
2794                     return;
2795                 }
2796                 var fileName = ts.getNormalizedAbsolutePath(relativeFileName, dirName);
2797                 var callbacks = fileName && fileWatcherCallbacks.get(toCanonicalName(fileName));
2798                 if (callbacks) {
2799                     for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) {
2800                         var fileCallback = callbacks_1[_i];
2801                         fileCallback(fileName, FileWatcherEventKind.Changed);
2802                     }
2803                 }
2804             }, false, PollingInterval.Medium, fallbackOptions);
2805             watcher.referenceCount = 0;
2806             dirWatchers.set(dirPath, watcher);
2807             return watcher;
2808         }
2809     }
2810     function createSingleFileWatcherPerName(watchFile, useCaseSensitiveFileNames) {
2811         var cache = ts.createMap();
2812         var callbacksCache = ts.createMultiMap();
2813         var toCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
2814         return function (fileName, callback, pollingInterval, options) {
2815             var path = toCanonicalFileName(fileName);
2816             var existing = cache.get(path);
2817             if (existing) {
2818                 existing.refCount++;
2819             }
2820             else {
2821                 cache.set(path, {
2822                     watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval, options),
2823                     refCount: 1
2824                 });
2825             }
2826             callbacksCache.add(path, callback);
2827             return {
2828                 close: function () {
2829                     var watcher = ts.Debug.checkDefined(cache.get(path));
2830                     callbacksCache.remove(path, callback);
2831                     watcher.refCount--;
2832                     if (watcher.refCount)
2833                         return;
2834                     cache.delete(path);
2835                     ts.closeFileWatcherOf(watcher);
2836                 }
2837             };
2838         };
2839     }
2840     ts.createSingleFileWatcherPerName = createSingleFileWatcherPerName;
2841     function onWatchedFileStat(watchedFile, modifiedTime) {
2842         var oldTime = watchedFile.mtime.getTime();
2843         var newTime = modifiedTime.getTime();
2844         if (oldTime !== newTime) {
2845             watchedFile.mtime = modifiedTime;
2846             watchedFile.callback(watchedFile.fileName, getFileWatcherEventKind(oldTime, newTime));
2847             return true;
2848         }
2849         return false;
2850     }
2851     ts.onWatchedFileStat = onWatchedFileStat;
2852     function getFileWatcherEventKind(oldTime, newTime) {
2853         return oldTime === 0
2854             ? FileWatcherEventKind.Created
2855             : newTime === 0
2856                 ? FileWatcherEventKind.Deleted
2857                 : FileWatcherEventKind.Changed;
2858     }
2859     ts.getFileWatcherEventKind = getFileWatcherEventKind;
2860     ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"];
2861     ts.sysLog = ts.noop;
2862     function setSysLog(logger) {
2863         ts.sysLog = logger;
2864     }
2865     ts.setSysLog = setSysLog;
2866     function createDirectoryWatcherSupportingRecursive(host) {
2867         var cache = ts.createMap();
2868         var callbackCache = ts.createMultiMap();
2869         var cacheToUpdateChildWatches = ts.createMap();
2870         var timerToUpdateChildWatches;
2871         var filePathComparer = ts.getStringComparer(!host.useCaseSensitiveFileNames);
2872         var toCanonicalFilePath = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames);
2873         return function (dirName, callback, recursive, options) { return recursive ?
2874             createDirectoryWatcher(dirName, options, callback) :
2875             host.watchDirectory(dirName, callback, recursive, options); };
2876         function createDirectoryWatcher(dirName, options, callback) {
2877             var dirPath = toCanonicalFilePath(dirName);
2878             var directoryWatcher = cache.get(dirPath);
2879             if (directoryWatcher) {
2880                 directoryWatcher.refCount++;
2881             }
2882             else {
2883                 directoryWatcher = {
2884                     watcher: host.watchDirectory(dirName, function (fileName) {
2885                         if (isIgnoredPath(fileName))
2886                             return;
2887                         if (options === null || options === void 0 ? void 0 : options.synchronousWatchDirectory) {
2888                             invokeCallbacks(dirPath, fileName);
2889                             updateChildWatches(dirName, dirPath, options);
2890                         }
2891                         else {
2892                             nonSyncUpdateChildWatches(dirName, dirPath, fileName, options);
2893                         }
2894                     }, false, options),
2895                     refCount: 1,
2896                     childWatches: ts.emptyArray
2897                 };
2898                 cache.set(dirPath, directoryWatcher);
2899                 updateChildWatches(dirName, dirPath, options);
2900             }
2901             var callbackToAdd = callback && { dirName: dirName, callback: callback };
2902             if (callbackToAdd) {
2903                 callbackCache.add(dirPath, callbackToAdd);
2904             }
2905             return {
2906                 dirName: dirName,
2907                 close: function () {
2908                     var directoryWatcher = ts.Debug.checkDefined(cache.get(dirPath));
2909                     if (callbackToAdd)
2910                         callbackCache.remove(dirPath, callbackToAdd);
2911                     directoryWatcher.refCount--;
2912                     if (directoryWatcher.refCount)
2913                         return;
2914                     cache.delete(dirPath);
2915                     ts.closeFileWatcherOf(directoryWatcher);
2916                     directoryWatcher.childWatches.forEach(ts.closeFileWatcher);
2917                 }
2918             };
2919         }
2920         function invokeCallbacks(dirPath, fileNameOrInvokeMap) {
2921             var fileName;
2922             var invokeMap;
2923             if (ts.isString(fileNameOrInvokeMap)) {
2924                 fileName = fileNameOrInvokeMap;
2925             }
2926             else {
2927                 invokeMap = fileNameOrInvokeMap;
2928             }
2929             callbackCache.forEach(function (callbacks, rootDirName) {
2930                 if (invokeMap && invokeMap.has(rootDirName))
2931                     return;
2932                 if (rootDirName === dirPath || (ts.startsWith(dirPath, rootDirName) && dirPath[rootDirName.length] === ts.directorySeparator)) {
2933                     if (invokeMap) {
2934                         invokeMap.set(rootDirName, true);
2935                     }
2936                     else {
2937                         callbacks.forEach(function (_a) {
2938                             var callback = _a.callback;
2939                             return callback(fileName);
2940                         });
2941                     }
2942                 }
2943             });
2944         }
2945         function nonSyncUpdateChildWatches(dirName, dirPath, fileName, options) {
2946             var parentWatcher = cache.get(dirPath);
2947             if (parentWatcher && host.directoryExists(dirName)) {
2948                 scheduleUpdateChildWatches(dirName, dirPath, options);
2949                 return;
2950             }
2951             invokeCallbacks(dirPath, fileName);
2952             removeChildWatches(parentWatcher);
2953         }
2954         function scheduleUpdateChildWatches(dirName, dirPath, options) {
2955             if (!cacheToUpdateChildWatches.has(dirPath)) {
2956                 cacheToUpdateChildWatches.set(dirPath, { dirName: dirName, options: options });
2957             }
2958             if (timerToUpdateChildWatches) {
2959                 host.clearTimeout(timerToUpdateChildWatches);
2960                 timerToUpdateChildWatches = undefined;
2961             }
2962             timerToUpdateChildWatches = host.setTimeout(onTimerToUpdateChildWatches, 1000);
2963         }
2964         function onTimerToUpdateChildWatches() {
2965             timerToUpdateChildWatches = undefined;
2966             ts.sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size);
2967             var start = ts.timestamp();
2968             var invokeMap = ts.createMap();
2969             while (!timerToUpdateChildWatches && cacheToUpdateChildWatches.size) {
2970                 var _a = cacheToUpdateChildWatches.entries().next(), _b = _a.value, dirPath = _b[0], _c = _b[1], dirName = _c.dirName, options = _c.options, done = _a.done;
2971                 ts.Debug.assert(!done);
2972                 cacheToUpdateChildWatches.delete(dirPath);
2973                 invokeCallbacks(dirPath, invokeMap);
2974                 updateChildWatches(dirName, dirPath, options);
2975             }
2976             ts.sysLog("sysLog:: invokingWatchers:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size);
2977             callbackCache.forEach(function (callbacks, rootDirName) {
2978                 if (invokeMap.has(rootDirName)) {
2979                     callbacks.forEach(function (_a) {
2980                         var callback = _a.callback, dirName = _a.dirName;
2981                         return callback(dirName);
2982                     });
2983                 }
2984             });
2985             var elapsed = ts.timestamp() - start;
2986             ts.sysLog("sysLog:: Elapsed " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches);
2987         }
2988         function removeChildWatches(parentWatcher) {
2989             if (!parentWatcher)
2990                 return;
2991             var existingChildWatches = parentWatcher.childWatches;
2992             parentWatcher.childWatches = ts.emptyArray;
2993             for (var _i = 0, existingChildWatches_1 = existingChildWatches; _i < existingChildWatches_1.length; _i++) {
2994                 var childWatcher = existingChildWatches_1[_i];
2995                 childWatcher.close();
2996                 removeChildWatches(cache.get(toCanonicalFilePath(childWatcher.dirName)));
2997             }
2998         }
2999         function updateChildWatches(dirName, dirPath, options) {
3000             var parentWatcher = cache.get(dirPath);
3001             if (parentWatcher) {
3002                 parentWatcher.childWatches = watchChildDirectories(dirName, parentWatcher.childWatches, options);
3003             }
3004         }
3005         function watchChildDirectories(parentDir, existingChildWatches, options) {
3006             var newChildWatches;
3007             ts.enumerateInsertsAndDeletes(host.directoryExists(parentDir) ? ts.mapDefined(host.getAccessibleSortedChildDirectories(parentDir), function (child) {
3008                 var childFullName = ts.getNormalizedAbsolutePath(child, parentDir);
3009                 return !isIgnoredPath(childFullName) && filePathComparer(childFullName, ts.normalizePath(host.realpath(childFullName))) === 0 ? childFullName : undefined;
3010             }) : ts.emptyArray, existingChildWatches, function (child, childWatcher) { return filePathComparer(child, childWatcher.dirName); }, createAndAddChildDirectoryWatcher, ts.closeFileWatcher, addChildDirectoryWatcher);
3011             return newChildWatches || ts.emptyArray;
3012             function createAndAddChildDirectoryWatcher(childName) {
3013                 var result = createDirectoryWatcher(childName, options);
3014                 addChildDirectoryWatcher(result);
3015             }
3016             function addChildDirectoryWatcher(childWatcher) {
3017                 (newChildWatches || (newChildWatches = [])).push(childWatcher);
3018             }
3019         }
3020         function isIgnoredPath(path) {
3021             return ts.some(ts.ignoredPaths, function (searchPath) { return isInPath(path, searchPath); });
3022         }
3023         function isInPath(path, searchPath) {
3024             if (ts.stringContains(path, searchPath))
3025                 return true;
3026             if (host.useCaseSensitiveFileNames)
3027                 return false;
3028             return ts.stringContains(toCanonicalFilePath(path), searchPath);
3029         }
3030     }
3031     ts.createDirectoryWatcherSupportingRecursive = createDirectoryWatcherSupportingRecursive;
3032     function createFileWatcherCallback(callback) {
3033         return function (_fileName, eventKind) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", ""); };
3034     }
3035     ts.createFileWatcherCallback = createFileWatcherCallback;
3036     function createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists) {
3037         return function (eventName) {
3038             if (eventName === "rename") {
3039                 callback(fileName, fileExists(fileName) ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted);
3040             }
3041             else {
3042                 callback(fileName, FileWatcherEventKind.Changed);
3043             }
3044         };
3045     }
3046     function createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback) {
3047         return function (eventName, relativeFileName) {
3048             if (eventName === "rename") {
3049                 callback(!relativeFileName ? directoryName : ts.normalizePath(ts.combinePaths(directoryName, relativeFileName)));
3050             }
3051         };
3052     }
3053     function createSystemWatchFunctions(_a) {
3054         var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatch = _a.fsWatch, fileExists = _a.fileExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, directoryExists = _a.directoryExists, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory;
3055         var dynamicPollingWatchFile;
3056         var nonPollingWatchFile;
3057         var hostRecursiveDirectoryWatcher;
3058         return {
3059             watchFile: watchFile,
3060             watchDirectory: watchDirectory
3061         };
3062         function watchFile(fileName, callback, pollingInterval, options) {
3063             options = updateOptionsForWatchFile(options, useNonPollingWatchers);
3064             var watchFileKind = ts.Debug.checkDefined(options.watchFile);
3065             switch (watchFileKind) {
3066                 case ts.WatchFileKind.FixedPollingInterval:
3067                     return pollingWatchFile(fileName, callback, PollingInterval.Low, undefined);
3068                 case ts.WatchFileKind.PriorityPollingInterval:
3069                     return pollingWatchFile(fileName, callback, pollingInterval, undefined);
3070                 case ts.WatchFileKind.DynamicPriorityPolling:
3071                     return ensureDynamicPollingWatchFile()(fileName, callback, pollingInterval, undefined);
3072                 case ts.WatchFileKind.UseFsEvents:
3073                     return fsWatch(fileName, 0, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists), false, pollingInterval, ts.getFallbackOptions(options));
3074                 case ts.WatchFileKind.UseFsEventsOnParentDirectory:
3075                     if (!nonPollingWatchFile) {
3076                         nonPollingWatchFile = createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames);
3077                     }
3078                     return nonPollingWatchFile(fileName, callback, pollingInterval, ts.getFallbackOptions(options));
3079                 default:
3080                     ts.Debug.assertNever(watchFileKind);
3081             }
3082         }
3083         function ensureDynamicPollingWatchFile() {
3084             return dynamicPollingWatchFile ||
3085                 (dynamicPollingWatchFile = createDynamicPriorityPollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout }));
3086         }
3087         function updateOptionsForWatchFile(options, useNonPollingWatchers) {
3088             if (options && options.watchFile !== undefined)
3089                 return options;
3090             switch (tscWatchFile) {
3091                 case "PriorityPollingInterval":
3092                     return { watchFile: ts.WatchFileKind.PriorityPollingInterval };
3093                 case "DynamicPriorityPolling":
3094                     return { watchFile: ts.WatchFileKind.DynamicPriorityPolling };
3095                 case "UseFsEvents":
3096                     return generateWatchFileOptions(ts.WatchFileKind.UseFsEvents, ts.PollingWatchKind.PriorityInterval, options);
3097                 case "UseFsEventsWithFallbackDynamicPolling":
3098                     return generateWatchFileOptions(ts.WatchFileKind.UseFsEvents, ts.PollingWatchKind.DynamicPriority, options);
3099                 case "UseFsEventsOnParentDirectory":
3100                     useNonPollingWatchers = true;
3101                 default:
3102                     return useNonPollingWatchers ?
3103                         generateWatchFileOptions(ts.WatchFileKind.UseFsEventsOnParentDirectory, ts.PollingWatchKind.PriorityInterval, options) :
3104                         { watchFile: ts.WatchFileKind.FixedPollingInterval };
3105             }
3106         }
3107         function generateWatchFileOptions(watchFile, fallbackPolling, options) {
3108             var defaultFallbackPolling = options === null || options === void 0 ? void 0 : options.fallbackPolling;
3109             return {
3110                 watchFile: watchFile,
3111                 fallbackPolling: defaultFallbackPolling === undefined ?
3112                     fallbackPolling :
3113                     defaultFallbackPolling
3114             };
3115         }
3116         function watchDirectory(directoryName, callback, recursive, options) {
3117             if (fsSupportsRecursiveFsWatch) {
3118                 return fsWatch(directoryName, 1, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback), recursive, PollingInterval.Medium, ts.getFallbackOptions(options));
3119             }
3120             if (!hostRecursiveDirectoryWatcher) {
3121                 hostRecursiveDirectoryWatcher = createDirectoryWatcherSupportingRecursive({
3122                     useCaseSensitiveFileNames: useCaseSensitiveFileNames,
3123                     directoryExists: directoryExists,
3124                     getAccessibleSortedChildDirectories: getAccessibleSortedChildDirectories,
3125                     watchDirectory: nonRecursiveWatchDirectory,
3126                     realpath: realpath,
3127                     setTimeout: setTimeout,
3128                     clearTimeout: clearTimeout
3129                 });
3130             }
3131             return hostRecursiveDirectoryWatcher(directoryName, callback, recursive, options);
3132         }
3133         function nonRecursiveWatchDirectory(directoryName, callback, recursive, options) {
3134             ts.Debug.assert(!recursive);
3135             options = updateOptionsForWatchDirectory(options);
3136             var watchDirectoryKind = ts.Debug.checkDefined(options.watchDirectory);
3137             switch (watchDirectoryKind) {
3138                 case ts.WatchDirectoryKind.FixedPollingInterval:
3139                     return pollingWatchFile(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium, undefined);
3140                 case ts.WatchDirectoryKind.DynamicPriorityPolling:
3141                     return ensureDynamicPollingWatchFile()(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium, undefined);
3142                 case ts.WatchDirectoryKind.UseFsEvents:
3143                     return fsWatch(directoryName, 1, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback), recursive, PollingInterval.Medium, ts.getFallbackOptions(options));
3144                 default:
3145                     ts.Debug.assertNever(watchDirectoryKind);
3146             }
3147         }
3148         function updateOptionsForWatchDirectory(options) {
3149             if (options && options.watchDirectory !== undefined)
3150                 return options;
3151             switch (tscWatchDirectory) {
3152                 case "RecursiveDirectoryUsingFsWatchFile":
3153                     return { watchDirectory: ts.WatchDirectoryKind.FixedPollingInterval };
3154                 case "RecursiveDirectoryUsingDynamicPriorityPolling":
3155                     return { watchDirectory: ts.WatchDirectoryKind.DynamicPriorityPolling };
3156                 default:
3157                     var defaultFallbackPolling = options === null || options === void 0 ? void 0 : options.fallbackPolling;
3158                     return {
3159                         watchDirectory: ts.WatchDirectoryKind.UseFsEvents,
3160                         fallbackPolling: defaultFallbackPolling !== undefined ?
3161                             defaultFallbackPolling :
3162                             undefined
3163                     };
3164             }
3165         }
3166     }
3167     ts.createSystemWatchFunctions = createSystemWatchFunctions;
3168     function patchWriteFileEnsuringDirectory(sys) {
3169         var originalWriteFile = sys.writeFile;
3170         sys.writeFile = function (path, data, writeBom) {
3171             return ts.writeFileEnsuringDirectories(path, data, !!writeBom, function (path, data, writeByteOrderMark) { return originalWriteFile.call(sys, path, data, writeByteOrderMark); }, function (path) { return sys.createDirectory(path); }, function (path) { return sys.directoryExists(path); });
3172         };
3173     }
3174     ts.patchWriteFileEnsuringDirectory = patchWriteFileEnsuringDirectory;
3175     function getNodeMajorVersion() {
3176         if (typeof process === "undefined") {
3177             return undefined;
3178         }
3179         var version = process.version;
3180         if (!version) {
3181             return undefined;
3182         }
3183         var dot = version.indexOf(".");
3184         if (dot === -1) {
3185             return undefined;
3186         }
3187         return parseInt(version.substring(1, dot));
3188     }
3189     ts.getNodeMajorVersion = getNodeMajorVersion;
3190     ts.sys = (function () {
3191         var byteOrderMarkIndicator = "\uFEFF";
3192         function getNodeSystem() {
3193             var nativePattern = /^native |^\([^)]+\)$|^(internal[\\/]|[a-zA-Z0-9_\s]+(\.js)?$)/;
3194             var _fs = require("fs");
3195             var _path = require("path");
3196             var _os = require("os");
3197             var _crypto;
3198             try {
3199                 _crypto = require("crypto");
3200             }
3201             catch (_a) {
3202                 _crypto = undefined;
3203             }
3204             var activeSession;
3205             var profilePath = "./profile.cpuprofile";
3206             var Buffer = require("buffer").Buffer;
3207             var nodeVersion = getNodeMajorVersion();
3208             var isNode4OrLater = nodeVersion >= 4;
3209             var isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin";
3210             var platform = _os.platform();
3211             var useCaseSensitiveFileNames = isFileSystemCaseSensitive();
3212             var fsSupportsRecursiveFsWatch = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin");
3213             var _b = createSystemWatchFunctions({
3214                 pollingWatchFile: createSingleFileWatcherPerName(fsWatchFileWorker, useCaseSensitiveFileNames),
3215                 getModifiedTime: getModifiedTime,
3216                 setTimeout: setTimeout,
3217                 clearTimeout: clearTimeout,
3218                 fsWatch: fsWatch,
3219                 useCaseSensitiveFileNames: useCaseSensitiveFileNames,
3220                 fileExists: fileExists,
3221                 fsSupportsRecursiveFsWatch: fsSupportsRecursiveFsWatch,
3222                 directoryExists: directoryExists,
3223                 getAccessibleSortedChildDirectories: function (path) { return getAccessibleFileSystemEntries(path).directories; },
3224                 realpath: realpath,
3225                 tscWatchFile: process.env.TSC_WATCHFILE,
3226                 useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER,
3227                 tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
3228             }), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory;
3229             var nodeSystem = {
3230                 args: process.argv.slice(2),
3231                 newLine: _os.EOL,
3232                 useCaseSensitiveFileNames: useCaseSensitiveFileNames,
3233                 write: function (s) {
3234                     process.stdout.write(s);
3235                 },
3236                 writeOutputIsTTY: function () {
3237                     return process.stdout.isTTY;
3238                 },
3239                 readFile: readFile,
3240                 writeFile: writeFile,
3241                 watchFile: watchFile,
3242                 watchDirectory: watchDirectory,
3243                 resolvePath: function (path) { return _path.resolve(path); },
3244                 fileExists: fileExists,
3245                 directoryExists: directoryExists,
3246                 createDirectory: function (directoryName) {
3247                     if (!nodeSystem.directoryExists(directoryName)) {
3248                         try {
3249                             _fs.mkdirSync(directoryName);
3250                         }
3251                         catch (e) {
3252                             if (e.code !== "EEXIST") {
3253                                 throw e;
3254                             }
3255                         }
3256                     }
3257                 },
3258                 getExecutingFilePath: function () {
3259                     return __filename;
3260                 },
3261                 getCurrentDirectory: function () {
3262                     return process.cwd();
3263                 },
3264                 getDirectories: getDirectories,
3265                 getEnvironmentVariable: function (name) {
3266                     return process.env[name] || "";
3267                 },
3268                 readDirectory: readDirectory,
3269                 getModifiedTime: getModifiedTime,
3270                 setModifiedTime: setModifiedTime,
3271                 deleteFile: deleteFile,
3272                 createHash: _crypto ? createSHA256Hash : generateDjb2Hash,
3273                 createSHA256Hash: _crypto ? createSHA256Hash : undefined,
3274                 getMemoryUsage: function () {
3275                     if (global.gc) {
3276                         global.gc();
3277                     }
3278                     return process.memoryUsage().heapUsed;
3279                 },
3280                 getFileSize: function (path) {
3281                     try {
3282                         var stat = _fs.statSync(path);
3283                         if (stat.isFile()) {
3284                             return stat.size;
3285                         }
3286                     }
3287                     catch (_a) { }
3288                     return 0;
3289                 },
3290                 exit: function (exitCode) {
3291                     disableCPUProfiler(function () { return process.exit(exitCode); });
3292                 },
3293                 enableCPUProfiler: enableCPUProfiler,
3294                 disableCPUProfiler: disableCPUProfiler,
3295                 realpath: realpath,
3296                 debugMode: !!process.env.NODE_INSPECTOR_IPC || ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }),
3297                 tryEnableSourceMapsForHost: function () {
3298                     try {
3299                         require("source-map-support").install();
3300                     }
3301                     catch (_a) {
3302                     }
3303                 },
3304                 setTimeout: setTimeout,
3305                 clearTimeout: clearTimeout,
3306                 clearScreen: function () {
3307                     process.stdout.write("\x1Bc");
3308                 },
3309                 setBlocking: function () {
3310                     if (process.stdout && process.stdout._handle && process.stdout._handle.setBlocking) {
3311                         process.stdout._handle.setBlocking(true);
3312                     }
3313                 },
3314                 bufferFrom: bufferFrom,
3315                 base64decode: function (input) { return bufferFrom(input, "base64").toString("utf8"); },
3316                 base64encode: function (input) { return bufferFrom(input).toString("base64"); },
3317                 require: function (baseDir, moduleName) {
3318                     try {
3319                         var modulePath = ts.resolveJSModule(moduleName, baseDir, nodeSystem);
3320                         return { module: require(modulePath), modulePath: modulePath, error: undefined };
3321                     }
3322                     catch (error) {
3323                         return { module: undefined, modulePath: undefined, error: error };
3324                     }
3325                 }
3326             };
3327             return nodeSystem;
3328             function enableCPUProfiler(path, cb) {
3329                 if (activeSession) {
3330                     cb();
3331                     return false;
3332                 }
3333                 var inspector = require("inspector");
3334                 if (!inspector || !inspector.Session) {
3335                     cb();
3336                     return false;
3337                 }
3338                 var session = new inspector.Session();
3339                 session.connect();
3340                 session.post("Profiler.enable", function () {
3341                     session.post("Profiler.start", function () {
3342                         activeSession = session;
3343                         profilePath = path;
3344                         cb();
3345                     });
3346                 });
3347                 return true;
3348             }
3349             function cleanupPaths(profile) {
3350                 var externalFileCounter = 0;
3351                 var remappedPaths = ts.createMap();
3352                 var normalizedDir = ts.normalizeSlashes(__dirname);
3353                 var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir;
3354                 for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) {
3355                     var node = _a[_i];
3356                     if (node.callFrame.url) {
3357                         var url = ts.normalizeSlashes(node.callFrame.url);
3358                         if (ts.containsPath(fileUrlRoot, url, useCaseSensitiveFileNames)) {
3359                             node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), true);
3360                         }
3361                         else if (!nativePattern.test(url)) {
3362                             node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url);
3363                             externalFileCounter++;
3364                         }
3365                     }
3366                 }
3367                 return profile;
3368             }
3369             function disableCPUProfiler(cb) {
3370                 if (activeSession && activeSession !== "stopping") {
3371                     var s_1 = activeSession;
3372                     activeSession.post("Profiler.stop", function (err, _a) {
3373                         var profile = _a.profile;
3374                         if (!err) {
3375                             try {
3376                                 if (_fs.statSync(profilePath).isDirectory()) {
3377                                     profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile");
3378                                 }
3379                             }
3380                             catch (_b) {
3381                             }
3382                             try {
3383                                 _fs.mkdirSync(_path.dirname(profilePath), { recursive: true });
3384                             }
3385                             catch (_c) {
3386                             }
3387                             _fs.writeFileSync(profilePath, JSON.stringify(cleanupPaths(profile)));
3388                         }
3389                         activeSession = undefined;
3390                         s_1.disconnect();
3391                         cb();
3392                     });
3393                     activeSession = "stopping";
3394                     return true;
3395                 }
3396                 else {
3397                     cb();
3398                     return false;
3399                 }
3400             }
3401             function bufferFrom(input, encoding) {
3402                 return Buffer.from && Buffer.from !== Int8Array.from
3403                     ? Buffer.from(input, encoding)
3404                     : new Buffer(input, encoding);
3405             }
3406             function isFileSystemCaseSensitive() {
3407                 if (platform === "win32" || platform === "win64") {
3408                     return false;
3409                 }
3410                 return !fileExists(swapCase(__filename));
3411             }
3412             function swapCase(s) {
3413                 return s.replace(/\w/g, function (ch) {
3414                     var up = ch.toUpperCase();
3415                     return ch === up ? ch.toLowerCase() : up;
3416                 });
3417             }
3418             function fsWatchFileWorker(fileName, callback, pollingInterval) {
3419                 _fs.watchFile(fileName, { persistent: true, interval: pollingInterval }, fileChanged);
3420                 var eventKind;
3421                 return {
3422                     close: function () { return _fs.unwatchFile(fileName, fileChanged); }
3423                 };
3424                 function fileChanged(curr, prev) {
3425                     var isPreviouslyDeleted = +prev.mtime === 0 || eventKind === FileWatcherEventKind.Deleted;
3426                     if (+curr.mtime === 0) {
3427                         if (isPreviouslyDeleted) {
3428                             return;
3429                         }
3430                         eventKind = FileWatcherEventKind.Deleted;
3431                     }
3432                     else if (isPreviouslyDeleted) {
3433                         eventKind = FileWatcherEventKind.Created;
3434                     }
3435                     else if (+curr.mtime === +prev.mtime) {
3436                         return;
3437                     }
3438                     else {
3439                         eventKind = FileWatcherEventKind.Changed;
3440                     }
3441                     callback(fileName, eventKind);
3442                 }
3443             }
3444             function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
3445                 var options;
3446                 var lastDirectoryPartWithDirectorySeparator;
3447                 var lastDirectoryPart;
3448                 if (isLinuxOrMacOs) {
3449                     lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator));
3450                     lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length);
3451                 }
3452                 var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
3453                     watchMissingFileSystemEntry() :
3454                     watchPresentFileSystemEntry();
3455                 return {
3456                     close: function () {
3457                         watcher.close();
3458                         watcher = undefined;
3459                     }
3460                 };
3461                 function invokeCallbackAndUpdateWatcher(createWatcher) {
3462                     ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
3463                     callback("rename", "");
3464                     if (watcher) {
3465                         watcher.close();
3466                         watcher = createWatcher();
3467                     }
3468                 }
3469                 function watchPresentFileSystemEntry() {
3470                     if (options === undefined) {
3471                         if (fsSupportsRecursiveFsWatch) {
3472                             options = { persistent: true, recursive: !!recursive };
3473                         }
3474                         else {
3475                             options = { persistent: true };
3476                         }
3477                     }
3478                     try {
3479                         var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ?
3480                             callbackChangingToMissingFileSystemEntry :
3481                             callback);
3482                         presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); });
3483                         return presentWatcher;
3484                     }
3485                     catch (e) {
3486                         return watchPresentFileSystemEntryWithFsWatchFile();
3487                     }
3488                 }
3489                 function callbackChangingToMissingFileSystemEntry(event, relativeName) {
3490                     return event === "rename" &&
3491                         (!relativeName ||
3492                             relativeName === lastDirectoryPart ||
3493                             relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length) &&
3494                         !fileSystemEntryExists(fileOrDirectory, entryKind) ?
3495                         invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) :
3496                         callback(event, relativeName);
3497                 }
3498                 function watchPresentFileSystemEntryWithFsWatchFile() {
3499                     ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile");
3500                     return watchFile(fileOrDirectory, createFileWatcherCallback(callback), fallbackPollingInterval, fallbackOptions);
3501                 }
3502                 function watchMissingFileSystemEntry() {
3503                     return watchFile(fileOrDirectory, function (_fileName, eventKind) {
3504                         if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
3505                             invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry);
3506                         }
3507                     }, fallbackPollingInterval, fallbackOptions);
3508                 }
3509             }
3510             function readFileWorker(fileName, _encoding) {
3511                 var buffer;
3512                 try {
3513                     buffer = _fs.readFileSync(fileName);
3514                 }
3515                 catch (e) {
3516                     return undefined;
3517                 }
3518                 var len = buffer.length;
3519                 if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) {
3520                     len &= ~1;
3521                     for (var i = 0; i < len; i += 2) {
3522                         var temp = buffer[i];
3523                         buffer[i] = buffer[i + 1];
3524                         buffer[i + 1] = temp;
3525                     }
3526                     return buffer.toString("utf16le", 2);
3527                 }
3528                 if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) {
3529                     return buffer.toString("utf16le", 2);
3530                 }
3531                 if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) {
3532                     return buffer.toString("utf8", 3);
3533                 }
3534                 return buffer.toString("utf8");
3535             }
3536             function readFile(fileName, _encoding) {
3537                 ts.perfLogger.logStartReadFile(fileName);
3538                 var file = readFileWorker(fileName, _encoding);
3539                 ts.perfLogger.logStopReadFile();
3540                 return file;
3541             }
3542             function writeFile(fileName, data, writeByteOrderMark) {
3543                 ts.perfLogger.logEvent("WriteFile: " + fileName);
3544                 if (writeByteOrderMark) {
3545                     data = byteOrderMarkIndicator + data;
3546                 }
3547                 var fd;
3548                 try {
3549                     fd = _fs.openSync(fileName, "w");
3550                     _fs.writeSync(fd, data, undefined, "utf8");
3551                 }
3552                 finally {
3553                     if (fd !== undefined) {
3554                         _fs.closeSync(fd);
3555                     }
3556                 }
3557             }
3558             function getAccessibleFileSystemEntries(path) {
3559                 ts.perfLogger.logEvent("ReadDir: " + (path || "."));
3560                 try {
3561                     var entries = _fs.readdirSync(path || ".", { withFileTypes: true });
3562                     var files = [];
3563                     var directories = [];
3564                     for (var _i = 0, entries_2 = entries; _i < entries_2.length; _i++) {
3565                         var dirent = entries_2[_i];
3566                         var entry = typeof dirent === "string" ? dirent : dirent.name;
3567                         if (entry === "." || entry === "..") {
3568                             continue;
3569                         }
3570                         var stat = void 0;
3571                         if (typeof dirent === "string" || dirent.isSymbolicLink()) {
3572                             var name = ts.combinePaths(path, entry);
3573                             try {
3574                                 stat = _fs.statSync(name);
3575                             }
3576                             catch (e) {
3577                                 continue;
3578                             }
3579                         }
3580                         else {
3581                             stat = dirent;
3582                         }
3583                         if (stat.isFile()) {
3584                             files.push(entry);
3585                         }
3586                         else if (stat.isDirectory()) {
3587                             directories.push(entry);
3588                         }
3589                     }
3590                     files.sort();
3591                     directories.sort();
3592                     return { files: files, directories: directories };
3593                 }
3594                 catch (e) {
3595                     return ts.emptyFileSystemEntries;
3596                 }
3597             }
3598             function readDirectory(path, extensions, excludes, includes, depth) {
3599                 return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), depth, getAccessibleFileSystemEntries, realpath);
3600             }
3601             function fileSystemEntryExists(path, entryKind) {
3602                 try {
3603                     var stat = _fs.statSync(path);
3604                     switch (entryKind) {
3605                         case 0: return stat.isFile();
3606                         case 1: return stat.isDirectory();
3607                         default: return false;
3608                     }
3609                 }
3610                 catch (e) {
3611                     return false;
3612                 }
3613             }
3614             function fileExists(path) {
3615                 return fileSystemEntryExists(path, 0);
3616             }
3617             function directoryExists(path) {
3618                 return fileSystemEntryExists(path, 1);
3619             }
3620             function getDirectories(path) {
3621                 return getAccessibleFileSystemEntries(path).directories.slice();
3622             }
3623             function realpath(path) {
3624                 try {
3625                     return _fs.realpathSync(path);
3626                 }
3627                 catch (_a) {
3628                     return path;
3629                 }
3630             }
3631             function getModifiedTime(path) {
3632                 try {
3633                     return _fs.statSync(path).mtime;
3634                 }
3635                 catch (e) {
3636                     return undefined;
3637                 }
3638             }
3639             function setModifiedTime(path, time) {
3640                 try {
3641                     _fs.utimesSync(path, time, time);
3642                 }
3643                 catch (e) {
3644                     return;
3645                 }
3646             }
3647             function deleteFile(path) {
3648                 try {
3649                     return _fs.unlinkSync(path);
3650                 }
3651                 catch (e) {
3652                     return;
3653                 }
3654             }
3655             function createSHA256Hash(data) {
3656                 var hash = _crypto.createHash("sha256");
3657                 hash.update(data);
3658                 return hash.digest("hex");
3659             }
3660         }
3661         var sys;
3662         if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") {
3663             sys = getNodeSystem();
3664         }
3665         if (sys) {
3666             patchWriteFileEnsuringDirectory(sys);
3667         }
3668         return sys;
3669     })();
3670     if (ts.sys && ts.sys.getEnvironmentVariable) {
3671         setCustomPollingValues(ts.sys);
3672         ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))
3673             ? 1
3674             : 0);
3675     }
3676     if (ts.sys && ts.sys.debugMode) {
3677         ts.Debug.isDebugging = true;
3678     }
3679 })(ts || (ts = {}));
3680 var ts;
3681 (function (ts) {
3682     ts.directorySeparator = "/";
3683     var altDirectorySeparator = "\\";
3684     var urlSchemeSeparator = "://";
3685     var backslashRegExp = /\\/g;
3686     function isAnyDirectorySeparator(charCode) {
3687         return charCode === 47 || charCode === 92;
3688     }
3689     ts.isAnyDirectorySeparator = isAnyDirectorySeparator;
3690     function isUrl(path) {
3691         return getEncodedRootLength(path) < 0;
3692     }
3693     ts.isUrl = isUrl;
3694     function isRootedDiskPath(path) {
3695         return getEncodedRootLength(path) > 0;
3696     }
3697     ts.isRootedDiskPath = isRootedDiskPath;
3698     function isDiskPathRoot(path) {
3699         var rootLength = getEncodedRootLength(path);
3700         return rootLength > 0 && rootLength === path.length;
3701     }
3702     ts.isDiskPathRoot = isDiskPathRoot;
3703     function pathIsAbsolute(path) {
3704         return getEncodedRootLength(path) !== 0;
3705     }
3706     ts.pathIsAbsolute = pathIsAbsolute;
3707     function pathIsRelative(path) {
3708         return /^\.\.?($|[\\/])/.test(path);
3709     }
3710     ts.pathIsRelative = pathIsRelative;
3711     function hasExtension(fileName) {
3712         return ts.stringContains(getBaseFileName(fileName), ".");
3713     }
3714     ts.hasExtension = hasExtension;
3715     function fileExtensionIs(path, extension) {
3716         return path.length > extension.length && ts.endsWith(path, extension);
3717     }
3718     ts.fileExtensionIs = fileExtensionIs;
3719     function fileExtensionIsOneOf(path, extensions) {
3720         for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) {
3721             var extension = extensions_1[_i];
3722             if (fileExtensionIs(path, extension)) {
3723                 return true;
3724             }
3725         }
3726         return false;
3727     }
3728     ts.fileExtensionIsOneOf = fileExtensionIsOneOf;
3729     function hasTrailingDirectorySeparator(path) {
3730         return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1));
3731     }
3732     ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator;
3733     function isVolumeCharacter(charCode) {
3734         return (charCode >= 97 && charCode <= 122) ||
3735             (charCode >= 65 && charCode <= 90);
3736     }
3737     function getFileUrlVolumeSeparatorEnd(url, start) {
3738         var ch0 = url.charCodeAt(start);
3739         if (ch0 === 58)
3740             return start + 1;
3741         if (ch0 === 37 && url.charCodeAt(start + 1) === 51) {
3742             var ch2 = url.charCodeAt(start + 2);
3743             if (ch2 === 97 || ch2 === 65)
3744                 return start + 3;
3745         }
3746         return -1;
3747     }
3748     function getEncodedRootLength(path) {
3749         if (!path)
3750             return 0;
3751         var ch0 = path.charCodeAt(0);
3752         if (ch0 === 47 || ch0 === 92) {
3753             if (path.charCodeAt(1) !== ch0)
3754                 return 1;
3755             var p1 = path.indexOf(ch0 === 47 ? ts.directorySeparator : altDirectorySeparator, 2);
3756             if (p1 < 0)
3757                 return path.length;
3758             return p1 + 1;
3759         }
3760         if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58) {
3761             var ch2 = path.charCodeAt(2);
3762             if (ch2 === 47 || ch2 === 92)
3763                 return 3;
3764             if (path.length === 2)
3765                 return 2;
3766         }
3767         var schemeEnd = path.indexOf(urlSchemeSeparator);
3768         if (schemeEnd !== -1) {
3769             var authorityStart = schemeEnd + urlSchemeSeparator.length;
3770             var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart);
3771             if (authorityEnd !== -1) {
3772                 var scheme = path.slice(0, schemeEnd);
3773                 var authority = path.slice(authorityStart, authorityEnd);
3774                 if (scheme === "file" && (authority === "" || authority === "localhost") &&
3775                     isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
3776                     var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
3777                     if (volumeSeparatorEnd !== -1) {
3778                         if (path.charCodeAt(volumeSeparatorEnd) === 47) {
3779                             return ~(volumeSeparatorEnd + 1);
3780                         }
3781                         if (volumeSeparatorEnd === path.length) {
3782                             return ~volumeSeparatorEnd;
3783                         }
3784                     }
3785                 }
3786                 return ~(authorityEnd + 1);
3787             }
3788             return ~path.length;
3789         }
3790         return 0;
3791     }
3792     function getRootLength(path) {
3793         var rootLength = getEncodedRootLength(path);
3794         return rootLength < 0 ? ~rootLength : rootLength;
3795     }
3796     ts.getRootLength = getRootLength;
3797     function getDirectoryPath(path) {
3798         path = normalizeSlashes(path);
3799         var rootLength = getRootLength(path);
3800         if (rootLength === path.length)
3801             return path;
3802         path = removeTrailingDirectorySeparator(path);
3803         return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator)));
3804     }
3805     ts.getDirectoryPath = getDirectoryPath;
3806     function getBaseFileName(path, extensions, ignoreCase) {
3807         path = normalizeSlashes(path);
3808         var rootLength = getRootLength(path);
3809         if (rootLength === path.length)
3810             return "";
3811         path = removeTrailingDirectorySeparator(path);
3812         var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1));
3813         var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined;
3814         return extension ? name.slice(0, name.length - extension.length) : name;
3815     }
3816     ts.getBaseFileName = getBaseFileName;
3817     function tryGetExtensionFromPath(path, extension, stringEqualityComparer) {
3818         if (!ts.startsWith(extension, "."))
3819             extension = "." + extension;
3820         if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46) {
3821             var pathExtension = path.slice(path.length - extension.length);
3822             if (stringEqualityComparer(pathExtension, extension)) {
3823                 return pathExtension;
3824             }
3825         }
3826     }
3827     function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) {
3828         if (typeof extensions === "string") {
3829             return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || "";
3830         }
3831         for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) {
3832             var extension = extensions_2[_i];
3833             var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer);
3834             if (result)
3835                 return result;
3836         }
3837         return "";
3838     }
3839     function getAnyExtensionFromPath(path, extensions, ignoreCase) {
3840         if (extensions) {
3841             return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive);
3842         }
3843         var baseFileName = getBaseFileName(path);
3844         var extensionIndex = baseFileName.lastIndexOf(".");
3845         if (extensionIndex >= 0) {
3846             return baseFileName.substring(extensionIndex);
3847         }
3848         return "";
3849     }
3850     ts.getAnyExtensionFromPath = getAnyExtensionFromPath;
3851     function pathComponents(path, rootLength) {
3852         var root = path.substring(0, rootLength);
3853         var rest = path.substring(rootLength).split(ts.directorySeparator);
3854         if (rest.length && !ts.lastOrUndefined(rest))
3855             rest.pop();
3856         return __spreadArrays([root], rest);
3857     }
3858     function getPathComponents(path, currentDirectory) {
3859         if (currentDirectory === void 0) { currentDirectory = ""; }
3860         path = combinePaths(currentDirectory, path);
3861         return pathComponents(path, getRootLength(path));
3862     }
3863     ts.getPathComponents = getPathComponents;
3864     function getPathFromPathComponents(pathComponents) {
3865         if (pathComponents.length === 0)
3866             return "";
3867         var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]);
3868         return root + pathComponents.slice(1).join(ts.directorySeparator);
3869     }
3870     ts.getPathFromPathComponents = getPathFromPathComponents;
3871     function normalizeSlashes(path) {
3872         return path.replace(backslashRegExp, ts.directorySeparator);
3873     }
3874     ts.normalizeSlashes = normalizeSlashes;
3875     function reducePathComponents(components) {
3876         if (!ts.some(components))
3877             return [];
3878         var reduced = [components[0]];
3879         for (var i = 1; i < components.length; i++) {
3880             var component = components[i];
3881             if (!component)
3882                 continue;
3883             if (component === ".")
3884                 continue;
3885             if (component === "..") {
3886                 if (reduced.length > 1) {
3887                     if (reduced[reduced.length - 1] !== "..") {
3888                         reduced.pop();
3889                         continue;
3890                     }
3891                 }
3892                 else if (reduced[0])
3893                     continue;
3894             }
3895             reduced.push(component);
3896         }
3897         return reduced;
3898     }
3899     ts.reducePathComponents = reducePathComponents;
3900     function combinePaths(path) {
3901         var paths = [];
3902         for (var _i = 1; _i < arguments.length; _i++) {
3903             paths[_i - 1] = arguments[_i];
3904         }
3905         if (path)
3906             path = normalizeSlashes(path);
3907         for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) {
3908             var relativePath = paths_1[_a];
3909             if (!relativePath)
3910                 continue;
3911             relativePath = normalizeSlashes(relativePath);
3912             if (!path || getRootLength(relativePath) !== 0) {
3913                 path = relativePath;
3914             }
3915             else {
3916                 path = ensureTrailingDirectorySeparator(path) + relativePath;
3917             }
3918         }
3919         return path;
3920     }
3921     ts.combinePaths = combinePaths;
3922     function resolvePath(path) {
3923         var paths = [];
3924         for (var _i = 1; _i < arguments.length; _i++) {
3925             paths[_i - 1] = arguments[_i];
3926         }
3927         return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : normalizeSlashes(path));
3928     }
3929     ts.resolvePath = resolvePath;
3930     function getNormalizedPathComponents(path, currentDirectory) {
3931         return reducePathComponents(getPathComponents(path, currentDirectory));
3932     }
3933     ts.getNormalizedPathComponents = getNormalizedPathComponents;
3934     function getNormalizedAbsolutePath(fileName, currentDirectory) {
3935         return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory));
3936     }
3937     ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath;
3938     function normalizePath(path) {
3939         path = normalizeSlashes(path);
3940         var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path)));
3941         return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
3942     }
3943     ts.normalizePath = normalizePath;
3944     function getPathWithoutRoot(pathComponents) {
3945         if (pathComponents.length === 0)
3946             return "";
3947         return pathComponents.slice(1).join(ts.directorySeparator);
3948     }
3949     function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) {
3950         return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
3951     }
3952     ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot;
3953     function toPath(fileName, basePath, getCanonicalFileName) {
3954         var nonCanonicalizedPath = isRootedDiskPath(fileName)
3955             ? normalizePath(fileName)
3956             : getNormalizedAbsolutePath(fileName, basePath);
3957         return getCanonicalFileName(nonCanonicalizedPath);
3958     }
3959     ts.toPath = toPath;
3960     function normalizePathAndParts(path) {
3961         path = normalizeSlashes(path);
3962         var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
3963         if (parts.length) {
3964             var joinedParts = root + parts.join(ts.directorySeparator);
3965             return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
3966         }
3967         else {
3968             return { path: root, parts: parts };
3969         }
3970     }
3971     ts.normalizePathAndParts = normalizePathAndParts;
3972     function removeTrailingDirectorySeparator(path) {
3973         if (hasTrailingDirectorySeparator(path)) {
3974             return path.substr(0, path.length - 1);
3975         }
3976         return path;
3977     }
3978     ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator;
3979     function ensureTrailingDirectorySeparator(path) {
3980         if (!hasTrailingDirectorySeparator(path)) {
3981             return path + ts.directorySeparator;
3982         }
3983         return path;
3984     }
3985     ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator;
3986     function ensurePathIsNonModuleName(path) {
3987         return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path;
3988     }
3989     ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName;
3990     function changeAnyExtension(path, ext, extensions, ignoreCase) {
3991         var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path);
3992         return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
3993     }
3994     ts.changeAnyExtension = changeAnyExtension;
3995     var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/;
3996     function comparePathsWorker(a, b, componentComparer) {
3997         if (a === b)
3998             return 0;
3999         if (a === undefined)
4000             return -1;
4001         if (b === undefined)
4002             return 1;
4003         var aRoot = a.substring(0, getRootLength(a));
4004         var bRoot = b.substring(0, getRootLength(b));
4005         var result = ts.compareStringsCaseInsensitive(aRoot, bRoot);
4006         if (result !== 0) {
4007             return result;
4008         }
4009         var aRest = a.substring(aRoot.length);
4010         var bRest = b.substring(bRoot.length);
4011         if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) {
4012             return componentComparer(aRest, bRest);
4013         }
4014         var aComponents = reducePathComponents(getPathComponents(a));
4015         var bComponents = reducePathComponents(getPathComponents(b));
4016         var sharedLength = Math.min(aComponents.length, bComponents.length);
4017         for (var i = 1; i < sharedLength; i++) {
4018             var result_1 = componentComparer(aComponents[i], bComponents[i]);
4019             if (result_1 !== 0) {
4020                 return result_1;
4021             }
4022         }
4023         return ts.compareValues(aComponents.length, bComponents.length);
4024     }
4025     function comparePathsCaseSensitive(a, b) {
4026         return comparePathsWorker(a, b, ts.compareStringsCaseSensitive);
4027     }
4028     ts.comparePathsCaseSensitive = comparePathsCaseSensitive;
4029     function comparePathsCaseInsensitive(a, b) {
4030         return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive);
4031     }
4032     ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive;
4033     function comparePaths(a, b, currentDirectory, ignoreCase) {
4034         if (typeof currentDirectory === "string") {
4035             a = combinePaths(currentDirectory, a);
4036             b = combinePaths(currentDirectory, b);
4037         }
4038         else if (typeof currentDirectory === "boolean") {
4039             ignoreCase = currentDirectory;
4040         }
4041         return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase));
4042     }
4043     ts.comparePaths = comparePaths;
4044     function containsPath(parent, child, currentDirectory, ignoreCase) {
4045         if (typeof currentDirectory === "string") {
4046             parent = combinePaths(currentDirectory, parent);
4047             child = combinePaths(currentDirectory, child);
4048         }
4049         else if (typeof currentDirectory === "boolean") {
4050             ignoreCase = currentDirectory;
4051         }
4052         if (parent === undefined || child === undefined)
4053             return false;
4054         if (parent === child)
4055             return true;
4056         var parentComponents = reducePathComponents(getPathComponents(parent));
4057         var childComponents = reducePathComponents(getPathComponents(child));
4058         if (childComponents.length < parentComponents.length) {
4059             return false;
4060         }
4061         var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive;
4062         for (var i = 0; i < parentComponents.length; i++) {
4063             var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer;
4064             if (!equalityComparer(parentComponents[i], childComponents[i])) {
4065                 return false;
4066             }
4067         }
4068         return true;
4069     }
4070     ts.containsPath = containsPath;
4071     function startsWithDirectory(fileName, directoryName, getCanonicalFileName) {
4072         var canonicalFileName = getCanonicalFileName(fileName);
4073         var canonicalDirectoryName = getCanonicalFileName(directoryName);
4074         return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\");
4075     }
4076     ts.startsWithDirectory = startsWithDirectory;
4077     function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) {
4078         var fromComponents = reducePathComponents(getPathComponents(from));
4079         var toComponents = reducePathComponents(getPathComponents(to));
4080         var start;
4081         for (start = 0; start < fromComponents.length && start < toComponents.length; start++) {
4082             var fromComponent = getCanonicalFileName(fromComponents[start]);
4083             var toComponent = getCanonicalFileName(toComponents[start]);
4084             var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer;
4085             if (!comparer(fromComponent, toComponent))
4086                 break;
4087         }
4088         if (start === 0) {
4089             return toComponents;
4090         }
4091         var components = toComponents.slice(start);
4092         var relative = [];
4093         for (; start < fromComponents.length; start++) {
4094             relative.push("..");
4095         }
4096         return __spreadArrays([""], relative, components);
4097     }
4098     ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo;
4099     function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
4100         ts.Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
4101         var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
4102         var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
4103         var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
4104         return getPathFromPathComponents(pathComponents);
4105     }
4106     ts.getRelativePathFromDirectory = getRelativePathFromDirectory;
4107     function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) {
4108         return !isRootedDiskPath(absoluteOrRelativePath)
4109             ? absoluteOrRelativePath
4110             : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, false);
4111     }
4112     ts.convertToRelativePath = convertToRelativePath;
4113     function getRelativePathFromFile(from, to, getCanonicalFileName) {
4114         return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName));
4115     }
4116     ts.getRelativePathFromFile = getRelativePathFromFile;
4117     function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
4118         var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName);
4119         var firstComponent = pathComponents[0];
4120         if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) {
4121             var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///";
4122             pathComponents[0] = prefix + firstComponent;
4123         }
4124         return getPathFromPathComponents(pathComponents);
4125     }
4126     ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl;
4127     function forEachAncestorDirectory(directory, callback) {
4128         while (true) {
4129             var result = callback(directory);
4130             if (result !== undefined) {
4131                 return result;
4132             }
4133             var parentPath = getDirectoryPath(directory);
4134             if (parentPath === directory) {
4135                 return undefined;
4136             }
4137             directory = parentPath;
4138         }
4139     }
4140     ts.forEachAncestorDirectory = forEachAncestorDirectory;
4141     function isNodeModulesDirectory(dirPath) {
4142         return ts.endsWith(dirPath, "/node_modules");
4143     }
4144     ts.isNodeModulesDirectory = isNodeModulesDirectory;
4145 })(ts || (ts = {}));
4146 var ts;
4147 (function (ts) {
4148     function diag(code, category, key, message, reportsUnnecessary, elidedInCompatabilityPyramid) {
4149         return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary, elidedInCompatabilityPyramid: elidedInCompatabilityPyramid };
4150     }
4151     ts.Diagnostics = {
4152         Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."),
4153         Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."),
4154         _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."),
4155         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."),
4156         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."),
4157         Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."),
4158         Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."),
4159         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."),
4160         Unexpected_token: diag(1012, ts.DiagnosticCategory.Error, "Unexpected_token_1012", "Unexpected token."),
4161         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."),
4162         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."),
4163         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."),
4164         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."),
4165         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."),
4166         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."),
4167         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."),
4168         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."),
4169         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."),
4170         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."),
4171         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'."),
4172         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."),
4173         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."),
4174         Accessibility_modifier_already_seen: diag(1028, ts.DiagnosticCategory.Error, "Accessibility_modifier_already_seen_1028", "Accessibility modifier already seen."),
4175         _0_modifier_must_precede_1_modifier: diag(1029, ts.DiagnosticCategory.Error, "_0_modifier_must_precede_1_modifier_1029", "'{0}' modifier must precede '{1}' modifier."),
4176         _0_modifier_already_seen: diag(1030, ts.DiagnosticCategory.Error, "_0_modifier_already_seen_1030", "'{0}' modifier already seen."),
4177         _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."),
4178         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."),
4179         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."),
4180         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."),
4181         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."),
4182         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."),
4183         _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."),
4184         _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."),
4185         _0_modifier_cannot_be_used_here: diag(1042, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_here_1042", "'{0}' modifier cannot be used here."),
4186         _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."),
4187         _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."),
4188         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."),
4189         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."),
4190         A_rest_parameter_cannot_be_optional: diag(1047, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_be_optional_1047", "A rest parameter cannot be optional."),
4191         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."),
4192         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."),
4193         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."),
4194         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."),
4195         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."),
4196         A_get_accessor_cannot_have_parameters: diag(1054, ts.DiagnosticCategory.Error, "A_get_accessor_cannot_have_parameters_1054", "A 'get' accessor cannot have parameters."),
4197         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."),
4198         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."),
4199         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."),
4200         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."),
4201         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."),
4202         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."),
4203         Enum_member_must_have_initializer: diag(1061, ts.DiagnosticCategory.Error, "Enum_member_must_have_initializer_1061", "Enum member must have initializer."),
4204         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."),
4205         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."),
4206         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."),
4207         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."),
4208         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."),
4209         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."),
4210         _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."),
4211         _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."),
4212         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."),
4213         Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."),
4214         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}'."),
4215         _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."),
4216         _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."),
4217         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."),
4218         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."),
4219         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."),
4220         An_accessor_cannot_have_type_parameters: diag(1094, ts.DiagnosticCategory.Error, "An_accessor_cannot_have_type_parameters_1094", "An accessor cannot have type parameters."),
4221         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."),
4222         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."),
4223         _0_list_cannot_be_empty: diag(1097, ts.DiagnosticCategory.Error, "_0_list_cannot_be_empty_1097", "'{0}' list cannot be empty."),
4224         Type_parameter_list_cannot_be_empty: diag(1098, ts.DiagnosticCategory.Error, "Type_parameter_list_cannot_be_empty_1098", "Type parameter list cannot be empty."),
4225         Type_argument_list_cannot_be_empty: diag(1099, ts.DiagnosticCategory.Error, "Type_argument_list_cannot_be_empty_1099", "Type argument list cannot be empty."),
4226         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."),
4227         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."),
4228         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."),
4229         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."),
4230         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."),
4231         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."),
4232         Jump_target_cannot_cross_function_boundary: diag(1107, ts.DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."),
4233         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."),
4234         Expression_expected: diag(1109, ts.DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."),
4235         Type_expected: diag(1110, ts.DiagnosticCategory.Error, "Type_expected_1110", "Type expected."),
4236         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."),
4237         Duplicate_label_0: diag(1114, ts.DiagnosticCategory.Error, "Duplicate_label_0_1114", "Duplicate label '{0}'."),
4238         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."),
4239         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."),
4240         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."),
4241         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."),
4242         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."),
4243         An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."),
4244         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."),
4245         Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."),
4246         Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."),
4247         Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."),
4248         Unexpected_end_of_text: diag(1126, ts.DiagnosticCategory.Error, "Unexpected_end_of_text_1126", "Unexpected end of text."),
4249         Invalid_character: diag(1127, ts.DiagnosticCategory.Error, "Invalid_character_1127", "Invalid character."),
4250         Declaration_or_statement_expected: diag(1128, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_1128", "Declaration or statement expected."),
4251         Statement_expected: diag(1129, ts.DiagnosticCategory.Error, "Statement_expected_1129", "Statement expected."),
4252         case_or_default_expected: diag(1130, ts.DiagnosticCategory.Error, "case_or_default_expected_1130", "'case' or 'default' expected."),
4253         Property_or_signature_expected: diag(1131, ts.DiagnosticCategory.Error, "Property_or_signature_expected_1131", "Property or signature expected."),
4254         Enum_member_expected: diag(1132, ts.DiagnosticCategory.Error, "Enum_member_expected_1132", "Enum member expected."),
4255         Variable_declaration_expected: diag(1134, ts.DiagnosticCategory.Error, "Variable_declaration_expected_1134", "Variable declaration expected."),
4256         Argument_expression_expected: diag(1135, ts.DiagnosticCategory.Error, "Argument_expression_expected_1135", "Argument expression expected."),
4257         Property_assignment_expected: diag(1136, ts.DiagnosticCategory.Error, "Property_assignment_expected_1136", "Property assignment expected."),
4258         Expression_or_comma_expected: diag(1137, ts.DiagnosticCategory.Error, "Expression_or_comma_expected_1137", "Expression or comma expected."),
4259         Parameter_declaration_expected: diag(1138, ts.DiagnosticCategory.Error, "Parameter_declaration_expected_1138", "Parameter declaration expected."),
4260         Type_parameter_declaration_expected: diag(1139, ts.DiagnosticCategory.Error, "Type_parameter_declaration_expected_1139", "Type parameter declaration expected."),
4261         Type_argument_expected: diag(1140, ts.DiagnosticCategory.Error, "Type_argument_expected_1140", "Type argument expected."),
4262         String_literal_expected: diag(1141, ts.DiagnosticCategory.Error, "String_literal_expected_1141", "String literal expected."),
4263         Line_break_not_permitted_here: diag(1142, ts.DiagnosticCategory.Error, "Line_break_not_permitted_here_1142", "Line break not permitted here."),
4264         or_expected: diag(1144, ts.DiagnosticCategory.Error, "or_expected_1144", "'{' or ';' expected."),
4265         Declaration_expected: diag(1146, ts.DiagnosticCategory.Error, "Declaration_expected_1146", "Declaration expected."),
4266         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."),
4267         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'."),
4268         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."),
4269         const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."),
4270         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."),
4271         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."),
4272         Unterminated_template_literal: diag(1160, ts.DiagnosticCategory.Error, "Unterminated_template_literal_1160", "Unterminated template literal."),
4273         Unterminated_regular_expression_literal: diag(1161, ts.DiagnosticCategory.Error, "Unterminated_regular_expression_literal_1161", "Unterminated regular expression literal."),
4274         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."),
4275         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."),
4276         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."),
4277         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."),
4278         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."),
4279         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."),
4280         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."),
4281         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."),
4282         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."),
4283         extends_clause_already_seen: diag(1172, ts.DiagnosticCategory.Error, "extends_clause_already_seen_1172", "'extends' clause already seen."),
4284         extends_clause_must_precede_implements_clause: diag(1173, ts.DiagnosticCategory.Error, "extends_clause_must_precede_implements_clause_1173", "'extends' clause must precede 'implements' clause."),
4285         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."),
4286         implements_clause_already_seen: diag(1175, ts.DiagnosticCategory.Error, "implements_clause_already_seen_1175", "'implements' clause already seen."),
4287         Interface_declaration_cannot_have_implements_clause: diag(1176, ts.DiagnosticCategory.Error, "Interface_declaration_cannot_have_implements_clause_1176", "Interface declaration cannot have 'implements' clause."),
4288         Binary_digit_expected: diag(1177, ts.DiagnosticCategory.Error, "Binary_digit_expected_1177", "Binary digit expected."),
4289         Octal_digit_expected: diag(1178, ts.DiagnosticCategory.Error, "Octal_digit_expected_1178", "Octal digit expected."),
4290         Unexpected_token_expected: diag(1179, ts.DiagnosticCategory.Error, "Unexpected_token_expected_1179", "Unexpected token. '{' expected."),
4291         Property_destructuring_pattern_expected: diag(1180, ts.DiagnosticCategory.Error, "Property_destructuring_pattern_expected_1180", "Property destructuring pattern expected."),
4292         Array_element_destructuring_pattern_expected: diag(1181, ts.DiagnosticCategory.Error, "Array_element_destructuring_pattern_expected_1181", "Array element destructuring pattern expected."),
4293         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."),
4294         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."),
4295         Modifiers_cannot_appear_here: diag(1184, ts.DiagnosticCategory.Error, "Modifiers_cannot_appear_here_1184", "Modifiers cannot appear here."),
4296         Merge_conflict_marker_encountered: diag(1185, ts.DiagnosticCategory.Error, "Merge_conflict_marker_encountered_1185", "Merge conflict marker encountered."),
4297         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."),
4298         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."),
4299         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."),
4300         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."),
4301         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."),
4302         An_import_declaration_cannot_have_modifiers: diag(1191, ts.DiagnosticCategory.Error, "An_import_declaration_cannot_have_modifiers_1191", "An import declaration cannot have modifiers."),
4303         Module_0_has_no_default_export: diag(1192, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_1192", "Module '{0}' has no default export."),
4304         An_export_declaration_cannot_have_modifiers: diag(1193, ts.DiagnosticCategory.Error, "An_export_declaration_cannot_have_modifiers_1193", "An export declaration cannot have modifiers."),
4305         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."),
4306         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."),
4307         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."),
4308         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."),
4309         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."),
4310         Unterminated_Unicode_escape_sequence: diag(1199, ts.DiagnosticCategory.Error, "Unterminated_Unicode_escape_sequence_1199", "Unterminated Unicode escape sequence."),
4311         Line_terminator_not_permitted_before_arrow: diag(1200, ts.DiagnosticCategory.Error, "Line_terminator_not_permitted_before_arrow_1200", "Line terminator not permitted before arrow."),
4312         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."),
4313         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."),
4314         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'."),
4315         Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."),
4316         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."),
4317         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."),
4318         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."),
4319         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."),
4320         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."),
4321         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."),
4322         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."),
4323         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."),
4324         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."),
4325         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'."),
4326         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."),
4327         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."),
4328         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."),
4329         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."),
4330         _0_tag_already_specified: diag(1223, ts.DiagnosticCategory.Error, "_0_tag_already_specified_1223", "'{0}' tag already specified."),
4331         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."),
4332         Cannot_find_parameter_0: diag(1225, ts.DiagnosticCategory.Error, "Cannot_find_parameter_0_1225", "Cannot find parameter '{0}'."),
4333         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}'."),
4334         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}'."),
4335         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."),
4336         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."),
4337         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."),
4338         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."),
4339         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."),
4340         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."),
4341         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."),
4342         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."),
4343         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'."),
4344         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'."),
4345         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."),
4346         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."),
4347         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."),
4348         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."),
4349         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."),
4350         _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."),
4351         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."),
4352         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."),
4353         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."),
4354         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."),
4355         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."),
4356         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."),
4357         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'."),
4358         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."),
4359         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."),
4360         _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."),
4361         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."),
4362         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."),
4363         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."),
4364         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."),
4365         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."),
4366         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"),
4367         Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."),
4368         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."),
4369         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."),
4370         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."),
4371         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."),
4372         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."),
4373         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."),
4374         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."),
4375         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."),
4376         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."),
4377         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."),
4378         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."),
4379         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."),
4380         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."),
4381         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."),
4382         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'."),
4383         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."),
4384         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."),
4385         Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments"),
4386         String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."),
4387         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."),
4388         _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}()'?"),
4389         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'."),
4390         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'."),
4391         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'."),
4392         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."),
4393         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."),
4394         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."),
4395         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."),
4396         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."),
4397         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."),
4398         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."),
4399         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}')'?"),
4400         Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."),
4401         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'."),
4402         A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."),
4403         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"),
4404         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."),
4405         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."),
4406         Non_simple_parameter_declared_here: diag(1348, ts.DiagnosticCategory.Error, "Non_simple_parameter_declared_here_1348", "Non-simple parameter declared here."),
4407         use_strict_directive_used_here: diag(1349, ts.DiagnosticCategory.Error, "use_strict_directive_used_here_1349", "'use strict' directive used here."),
4408         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."),
4409         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."),
4410         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."),
4411         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."),
4412         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."),
4413         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."),
4414         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'?"),
4415         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 '}'."),
4416         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."),
4417         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."),
4418         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?"),
4419         _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'."),
4420         _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'."),
4421         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."),
4422         Convert_to_type_only_export: diag(1364, ts.DiagnosticCategory.Message, "Convert_to_type_only_export_1364", "Convert to type-only export"),
4423         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"),
4424         Split_into_two_separate_import_declarations: diag(1366, ts.DiagnosticCategory.Message, "Split_into_two_separate_import_declarations_1366", "Split into two separate import declarations"),
4425         Split_all_invalid_type_only_imports: diag(1367, ts.DiagnosticCategory.Message, "Split_all_invalid_type_only_imports_1367", "Split all invalid type-only imports"),
4426         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"),
4427         Did_you_mean_0: diag(1369, ts.DiagnosticCategory.Message, "Did_you_mean_0_1369", "Did you mean '{0}'?"),
4428         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'."),
4429         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'."),
4430         Convert_to_type_only_import: diag(1373, ts.DiagnosticCategory.Message, "Convert_to_type_only_import_1373", "Convert to type-only import"),
4431         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"),
4432         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."),
4433         _0_was_imported_here: diag(1376, ts.DiagnosticCategory.Message, "_0_was_imported_here_1376", "'{0}' was imported here."),
4434         _0_was_exported_here: diag(1377, ts.DiagnosticCategory.Message, "_0_was_exported_here_1377", "'{0}' was exported here."),
4435         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."),
4436         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'."),
4437         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'."),
4438         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;`?"),
4439         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;`?"),
4440         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'."),
4441         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."),
4442         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."),
4443         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."),
4444         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),
4445         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),
4446         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),
4447         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),
4448         Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
4449         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."),
4450         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."),
4451         Circular_definition_of_import_alias_0: diag(2303, ts.DiagnosticCategory.Error, "Circular_definition_of_import_alias_0_2303", "Circular definition of import alias '{0}'."),
4452         Cannot_find_name_0: diag(2304, ts.DiagnosticCategory.Error, "Cannot_find_name_0_2304", "Cannot find name '{0}'."),
4453         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}'."),
4454         File_0_is_not_a_module: diag(2306, ts.DiagnosticCategory.Error, "File_0_is_not_a_module_2306", "File '{0}' is not a module."),
4455         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."),
4456         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."),
4457         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."),
4458         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."),
4459         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."),
4460         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."),
4461         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."),
4462         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)."),
4463         Type_0_is_not_generic: diag(2315, ts.DiagnosticCategory.Error, "Type_0_is_not_generic_2315", "Type '{0}' is not generic."),
4464         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."),
4465         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)."),
4466         Cannot_find_global_type_0: diag(2318, ts.DiagnosticCategory.Error, "Cannot_find_global_type_0_2318", "Cannot find global type '{0}'."),
4467         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."),
4468         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}'."),
4469         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}'."),
4470         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}'."),
4471         Cannot_redeclare_exported_variable_0: diag(2323, ts.DiagnosticCategory.Error, "Cannot_redeclare_exported_variable_0_2323", "Cannot redeclare exported variable '{0}'."),
4472         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}'."),
4473         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}'."),
4474         Types_of_property_0_are_incompatible: diag(2326, ts.DiagnosticCategory.Error, "Types_of_property_0_are_incompatible_2326", "Types of property '{0}' are incompatible."),
4475         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}'."),
4476         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."),
4477         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}'."),
4478         Index_signatures_are_incompatible: diag(2330, ts.DiagnosticCategory.Error, "Index_signatures_are_incompatible_2330", "Index signatures are incompatible."),
4479         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."),
4480         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."),
4481         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."),
4482         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."),
4483         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."),
4484         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."),
4485         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."),
4486         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."),
4487         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}'."),
4488         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."),
4489         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}'."),
4490         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'."),
4491         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}'."),
4492         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}'."),
4493         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}'."),
4494         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."),
4495         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."),
4496         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'?"),
4497         This_expression_is_not_callable: diag(2349, ts.DiagnosticCategory.Error, "This_expression_is_not_callable_2349", "This expression is not callable."),
4498         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."),
4499         This_expression_is_not_constructable: diag(2351, ts.DiagnosticCategory.Error, "This_expression_is_not_constructable_2351", "This expression is not constructable."),
4500         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."),
4501         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}'."),
4502         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."),
4503         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."),
4504         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."),
4505         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."),
4506         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."),
4507         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."),
4508         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'."),
4509         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."),
4510         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."),
4511         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."),
4512         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."),
4513         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}'."),
4514         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'."),
4515         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."),
4516         Type_parameter_name_cannot_be_0: diag(2368, ts.DiagnosticCategory.Error, "Type_parameter_name_cannot_be_0_2368", "Type parameter name cannot be '{0}'."),
4517         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."),
4518         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."),
4519         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."),
4520         Parameter_0_cannot_reference_itself: diag(2372, ts.DiagnosticCategory.Error, "Parameter_0_cannot_reference_itself_2372", "Parameter '{0}' cannot reference itself."),
4521         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."),
4522         Duplicate_string_index_signature: diag(2374, ts.DiagnosticCategory.Error, "Duplicate_string_index_signature_2374", "Duplicate string index signature."),
4523         Duplicate_number_index_signature: diag(2375, ts.DiagnosticCategory.Error, "Duplicate_number_index_signature_2375", "Duplicate number index signature."),
4524         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."),
4525         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."),
4526         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."),
4527         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."),
4528         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."),
4529         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."),
4530         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."),
4531         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."),
4532         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."),
4533         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."),
4534         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."),
4535         Function_overload_must_be_static: diag(2387, ts.DiagnosticCategory.Error, "Function_overload_must_be_static_2387", "Function overload must be static."),
4536         Function_overload_must_not_be_static: diag(2388, ts.DiagnosticCategory.Error, "Function_overload_must_not_be_static_2388", "Function overload must not be static."),
4537         Function_implementation_name_must_be_0: diag(2389, ts.DiagnosticCategory.Error, "Function_implementation_name_must_be_0_2389", "Function implementation name must be '{0}'."),
4538         Constructor_implementation_is_missing: diag(2390, ts.DiagnosticCategory.Error, "Constructor_implementation_is_missing_2390", "Constructor implementation is missing."),
4539         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."),
4540         Multiple_constructor_implementations_are_not_allowed: diag(2392, ts.DiagnosticCategory.Error, "Multiple_constructor_implementations_are_not_allowed_2392", "Multiple constructor implementations are not allowed."),
4541         Duplicate_function_implementation: diag(2393, ts.DiagnosticCategory.Error, "Duplicate_function_implementation_2393", "Duplicate function implementation."),
4542         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."),
4543         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."),
4544         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."),
4545         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}'."),
4546         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."),
4547         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."),
4548         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."),
4549         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."),
4550         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."),
4551         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}'."),
4552         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."),
4553         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'."),
4554         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."),
4555         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}'."),
4556         Setters_cannot_return_a_value: diag(2408, ts.DiagnosticCategory.Error, "Setters_cannot_return_a_value_2408", "Setters cannot return a value."),
4557         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."),
4558         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'."),
4559         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}'."),
4560         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}'."),
4561         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}'."),
4562         Class_name_cannot_be_0: diag(2414, ts.DiagnosticCategory.Error, "Class_name_cannot_be_0_2414", "Class name cannot be '{0}'."),
4563         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}'."),
4564         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}'."),
4565         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}'."),
4566         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}'."),
4567         Class_0_incorrectly_implements_interface_1: diag(2420, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_interface_1_2420", "Class '{0}' incorrectly implements interface '{1}'."),
4568         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."),
4569         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."),
4570         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."),
4571         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."),
4572         Interface_name_cannot_be_0: diag(2427, ts.DiagnosticCategory.Error, "Interface_name_cannot_be_0_2427", "Interface name cannot be '{0}'."),
4573         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."),
4574         Interface_0_incorrectly_extends_interface_1: diag(2430, ts.DiagnosticCategory.Error, "Interface_0_incorrectly_extends_interface_1_2430", "Interface '{0}' incorrectly extends interface '{1}'."),
4575         Enum_name_cannot_be_0: diag(2431, ts.DiagnosticCategory.Error, "Enum_name_cannot_be_0_2431", "Enum name cannot be '{0}'."),
4576         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."),
4577         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."),
4578         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."),
4579         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."),
4580         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."),
4581         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."),
4582         Import_name_cannot_be_0: diag(2438, ts.DiagnosticCategory.Error, "Import_name_cannot_be_0_2438", "Import name cannot be '{0}'."),
4583         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."),
4584         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}'."),
4585         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."),
4586         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}'."),
4587         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}'."),
4588         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}'."),
4589         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."),
4590         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}'."),
4591         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."),
4592         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."),
4593         Class_0_used_before_its_declaration: diag(2449, ts.DiagnosticCategory.Error, "Class_0_used_before_its_declaration_2449", "Class '{0}' used before its declaration."),
4594         Enum_0_used_before_its_declaration: diag(2450, ts.DiagnosticCategory.Error, "Enum_0_used_before_its_declaration_2450", "Enum '{0}' used before its declaration."),
4595         Cannot_redeclare_block_scoped_variable_0: diag(2451, ts.DiagnosticCategory.Error, "Cannot_redeclare_block_scoped_variable_0_2451", "Cannot redeclare block-scoped variable '{0}'."),
4596         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."),
4597         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."),
4598         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."),
4599         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}'."),
4600         Type_alias_0_circularly_references_itself: diag(2456, ts.DiagnosticCategory.Error, "Type_alias_0_circularly_references_itself_2456", "Type alias '{0}' circularly references itself."),
4601         Type_alias_name_cannot_be_0: diag(2457, ts.DiagnosticCategory.Error, "Type_alias_name_cannot_be_0_2457", "Type alias name cannot be '{0}'."),
4602         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."),
4603         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."),
4604         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}'."),
4605         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."),
4606         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."),
4607         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."),
4608         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'."),
4609         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."),
4610         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."),
4611         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."),
4612         Cannot_find_global_value_0: diag(2468, ts.DiagnosticCategory.Error, "Cannot_find_global_value_0_2468", "Cannot find global value '{0}'."),
4613         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'."),
4614         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."),
4615         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'."),
4616         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."),
4617         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."),
4618         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."),
4619         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."),
4620         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."),
4621         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."),
4622         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'."),
4623         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}'."),
4624         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."),
4625         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}'."),
4626         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."),
4627         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}'."),
4628         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."),
4629         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."),
4630         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."),
4631         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."),
4632         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."),
4633         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."),
4634         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}'."),
4635         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."),
4636         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."),
4637         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."),
4638         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."),
4639         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 *'."),
4640         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."),
4641         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."),
4642         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."),
4643         _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."),
4644         Cannot_find_namespace_0: diag(2503, ts.DiagnosticCategory.Error, "Cannot_find_namespace_0_2503", "Cannot find namespace '{0}'."),
4645         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."),
4646         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."),
4647         _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."),
4648         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."),
4649         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."),
4650         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."),
4651         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."),
4652         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."),
4653         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."),
4654         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."),
4655         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."),
4656         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}'."),
4657         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."),
4658         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."),
4659         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."),
4660         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."),
4661         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."),
4662         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."),
4663         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."),
4664         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."),
4665         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."),
4666         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."),
4667         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."),
4668         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."),
4669         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."),
4670         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."),
4671         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."),
4672         Object_is_possibly_null: diag(2531, ts.DiagnosticCategory.Error, "Object_is_possibly_null_2531", "Object is possibly 'null'."),
4673         Object_is_possibly_undefined: diag(2532, ts.DiagnosticCategory.Error, "Object_is_possibly_undefined_2532", "Object is possibly 'undefined'."),
4674         Object_is_possibly_null_or_undefined: diag(2533, ts.DiagnosticCategory.Error, "Object_is_possibly_null_or_undefined_2533", "Object is possibly 'null' or 'undefined'."),
4675         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."),
4676         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."),
4677         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}'."),
4678         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}'."),
4679         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."),
4680         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."),
4681         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."),
4682         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."),
4683         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."),
4684         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."),
4685         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."),
4686         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[]'."),
4687         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."),
4688         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."),
4689         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."),
4690         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}'?"),
4691         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}'?"),
4692         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."),
4693         Expected_0_arguments_but_got_1: diag(2554, ts.DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_2554", "Expected {0} arguments, but got {1}."),
4694         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}."),
4695         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."),
4696         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."),
4697         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}."),
4698         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}'."),
4699         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?"),
4700         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}'?"),
4701         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."),
4702         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."),
4703         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."),
4704         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."),
4705         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."),
4706         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."),
4707         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."),
4708         Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."),
4709         Rest_signatures_are_incompatible: diag(2572, ts.DiagnosticCategory.Error, "Rest_signatures_are_incompatible_2572", "Rest signatures are incompatible."),
4710         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."),
4711         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."),
4712         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."),
4713         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}'"),
4714         Return_type_annotation_circularly_references_itself: diag(2577, ts.DiagnosticCategory.Error, "Return_type_annotation_circularly_references_itself_2577", "Return type annotation circularly references itself."),
4715         Unused_ts_expect_error_directive: diag(2578, ts.DiagnosticCategory.Error, "Unused_ts_expect_error_directive_2578", "Unused '@ts-expect-error' directive."),
4716         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`."),
4717         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`."),
4718         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`."),
4719         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."),
4720         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'."),
4721         _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."),
4722         Enum_type_0_circularly_references_itself: diag(2586, ts.DiagnosticCategory.Error, "Enum_type_0_circularly_references_itself_2586", "Enum type '{0}' circularly references itself."),
4723         JSDoc_type_0_circularly_references_itself: diag(2587, ts.DiagnosticCategory.Error, "JSDoc_type_0_circularly_references_itself_2587", "JSDoc type '{0}' circularly references itself."),
4724         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."),
4725         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."),
4726         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."),
4727         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."),
4728         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."),
4729         Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha_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."),
4730         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."),
4731         _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."),
4732         _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."),
4733         _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."),
4734         _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."),
4735         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."),
4736         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."),
4737         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."),
4738         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}'."),
4739         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."),
4740         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."),
4741         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."),
4742         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."),
4743         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."),
4744         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."),
4745         _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."),
4746         _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."),
4747         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."),
4748         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?"),
4749         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?"),
4750         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}'."),
4751         _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."),
4752         _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."),
4753         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."),
4754         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."),
4755         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."),
4756         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}'."),
4757         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."),
4758         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."),
4759         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."),
4760         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}'."),
4761         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."),
4762         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."),
4763         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."),
4764         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}'?"),
4765         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}'?"),
4766         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."),
4767         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."),
4768         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."),
4769         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."),
4770         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."),
4771         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."),
4772         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."),
4773         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."),
4774         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."),
4775         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."),
4776         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."),
4777         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."),
4778         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."),
4779         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."),
4780         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}'."),
4781         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'."),
4782         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."),
4783         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."),
4784         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."),
4785         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."),
4786         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}'."),
4787         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."),
4788         _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."),
4789         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."),
4790         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}'."),
4791         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'?"),
4792         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."),
4793         _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."),
4794         _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."),
4795         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}'."),
4796         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),
4797         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?"),
4798         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."),
4799         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."),
4800         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}'."),
4801         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."),
4802         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."),
4803         _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."),
4804         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."),
4805         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."),
4806         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."),
4807         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."),
4808         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."),
4809         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."),
4810         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."),
4811         _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."),
4812         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."),
4813         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."),
4814         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}\"]'?"),
4815         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."),
4816         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."),
4817         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."),
4818         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}'."),
4819         Duplicate_property_0: diag(2718, ts.DiagnosticCategory.Error, "Duplicate_property_0_2718", "Duplicate property '{0}'."),
4820         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."),
4821         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?"),
4822         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'."),
4823         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'."),
4824         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'."),
4825         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}'?"),
4826         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}."),
4827         Cannot_find_lib_definition_for_0: diag(2726, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_2726", "Cannot find lib definition for '{0}'."),
4828         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}'?"),
4829         _0_is_declared_here: diag(2728, ts.DiagnosticCategory.Message, "_0_is_declared_here_2728", "'{0}' is declared here."),
4830         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."),
4831         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."),
4832         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(...)'."),
4833         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"),
4834         Property_0_was_also_declared_here: diag(2733, ts.DiagnosticCategory.Error, "Property_0_was_also_declared_here_2733", "Property '{0}' was also declared here."),
4835         Are_you_missing_a_semicolon: diag(2734, ts.DiagnosticCategory.Error, "Are_you_missing_a_semicolon_2734", "Are you missing a semicolon?"),
4836         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}'?"),
4837         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}'."),
4838         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."),
4839         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."),
4840         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}"),
4841         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."),
4842         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}'."),
4843         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."),
4844         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."),
4845         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."),
4846         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."),
4847         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."),
4848         _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}'."),
4849         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."),
4850         _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}'?"),
4851         The_implementation_signature_is_declared_here: diag(2750, ts.DiagnosticCategory.Error, "The_implementation_signature_is_declared_here_2750", "The implementation signature is declared here."),
4852         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."),
4853         The_first_export_default_is_here: diag(2752, ts.DiagnosticCategory.Error, "The_first_export_default_is_here_2752", "The first export default is here."),
4854         Another_export_default_is_here: diag(2753, ts.DiagnosticCategory.Error, "Another_export_default_is_here_2753", "Another export default is here."),
4855         super_may_not_use_type_arguments: diag(2754, ts.DiagnosticCategory.Error, "super_may_not_use_type_arguments_2754", "'super' may not use type arguments."),
4856         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."),
4857         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."),
4858         Type_0_has_no_call_signatures: diag(2757, ts.DiagnosticCategory.Error, "Type_0_has_no_call_signatures_2757", "Type '{0}' has no call signatures."),
4859         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."),
4860         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."),
4861         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."),
4862         Type_0_has_no_construct_signatures: diag(2761, ts.DiagnosticCategory.Error, "Type_0_has_no_construct_signatures_2761", "Type '{0}' has no construct signatures."),
4863         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."),
4864         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}'."),
4865         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}'."),
4866         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}'."),
4867         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}'."),
4868         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."),
4869         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."),
4870         No_overload_matches_this_call: diag(2769, ts.DiagnosticCategory.Error, "No_overload_matches_this_call_2769", "No overload matches this call."),
4871         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."),
4872         The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."),
4873         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."),
4874         Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"),
4875         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?"),
4876         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."),
4877         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."),
4878         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."),
4879         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."),
4880         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."),
4881         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."),
4882         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."),
4883         _0_needs_an_explicit_type_annotation: diag(2782, ts.DiagnosticCategory.Message, "_0_needs_an_explicit_type_annotation_2782", "'{0}' needs an explicit type annotation."),
4884         _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."),
4885         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."),
4886         This_spread_always_overwrites_this_property: diag(2785, ts.DiagnosticCategory.Error, "This_spread_always_overwrites_this_property_2785", "This spread always overwrites this property."),
4887         _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."),
4888         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."),
4889         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."),
4890         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."),
4891         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}'."),
4892         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}'."),
4893         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}'."),
4894         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}'."),
4895         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}'."),
4896         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}'."),
4897         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}'."),
4898         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}'."),
4899         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}'."),
4900         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}'."),
4901         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}'."),
4902         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}'."),
4903         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."),
4904         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}'."),
4905         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}'."),
4906         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."),
4907         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}'."),
4908         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}'."),
4909         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."),
4910         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}'."),
4911         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}'."),
4912         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}'."),
4913         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}'."),
4914         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}'."),
4915         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}'."),
4916         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}'."),
4917         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}'."),
4918         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."),
4919         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}'."),
4920         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}'."),
4921         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."),
4922         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}'."),
4923         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}'."),
4924         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}'."),
4925         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}'."),
4926         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}'."),
4927         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}'."),
4928         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}'."),
4929         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}'."),
4930         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."),
4931         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}'."),
4932         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}'."),
4933         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."),
4934         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}'."),
4935         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}'."),
4936         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}'."),
4937         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}'."),
4938         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."),
4939         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}'."),
4940         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}'."),
4941         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."),
4942         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}'."),
4943         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}'."),
4944         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}'."),
4945         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}'."),
4946         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}'."),
4947         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}'."),
4948         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."),
4949         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}'."),
4950         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}'."),
4951         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."),
4952         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}'."),
4953         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}'."),
4954         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}'."),
4955         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}'."),
4956         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."),
4957         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}'."),
4958         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}'."),
4959         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}'."),
4960         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}'."),
4961         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}'."),
4962         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."),
4963         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}'."),
4964         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}'."),
4965         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."),
4966         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."),
4967         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}'."),
4968         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}'."),
4969         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."),
4970         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}'."),
4971         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}'."),
4972         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}'."),
4973         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}'."),
4974         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}'."),
4975         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}'."),
4976         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."),
4977         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}'."),
4978         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}'."),
4979         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."),
4980         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."),
4981         Tuple_type_arguments_circularly_reference_themselves: diag(4110, ts.DiagnosticCategory.Error, "Tuple_type_arguments_circularly_reference_themselves_4110", "Tuple type arguments circularly reference themselves."),
4982         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."),
4983         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."),
4984         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}'."),
4985         Cannot_read_file_0_Colon_1: diag(5012, ts.DiagnosticCategory.Error, "Cannot_read_file_0_Colon_1_5012", "Cannot read file '{0}': {1}."),
4986         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}."),
4987         Unknown_compiler_option_0: diag(5023, ts.DiagnosticCategory.Error, "Unknown_compiler_option_0_5023", "Unknown compiler option '{0}'."),
4988         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}."),
4989         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}'?"),
4990         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}."),
4991         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."),
4992         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."),
4993         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'."),
4994         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."),
4995         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}'."),
4996         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}'."),
4997         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}'."),
4998         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."),
4999         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."),
5000         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}'."),
5001         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}'."),
5002         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."),
5003         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."),
5004         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."),
5005         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."),
5006         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."),
5007         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}'."),
5008         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}'."),
5009         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."),
5010         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."),
5011         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."),
5012         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}'."),
5013         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."),
5014         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'."),
5015         Unknown_build_option_0: diag(5072, ts.DiagnosticCategory.Error, "Unknown_build_option_0_5072", "Unknown build option '{0}'."),
5016         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}."),
5017         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."),
5018         _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}'."),
5019         _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."),
5020         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}'?"),
5021         Unknown_watch_option_0: diag(5078, ts.DiagnosticCategory.Error, "Unknown_watch_option_0_5078", "Unknown watch option '{0}'."),
5022         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}'?"),
5023         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}."),
5024         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}."),
5025         _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}'."),
5026         Cannot_read_file_0: diag(5083, ts.DiagnosticCategory.Error, "Cannot_read_file_0_5083", "Cannot read file '{0}'."),
5027         The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialized_A_type_annotation_is_necessary: diag(5088, ts.DiagnosticCategory.Error, "The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialize_5088", "The inferred type of '{0}' references a type with a cyclic structure which cannot be trivially serialized. A type annotation is necessary."),
5028         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."),
5029         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."),
5030         Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."),
5031         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."),
5032         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."),
5033         Watch_input_files: diag(6005, ts.DiagnosticCategory.Message, "Watch_input_files_6005", "Watch input files."),
5034         Redirect_output_structure_to_the_directory: diag(6006, ts.DiagnosticCategory.Message, "Redirect_output_structure_to_the_directory_6006", "Redirect output structure to the directory."),
5035         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."),
5036         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."),
5037         Do_not_emit_comments_to_output: diag(6009, ts.DiagnosticCategory.Message, "Do_not_emit_comments_to_output_6009", "Do not emit comments to output."),
5038         Do_not_emit_outputs: diag(6010, ts.DiagnosticCategory.Message, "Do_not_emit_outputs_6010", "Do not emit outputs."),
5039         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."),
5040         Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."),
5041         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."),
5042         Only_emit_d_ts_declaration_files: diag(6014, ts.DiagnosticCategory.Message, "Only_emit_d_ts_declaration_files_6014", "Only emit '.d.ts' declaration files."),
5043         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'."),
5044         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'."),
5045         Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."),
5046         Print_the_compiler_s_version: diag(6019, ts.DiagnosticCategory.Message, "Print_the_compiler_s_version_6019", "Print the compiler's version."),
5047         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'."),
5048         Syntax_Colon_0: diag(6023, ts.DiagnosticCategory.Message, "Syntax_Colon_0_6023", "Syntax: {0}"),
5049         options: diag(6024, ts.DiagnosticCategory.Message, "options_6024", "options"),
5050         file: diag(6025, ts.DiagnosticCategory.Message, "file_6025", "file"),
5051         Examples_Colon_0: diag(6026, ts.DiagnosticCategory.Message, "Examples_Colon_0_6026", "Examples: {0}"),
5052         Options_Colon: diag(6027, ts.DiagnosticCategory.Message, "Options_Colon_6027", "Options:"),
5053         Version_0: diag(6029, ts.DiagnosticCategory.Message, "Version_0_6029", "Version {0}"),
5054         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."),
5055         Starting_compilation_in_watch_mode: diag(6031, ts.DiagnosticCategory.Message, "Starting_compilation_in_watch_mode_6031", "Starting compilation in watch mode..."),
5056         File_change_detected_Starting_incremental_compilation: diag(6032, ts.DiagnosticCategory.Message, "File_change_detected_Starting_incremental_compilation_6032", "File change detected. Starting incremental compilation..."),
5057         KIND: diag(6034, ts.DiagnosticCategory.Message, "KIND_6034", "KIND"),
5058         FILE: diag(6035, ts.DiagnosticCategory.Message, "FILE_6035", "FILE"),
5059         VERSION: diag(6036, ts.DiagnosticCategory.Message, "VERSION_6036", "VERSION"),
5060         LOCATION: diag(6037, ts.DiagnosticCategory.Message, "LOCATION_6037", "LOCATION"),
5061         DIRECTORY: diag(6038, ts.DiagnosticCategory.Message, "DIRECTORY_6038", "DIRECTORY"),
5062         STRATEGY: diag(6039, ts.DiagnosticCategory.Message, "STRATEGY_6039", "STRATEGY"),
5063         FILE_OR_DIRECTORY: diag(6040, ts.DiagnosticCategory.Message, "FILE_OR_DIRECTORY_6040", "FILE OR DIRECTORY"),
5064         Generates_corresponding_map_file: diag(6043, ts.DiagnosticCategory.Message, "Generates_corresponding_map_file_6043", "Generates corresponding '.map' file."),
5065         Compiler_option_0_expects_an_argument: diag(6044, ts.DiagnosticCategory.Error, "Compiler_option_0_expects_an_argument_6044", "Compiler option '{0}' expects an argument."),
5066         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}'."),
5067         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}."),
5068         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}'."),
5069         Unsupported_locale_0: diag(6049, ts.DiagnosticCategory.Error, "Unsupported_locale_0_6049", "Unsupported locale '{0}'."),
5070         Unable_to_open_file_0: diag(6050, ts.DiagnosticCategory.Error, "Unable_to_open_file_0_6050", "Unable to open file '{0}'."),
5071         Corrupted_locale_file_0: diag(6051, ts.DiagnosticCategory.Error, "Corrupted_locale_file_0_6051", "Corrupted locale file {0}."),
5072         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."),
5073         File_0_not_found: diag(6053, ts.DiagnosticCategory.Error, "File_0_not_found_6053", "File '{0}' not found."),
5074         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}."),
5075         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."),
5076         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."),
5077         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."),
5078         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."),
5079         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)."),
5080         NEWLINE: diag(6061, ts.DiagnosticCategory.Message, "NEWLINE_6061", "NEWLINE"),
5081         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."),
5082         Enables_experimental_support_for_ES7_decorators: diag(6065, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_ES7_decorators_6065", "Enables experimental support for ES7 decorators."),
5083         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."),
5084         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."),
5085         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)."),
5086         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."),
5087         Successfully_created_a_tsconfig_json_file: diag(6071, ts.DiagnosticCategory.Message, "Successfully_created_a_tsconfig_json_file_6071", "Successfully created a tsconfig.json file."),
5088         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."),
5089         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)."),
5090         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."),
5091         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."),
5092         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."),
5093         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."),
5094         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."),
5095         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."),
5096         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'."),
5097         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."),
5098         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}."),
5099         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."),
5100         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"),
5101         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."),
5102         Resolving_module_0_from_1: diag(6086, ts.DiagnosticCategory.Message, "Resolving_module_0_from_1_6086", "======== Resolving module '{0}' from '{1}'. ========"),
5103         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}'."),
5104         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}'."),
5105         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}'. ========"),
5106         Module_name_0_was_not_resolved: diag(6090, ts.DiagnosticCategory.Message, "Module_name_0_was_not_resolved_6090", "======== Module name '{0}' was not resolved. ========"),
5107         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}'."),
5108         Module_name_0_matched_pattern_1: diag(6092, ts.DiagnosticCategory.Message, "Module_name_0_matched_pattern_1_6092", "Module name '{0}', matched pattern '{1}'."),
5109         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}'."),
5110         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}'."),
5111         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}'."),
5112         File_0_does_not_exist: diag(6096, ts.DiagnosticCategory.Message, "File_0_does_not_exist_6096", "File '{0}' does not exist."),
5113         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."),
5114         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}'."),
5115         Found_package_json_at_0: diag(6099, ts.DiagnosticCategory.Message, "Found_package_json_at_0_6099", "Found 'package.json' at '{0}'."),
5116         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."),
5117         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}'."),
5118         Allow_javascript_files_to_be_compiled: diag(6102, ts.DiagnosticCategory.Message, "Allow_javascript_files_to_be_compiled_6102", "Allow javascript files to be compiled."),
5119         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."),
5120         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}'."),
5121         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}'."),
5122         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}'."),
5123         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}'."),
5124         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}'."),
5125         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}'."),
5126         Trying_other_entries_in_rootDirs: diag(6110, ts.DiagnosticCategory.Message, "Trying_other_entries_in_rootDirs_6110", "Trying other entries in 'rootDirs'."),
5127         Module_resolution_using_rootDirs_has_failed: diag(6111, ts.DiagnosticCategory.Message, "Module_resolution_using_rootDirs_has_failed_6111", "Module resolution using 'rootDirs' has failed."),
5128         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."),
5129         Enable_strict_null_checks: diag(6113, ts.DiagnosticCategory.Message, "Enable_strict_null_checks_6113", "Enable strict null checks."),
5130         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'?"),
5131         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."),
5132         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}'. ========"),
5133         Resolving_using_primary_search_paths: diag(6117, ts.DiagnosticCategory.Message, "Resolving_using_primary_search_paths_6117", "Resolving using primary search paths..."),
5134         Resolving_from_node_modules_folder: diag(6118, ts.DiagnosticCategory.Message, "Resolving_from_node_modules_folder_6118", "Resolving from node_modules folder..."),
5135         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}. ========"),
5136         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. ========"),
5137         Resolving_with_primary_search_path_0: diag(6121, ts.DiagnosticCategory.Message, "Resolving_with_primary_search_path_0_6121", "Resolving with primary search path '{0}'."),
5138         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."),
5139         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. ========"),
5140         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."),
5141         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}'."),
5142         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."),
5143         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}'. ========"),
5144         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. ========"),
5145         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}'."),
5146         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'."),
5147         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."),
5148         _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),
5149         Report_errors_on_unused_locals: diag(6134, ts.DiagnosticCategory.Message, "Report_errors_on_unused_locals_6134", "Report errors on unused locals."),
5150         Report_errors_on_unused_parameters: diag(6135, ts.DiagnosticCategory.Message, "Report_errors_on_unused_parameters_6135", "Report errors on unused parameters."),
5151         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."),
5152         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}'."),
5153         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),
5154         Import_emit_helpers_from_tslib: diag(6139, ts.DiagnosticCategory.Message, "Import_emit_helpers_from_tslib_6139", "Import emit helpers from 'tslib'."),
5155         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}'."),
5156         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."),
5157         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."),
5158         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}'."),
5159         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."),
5160         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'."),
5161         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}'."),
5162         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."),
5163         Show_diagnostic_information: diag(6149, ts.DiagnosticCategory.Message, "Show_diagnostic_information_6149", "Show diagnostic information."),
5164         Show_verbose_diagnostic_information: diag(6150, ts.DiagnosticCategory.Message, "Show_verbose_diagnostic_information_6150", "Show verbose diagnostic information."),
5165         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."),
5166         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."),
5167         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')."),
5168         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."),
5169         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."),
5170         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')"),
5171         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."),
5172         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)."),
5173         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."),
5174         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."),
5175         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."),
5176         Disable_size_limitations_on_JavaScript_projects: diag(6162, ts.DiagnosticCategory.Message, "Disable_size_limitations_on_JavaScript_projects_6162", "Disable size limitations on JavaScript projects."),
5177         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."),
5178         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."),
5179         Do_not_truncate_error_messages: diag(6165, ts.DiagnosticCategory.Message, "Do_not_truncate_error_messages_6165", "Do not truncate error messages."),
5180         Output_directory_for_generated_declaration_files: diag(6166, ts.DiagnosticCategory.Message, "Output_directory_for_generated_declaration_files_6166", "Output directory for generated declaration files."),
5181         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'."),
5182         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."),
5183         Show_all_compiler_options: diag(6169, ts.DiagnosticCategory.Message, "Show_all_compiler_options_6169", "Show all compiler options."),
5184         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"),
5185         Command_line_Options: diag(6171, ts.DiagnosticCategory.Message, "Command_line_Options_6171", "Command-line Options"),
5186         Basic_Options: diag(6172, ts.DiagnosticCategory.Message, "Basic_Options_6172", "Basic Options"),
5187         Strict_Type_Checking_Options: diag(6173, ts.DiagnosticCategory.Message, "Strict_Type_Checking_Options_6173", "Strict Type-Checking Options"),
5188         Module_Resolution_Options: diag(6174, ts.DiagnosticCategory.Message, "Module_Resolution_Options_6174", "Module Resolution Options"),
5189         Source_Map_Options: diag(6175, ts.DiagnosticCategory.Message, "Source_Map_Options_6175", "Source Map Options"),
5190         Additional_Checks: diag(6176, ts.DiagnosticCategory.Message, "Additional_Checks_6176", "Additional Checks"),
5191         Experimental_Options: diag(6177, ts.DiagnosticCategory.Message, "Experimental_Options_6177", "Experimental Options"),
5192         Advanced_Options: diag(6178, ts.DiagnosticCategory.Message, "Advanced_Options_6178", "Advanced Options"),
5193         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'."),
5194         Enable_all_strict_type_checking_options: diag(6180, ts.DiagnosticCategory.Message, "Enable_all_strict_type_checking_options_6180", "Enable all strict type-checking options."),
5195         List_of_language_service_plugins: diag(6181, ts.DiagnosticCategory.Message, "List_of_language_service_plugins_6181", "List of language service plugins."),
5196         Scoped_package_detected_looking_in_0: diag(6182, ts.DiagnosticCategory.Message, "Scoped_package_detected_looking_in_0_6182", "Scoped package detected, looking in '{0}'"),
5197         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."),
5198         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."),
5199         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."),
5200         Enable_strict_checking_of_function_types: diag(6186, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_function_types_6186", "Enable strict checking of function types."),
5201         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."),
5202         Numeric_separators_are_not_allowed_here: diag(6188, ts.DiagnosticCategory.Error, "Numeric_separators_are_not_allowed_here_6188", "Numeric separators are not allowed here."),
5203         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."),
5204         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."),
5205         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),
5206         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."),
5207         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."),
5208         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)."),
5209         _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),
5210         Include_modules_imported_with_json_extension: diag(6197, ts.DiagnosticCategory.Message, "Include_modules_imported_with_json_extension_6197", "Include modules imported with '.json' extension"),
5211         All_destructured_elements_are_unused: diag(6198, ts.DiagnosticCategory.Error, "All_destructured_elements_are_unused_6198", "All destructured elements are unused.", true),
5212         All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", true),
5213         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}"),
5214         Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."),
5215         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}"),
5216         _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."),
5217         and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."),
5218         All_type_parameters_are_unused: diag(6205, ts.DiagnosticCategory.Error, "All_type_parameters_are_unused_6205", "All type parameters are unused"),
5219         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."),
5220         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}'."),
5221         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}'."),
5222         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."),
5223         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."),
5224         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."),
5225         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?"),
5226         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?"),
5227         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."),
5228         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}'."),
5229         Found_1_error: diag(6216, ts.DiagnosticCategory.Message, "Found_1_error_6216", "Found 1 error."),
5230         Found_0_errors: diag(6217, ts.DiagnosticCategory.Message, "Found_0_errors_6217", "Found {0} errors."),
5231         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}'. ========"),
5232         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}. ========"),
5233         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."),
5234         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."),
5235         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."),
5236         Generates_a_CPU_profile: diag(6223, ts.DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."),
5237         Disable_solution_searching_for_this_project: diag(6224, ts.DiagnosticCategory.Message, "Disable_solution_searching_for_this_project_6224", "Disable solution searching for this project."),
5238         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'."),
5239         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'."),
5240         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'."),
5241         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."),
5242         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}'."),
5243         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."),
5244         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}."),
5245         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."),
5246         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."),
5247         Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"),
5248         Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"),
5249         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."),
5250         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}'."),
5251         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."),
5252         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."),
5253         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"),
5254         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"),
5255         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}'"),
5256         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}'"),
5257         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"),
5258         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"),
5259         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"),
5260         Projects_in_this_build_Colon_0: diag(6355, ts.DiagnosticCategory.Message, "Projects_in_this_build_Colon_0_6355", "Projects in this build: {0}"),
5261         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}"),
5262         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}'"),
5263         Building_project_0: diag(6358, ts.DiagnosticCategory.Message, "Building_project_0_6358", "Building project '{0}'..."),
5264         Updating_output_timestamps_of_project_0: diag(6359, ts.DiagnosticCategory.Message, "Updating_output_timestamps_of_project_0_6359", "Updating output timestamps of project '{0}'..."),
5265         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"),
5266         Project_0_is_up_to_date: diag(6361, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_6361", "Project '{0}' is up to date"),
5267         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"),
5268         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"),
5269         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"),
5270         Delete_the_outputs_of_all_projects: diag(6365, ts.DiagnosticCategory.Message, "Delete_the_outputs_of_all_projects_6365", "Delete the outputs of all projects"),
5271         Enable_verbose_logging: diag(6366, ts.DiagnosticCategory.Message, "Enable_verbose_logging_6366", "Enable verbose logging"),
5272         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')"),
5273         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"),
5274         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."),
5275         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."),
5276         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}'..."),
5277         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"),
5278         Updating_output_of_project_0: diag(6373, ts.DiagnosticCategory.Message, "Updating_output_of_project_0_6373", "Updating output of project '{0}'..."),
5279         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}'"),
5280         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}'"),
5281         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}'"),
5282         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}'"),
5283         Enable_incremental_compilation: diag(6378, ts.DiagnosticCategory.Message, "Enable_incremental_compilation_6378", "Enable incremental compilation"),
5284         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."),
5285         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"),
5286         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}'"),
5287         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"),
5288         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"),
5289         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."),
5290         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}'"),
5291         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."),
5292         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."),
5293         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."),
5294         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?"),
5295         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."),
5296         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."),
5297         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."),
5298         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."),
5299         _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."),
5300         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."),
5301         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."),
5302         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."),
5303         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'."),
5304         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."),
5305         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."),
5306         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."),
5307         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."),
5308         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."),
5309         _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."),
5310         _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."),
5311         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."),
5312         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."),
5313         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."),
5314         Unreachable_code_detected: diag(7027, ts.DiagnosticCategory.Error, "Unreachable_code_detected_7027", "Unreachable code detected.", true),
5315         Unused_label: diag(7028, ts.DiagnosticCategory.Error, "Unused_label_7028", "Unused label.", true),
5316         Fallthrough_case_in_switch: diag(7029, ts.DiagnosticCategory.Error, "Fallthrough_case_in_switch_7029", "Fallthrough case in switch."),
5317         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."),
5318         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."),
5319         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."),
5320         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."),
5321         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."),
5322         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}';`"),
5323         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}'."),
5324         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'."),
5325         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."),
5326         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."),
5327         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}`"),
5328         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'."),
5329         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."),
5330         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."),
5331         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."),
5332         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."),
5333         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."),
5334         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."),
5335         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."),
5336         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."),
5337         _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."),
5338         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}'?"),
5339         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}'?"),
5340         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}'."),
5341         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}'."),
5342         _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."),
5343         You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
5344         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."),
5345         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."),
5346         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."),
5347         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."),
5348         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."),
5349         _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."),
5350         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."),
5351         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."),
5352         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."),
5353         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."),
5354         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."),
5355         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."),
5356         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."),
5357         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}'."),
5358         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}'."),
5359         Report_errors_in_js_files: diag(8019, ts.DiagnosticCategory.Message, "Report_errors_in_js_files_8019", "Report errors in .js files."),
5360         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."),
5361         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."),
5362         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."),
5363         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."),
5364         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."),
5365         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."),
5366         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."),
5367         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."),
5368         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."),
5369         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."),
5370         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."),
5371         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."),
5372         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}'."),
5373         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."),
5374         class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."),
5375         Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."),
5376         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."),
5377         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."),
5378         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'."),
5379         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."),
5380         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}'."),
5381         JSX_attribute_expected: diag(17003, ts.DiagnosticCategory.Error, "JSX_attribute_expected_17003", "JSX attribute expected."),
5382         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."),
5383         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'."),
5384         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."),
5385         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."),
5386         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."),
5387         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."),
5388         Unknown_type_acquisition_option_0: diag(17010, ts.DiagnosticCategory.Error, "Unknown_type_acquisition_option_0_17010", "Unknown type acquisition option '{0}'."),
5389         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."),
5390         _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}'?"),
5391         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."),
5392         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."),
5393         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."),
5394         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"),
5395         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"),
5396         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}'?"),
5397         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}"),
5398         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."),
5399         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."),
5400         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}'."),
5401         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."),
5402         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."),
5403         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."),
5404         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."),
5405         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."),
5406         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."),
5407         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."),
5408         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."),
5409         Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"),
5410         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"),
5411         Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"),
5412         Remove_unused_declaration_for_Colon_0: diag(90004, ts.DiagnosticCategory.Message, "Remove_unused_declaration_for_Colon_0_90004", "Remove unused declaration for: '{0}'"),
5413         Remove_import_from_0: diag(90005, ts.DiagnosticCategory.Message, "Remove_import_from_0_90005", "Remove import from '{0}'"),
5414         Implement_interface_0: diag(90006, ts.DiagnosticCategory.Message, "Implement_interface_0_90006", "Implement interface '{0}'"),
5415         Implement_inherited_abstract_class: diag(90007, ts.DiagnosticCategory.Message, "Implement_inherited_abstract_class_90007", "Implement inherited abstract class"),
5416         Add_0_to_unresolved_variable: diag(90008, ts.DiagnosticCategory.Message, "Add_0_to_unresolved_variable_90008", "Add '{0}.' to unresolved variable"),
5417         Remove_destructuring: diag(90009, ts.DiagnosticCategory.Message, "Remove_destructuring_90009", "Remove destructuring"),
5418         Remove_variable_statement: diag(90010, ts.DiagnosticCategory.Message, "Remove_variable_statement_90010", "Remove variable statement"),
5419         Remove_template_tag: diag(90011, ts.DiagnosticCategory.Message, "Remove_template_tag_90011", "Remove template tag"),
5420         Remove_type_parameters: diag(90012, ts.DiagnosticCategory.Message, "Remove_type_parameters_90012", "Remove type parameters"),
5421         Import_0_from_module_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_module_1_90013", "Import '{0}' from module \"{1}\""),
5422         Change_0_to_1: diag(90014, ts.DiagnosticCategory.Message, "Change_0_to_1_90014", "Change '{0}' to '{1}'"),
5423         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}\""),
5424         Declare_property_0: diag(90016, ts.DiagnosticCategory.Message, "Declare_property_0_90016", "Declare property '{0}'"),
5425         Add_index_signature_for_property_0: diag(90017, ts.DiagnosticCategory.Message, "Add_index_signature_for_property_0_90017", "Add index signature for property '{0}'"),
5426         Disable_checking_for_this_file: diag(90018, ts.DiagnosticCategory.Message, "Disable_checking_for_this_file_90018", "Disable checking for this file"),
5427         Ignore_this_error_message: diag(90019, ts.DiagnosticCategory.Message, "Ignore_this_error_message_90019", "Ignore this error message"),
5428         Initialize_property_0_in_the_constructor: diag(90020, ts.DiagnosticCategory.Message, "Initialize_property_0_in_the_constructor_90020", "Initialize property '{0}' in the constructor"),
5429         Initialize_static_property_0: diag(90021, ts.DiagnosticCategory.Message, "Initialize_static_property_0_90021", "Initialize static property '{0}'"),
5430         Change_spelling_to_0: diag(90022, ts.DiagnosticCategory.Message, "Change_spelling_to_0_90022", "Change spelling to '{0}'"),
5431         Declare_method_0: diag(90023, ts.DiagnosticCategory.Message, "Declare_method_0_90023", "Declare method '{0}'"),
5432         Declare_static_method_0: diag(90024, ts.DiagnosticCategory.Message, "Declare_static_method_0_90024", "Declare static method '{0}'"),
5433         Prefix_0_with_an_underscore: diag(90025, ts.DiagnosticCategory.Message, "Prefix_0_with_an_underscore_90025", "Prefix '{0}' with an underscore"),
5434         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}'"),
5435         Declare_static_property_0: diag(90027, ts.DiagnosticCategory.Message, "Declare_static_property_0_90027", "Declare static property '{0}'"),
5436         Call_decorator_expression: diag(90028, ts.DiagnosticCategory.Message, "Call_decorator_expression_90028", "Call decorator expression"),
5437         Add_async_modifier_to_containing_function: diag(90029, ts.DiagnosticCategory.Message, "Add_async_modifier_to_containing_function_90029", "Add async modifier to containing function"),
5438         Replace_infer_0_with_unknown: diag(90030, ts.DiagnosticCategory.Message, "Replace_infer_0_with_unknown_90030", "Replace 'infer {0}' with 'unknown'"),
5439         Replace_all_unused_infer_with_unknown: diag(90031, ts.DiagnosticCategory.Message, "Replace_all_unused_infer_with_unknown_90031", "Replace all unused 'infer' with 'unknown'"),
5440         Import_default_0_from_module_1: diag(90032, ts.DiagnosticCategory.Message, "Import_default_0_from_module_1_90032", "Import default '{0}' from module \"{1}\""),
5441         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}\""),
5442         Add_parameter_name: diag(90034, ts.DiagnosticCategory.Message, "Add_parameter_name_90034", "Add parameter name"),
5443         Declare_private_property_0: diag(90035, ts.DiagnosticCategory.Message, "Declare_private_property_0_90035", "Declare private property '{0}'"),
5444         Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."),
5445         Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
5446         Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"),
5447         Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
5448         Extract_function: diag(95005, ts.DiagnosticCategory.Message, "Extract_function_95005", "Extract function"),
5449         Extract_constant: diag(95006, ts.DiagnosticCategory.Message, "Extract_constant_95006", "Extract constant"),
5450         Extract_to_0_in_enclosing_scope: diag(95007, ts.DiagnosticCategory.Message, "Extract_to_0_in_enclosing_scope_95007", "Extract to {0} in enclosing scope"),
5451         Extract_to_0_in_1_scope: diag(95008, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_scope_95008", "Extract to {0} in {1} scope"),
5452         Annotate_with_type_from_JSDoc: diag(95009, ts.DiagnosticCategory.Message, "Annotate_with_type_from_JSDoc_95009", "Annotate with type from JSDoc"),
5453         Annotate_with_types_from_JSDoc: diag(95010, ts.DiagnosticCategory.Message, "Annotate_with_types_from_JSDoc_95010", "Annotate with types from JSDoc"),
5454         Infer_type_of_0_from_usage: diag(95011, ts.DiagnosticCategory.Message, "Infer_type_of_0_from_usage_95011", "Infer type of '{0}' from usage"),
5455         Infer_parameter_types_from_usage: diag(95012, ts.DiagnosticCategory.Message, "Infer_parameter_types_from_usage_95012", "Infer parameter types from usage"),
5456         Convert_to_default_import: diag(95013, ts.DiagnosticCategory.Message, "Convert_to_default_import_95013", "Convert to default import"),
5457         Install_0: diag(95014, ts.DiagnosticCategory.Message, "Install_0_95014", "Install '{0}'"),
5458         Replace_import_with_0: diag(95015, ts.DiagnosticCategory.Message, "Replace_import_with_0_95015", "Replace import with '{0}'."),
5459         Use_synthetic_default_member: diag(95016, ts.DiagnosticCategory.Message, "Use_synthetic_default_member_95016", "Use synthetic 'default' member."),
5460         Convert_to_ES6_module: diag(95017, ts.DiagnosticCategory.Message, "Convert_to_ES6_module_95017", "Convert to ES6 module"),
5461         Add_undefined_type_to_property_0: diag(95018, ts.DiagnosticCategory.Message, "Add_undefined_type_to_property_0_95018", "Add 'undefined' type to property '{0}'"),
5462         Add_initializer_to_property_0: diag(95019, ts.DiagnosticCategory.Message, "Add_initializer_to_property_0_95019", "Add initializer to property '{0}'"),
5463         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}'"),
5464         Add_all_missing_members: diag(95022, ts.DiagnosticCategory.Message, "Add_all_missing_members_95022", "Add all missing members"),
5465         Infer_all_types_from_usage: diag(95023, ts.DiagnosticCategory.Message, "Infer_all_types_from_usage_95023", "Infer all types from usage"),
5466         Delete_all_unused_declarations: diag(95024, ts.DiagnosticCategory.Message, "Delete_all_unused_declarations_95024", "Delete all unused declarations"),
5467         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"),
5468         Fix_all_detected_spelling_errors: diag(95026, ts.DiagnosticCategory.Message, "Fix_all_detected_spelling_errors_95026", "Fix all detected spelling errors"),
5469         Add_initializers_to_all_uninitialized_properties: diag(95027, ts.DiagnosticCategory.Message, "Add_initializers_to_all_uninitialized_properties_95027", "Add initializers to all uninitialized properties"),
5470         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"),
5471         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"),
5472         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"),
5473         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)"),
5474         Implement_all_unimplemented_interfaces: diag(95032, ts.DiagnosticCategory.Message, "Implement_all_unimplemented_interfaces_95032", "Implement all unimplemented interfaces"),
5475         Install_all_missing_types_packages: diag(95033, ts.DiagnosticCategory.Message, "Install_all_missing_types_packages_95033", "Install all missing types packages"),
5476         Rewrite_all_as_indexed_access_types: diag(95034, ts.DiagnosticCategory.Message, "Rewrite_all_as_indexed_access_types_95034", "Rewrite all as indexed access types"),
5477         Convert_all_to_default_imports: diag(95035, ts.DiagnosticCategory.Message, "Convert_all_to_default_imports_95035", "Convert all to default imports"),
5478         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"),
5479         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"),
5480         Change_all_extended_interfaces_to_implements: diag(95038, ts.DiagnosticCategory.Message, "Change_all_extended_interfaces_to_implements_95038", "Change all extended interfaces to 'implements'"),
5481         Add_all_missing_super_calls: diag(95039, ts.DiagnosticCategory.Message, "Add_all_missing_super_calls_95039", "Add all missing super calls"),
5482         Implement_all_inherited_abstract_classes: diag(95040, ts.DiagnosticCategory.Message, "Implement_all_inherited_abstract_classes_95040", "Implement all inherited abstract classes"),
5483         Add_all_missing_async_modifiers: diag(95041, ts.DiagnosticCategory.Message, "Add_all_missing_async_modifiers_95041", "Add all missing 'async' modifiers"),
5484         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"),
5485         Annotate_everything_with_types_from_JSDoc: diag(95043, ts.DiagnosticCategory.Message, "Annotate_everything_with_types_from_JSDoc_95043", "Annotate everything with types from JSDoc"),
5486         Add_to_all_uncalled_decorators: diag(95044, ts.DiagnosticCategory.Message, "Add_to_all_uncalled_decorators_95044", "Add '()' to all uncalled decorators"),
5487         Convert_all_constructor_functions_to_classes: diag(95045, ts.DiagnosticCategory.Message, "Convert_all_constructor_functions_to_classes_95045", "Convert all constructor functions to classes"),
5488         Generate_get_and_set_accessors: diag(95046, ts.DiagnosticCategory.Message, "Generate_get_and_set_accessors_95046", "Generate 'get' and 'set' accessors"),
5489         Convert_require_to_import: diag(95047, ts.DiagnosticCategory.Message, "Convert_require_to_import_95047", "Convert 'require' to 'import'"),
5490         Convert_all_require_to_import: diag(95048, ts.DiagnosticCategory.Message, "Convert_all_require_to_import_95048", "Convert all 'require' to 'import'"),
5491         Move_to_a_new_file: diag(95049, ts.DiagnosticCategory.Message, "Move_to_a_new_file_95049", "Move to a new file"),
5492         Remove_unreachable_code: diag(95050, ts.DiagnosticCategory.Message, "Remove_unreachable_code_95050", "Remove unreachable code"),
5493         Remove_all_unreachable_code: diag(95051, ts.DiagnosticCategory.Message, "Remove_all_unreachable_code_95051", "Remove all unreachable code"),
5494         Add_missing_typeof: diag(95052, ts.DiagnosticCategory.Message, "Add_missing_typeof_95052", "Add missing 'typeof'"),
5495         Remove_unused_label: diag(95053, ts.DiagnosticCategory.Message, "Remove_unused_label_95053", "Remove unused label"),
5496         Remove_all_unused_labels: diag(95054, ts.DiagnosticCategory.Message, "Remove_all_unused_labels_95054", "Remove all unused labels"),
5497         Convert_0_to_mapped_object_type: diag(95055, ts.DiagnosticCategory.Message, "Convert_0_to_mapped_object_type_95055", "Convert '{0}' to mapped object type"),
5498         Convert_namespace_import_to_named_imports: diag(95056, ts.DiagnosticCategory.Message, "Convert_namespace_import_to_named_imports_95056", "Convert namespace import to named imports"),
5499         Convert_named_imports_to_namespace_import: diag(95057, ts.DiagnosticCategory.Message, "Convert_named_imports_to_namespace_import_95057", "Convert named imports to namespace import"),
5500         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"),
5501         Add_braces_to_arrow_function: diag(95059, ts.DiagnosticCategory.Message, "Add_braces_to_arrow_function_95059", "Add braces to arrow function"),
5502         Remove_braces_from_arrow_function: diag(95060, ts.DiagnosticCategory.Message, "Remove_braces_from_arrow_function_95060", "Remove braces from arrow function"),
5503         Convert_default_export_to_named_export: diag(95061, ts.DiagnosticCategory.Message, "Convert_default_export_to_named_export_95061", "Convert default export to named export"),
5504         Convert_named_export_to_default_export: diag(95062, ts.DiagnosticCategory.Message, "Convert_named_export_to_default_export_95062", "Convert named export to default export"),
5505         Add_missing_enum_member_0: diag(95063, ts.DiagnosticCategory.Message, "Add_missing_enum_member_0_95063", "Add missing enum member '{0}'"),
5506         Add_all_missing_imports: diag(95064, ts.DiagnosticCategory.Message, "Add_all_missing_imports_95064", "Add all missing imports"),
5507         Convert_to_async_function: diag(95065, ts.DiagnosticCategory.Message, "Convert_to_async_function_95065", "Convert to async function"),
5508         Convert_all_to_async_functions: diag(95066, ts.DiagnosticCategory.Message, "Convert_all_to_async_functions_95066", "Convert all to async functions"),
5509         Add_missing_call_parentheses: diag(95067, ts.DiagnosticCategory.Message, "Add_missing_call_parentheses_95067", "Add missing call parentheses"),
5510         Add_all_missing_call_parentheses: diag(95068, ts.DiagnosticCategory.Message, "Add_all_missing_call_parentheses_95068", "Add all missing call parentheses"),
5511         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"),
5512         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"),
5513         Add_missing_new_operator_to_call: diag(95071, ts.DiagnosticCategory.Message, "Add_missing_new_operator_to_call_95071", "Add missing 'new' operator to call"),
5514         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"),
5515         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"),
5516         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"),
5517         Convert_parameters_to_destructured_object: diag(95075, ts.DiagnosticCategory.Message, "Convert_parameters_to_destructured_object_95075", "Convert parameters to destructured object"),
5518         Allow_accessing_UMD_globals_from_modules: diag(95076, ts.DiagnosticCategory.Message, "Allow_accessing_UMD_globals_from_modules_95076", "Allow accessing UMD globals from modules."),
5519         Extract_type: diag(95077, ts.DiagnosticCategory.Message, "Extract_type_95077", "Extract type"),
5520         Extract_to_type_alias: diag(95078, ts.DiagnosticCategory.Message, "Extract_to_type_alias_95078", "Extract to type alias"),
5521         Extract_to_typedef: diag(95079, ts.DiagnosticCategory.Message, "Extract_to_typedef_95079", "Extract to typedef"),
5522         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"),
5523         Add_const_to_unresolved_variable: diag(95081, ts.DiagnosticCategory.Message, "Add_const_to_unresolved_variable_95081", "Add 'const' to unresolved variable"),
5524         Add_const_to_all_unresolved_variables: diag(95082, ts.DiagnosticCategory.Message, "Add_const_to_all_unresolved_variables_95082", "Add 'const' to all unresolved variables"),
5525         Add_await: diag(95083, ts.DiagnosticCategory.Message, "Add_await_95083", "Add 'await'"),
5526         Add_await_to_initializer_for_0: diag(95084, ts.DiagnosticCategory.Message, "Add_await_to_initializer_for_0_95084", "Add 'await' to initializer for '{0}'"),
5527         Fix_all_expressions_possibly_missing_await: diag(95085, ts.DiagnosticCategory.Message, "Fix_all_expressions_possibly_missing_await_95085", "Fix all expressions possibly missing 'await'"),
5528         Remove_unnecessary_await: diag(95086, ts.DiagnosticCategory.Message, "Remove_unnecessary_await_95086", "Remove unnecessary 'await'"),
5529         Remove_all_unnecessary_uses_of_await: diag(95087, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_uses_of_await_95087", "Remove all unnecessary uses of 'await'"),
5530         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"),
5531         Add_await_to_initializers: diag(95089, ts.DiagnosticCategory.Message, "Add_await_to_initializers_95089", "Add 'await' to initializers"),
5532         Extract_to_interface: diag(95090, ts.DiagnosticCategory.Message, "Extract_to_interface_95090", "Extract to interface"),
5533         Convert_to_a_bigint_numeric_literal: diag(95091, ts.DiagnosticCategory.Message, "Convert_to_a_bigint_numeric_literal_95091", "Convert to a bigint numeric literal"),
5534         Convert_all_to_bigint_numeric_literals: diag(95092, ts.DiagnosticCategory.Message, "Convert_all_to_bigint_numeric_literals_95092", "Convert all to bigint numeric literals"),
5535         Convert_const_to_let: diag(95093, ts.DiagnosticCategory.Message, "Convert_const_to_let_95093", "Convert 'const' to 'let'"),
5536         Prefix_with_declare: diag(95094, ts.DiagnosticCategory.Message, "Prefix_with_declare_95094", "Prefix with 'declare'"),
5537         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'"),
5538         Convert_to_template_string: diag(95096, ts.DiagnosticCategory.Message, "Convert_to_template_string_95096", "Convert to template string"),
5539         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"),
5540         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}'"),
5541         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}'"),
5542         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"),
5543         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"),
5544         Add_class_tag: diag(95102, ts.DiagnosticCategory.Message, "Add_class_tag_95102", "Add '@class' tag"),
5545         Add_this_tag: diag(95103, ts.DiagnosticCategory.Message, "Add_this_tag_95103", "Add '@this' tag"),
5546         Add_this_parameter: diag(95104, ts.DiagnosticCategory.Message, "Add_this_parameter_95104", "Add 'this' parameter."),
5547         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"),
5548         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"),
5549         Fix_all_implicit_this_errors: diag(95107, ts.DiagnosticCategory.Message, "Fix_all_implicit_this_errors_95107", "Fix all implicit-'this' errors"),
5550         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"),
5551         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"),
5552         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"),
5553         Add_a_return_statement: diag(95111, ts.DiagnosticCategory.Message, "Add_a_return_statement_95111", "Add a return statement"),
5554         Remove_block_body_braces: diag(95112, ts.DiagnosticCategory.Message, "Remove_block_body_braces_95112", "Remove block body braces"),
5555         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"),
5556         Add_all_missing_return_statement: diag(95114, ts.DiagnosticCategory.Message, "Add_all_missing_return_statement_95114", "Add all missing return statement"),
5557         Remove_all_incorrect_body_block_braces: diag(95115, ts.DiagnosticCategory.Message, "Remove_all_incorrect_body_block_braces_95115", "Remove all incorrect body block braces"),
5558         Wrap_all_object_literal_with_parentheses: diag(95116, ts.DiagnosticCategory.Message, "Wrap_all_object_literal_with_parentheses_95116", "Wrap all object literal with parentheses"),
5559         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."),
5560         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'."),
5561         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?"),
5562         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"),
5563         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."),
5564         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."),
5565         constructor_is_a_reserved_word: diag(18012, ts.DiagnosticCategory.Error, "constructor_is_a_reserved_word_18012", "'#constructor' is a reserved word."),
5566         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."),
5567         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."),
5568         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}'."),
5569         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."),
5570         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"),
5571         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"),
5572         _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"),
5573         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."),
5574         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."),
5575         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."),
5576         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."),
5577         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."),
5578         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."),
5579         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."),
5580         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."),
5581         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."),
5582         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."),
5583         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."),
5584     };
5585 })(ts || (ts = {}));
5586 var ts;
5587 (function (ts) {
5588     var _a;
5589     function tokenIsIdentifierOrKeyword(token) {
5590         return token >= 75;
5591     }
5592     ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword;
5593     function tokenIsIdentifierOrKeywordOrGreaterThan(token) {
5594         return token === 31 || tokenIsIdentifierOrKeyword(token);
5595     }
5596     ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan;
5597     var textToKeywordObj = (_a = {
5598             abstract: 122,
5599             any: 125,
5600             as: 123,
5601             asserts: 124,
5602             bigint: 151,
5603             boolean: 128,
5604             break: 77,
5605             case: 78,
5606             catch: 79,
5607             class: 80,
5608             continue: 82,
5609             const: 81
5610         },
5611         _a["" + "constructor"] = 129,
5612         _a.debugger = 83,
5613         _a.declare = 130,
5614         _a.default = 84,
5615         _a.delete = 85,
5616         _a.do = 86,
5617         _a.else = 87,
5618         _a.enum = 88,
5619         _a.export = 89,
5620         _a.extends = 90,
5621         _a.false = 91,
5622         _a.finally = 92,
5623         _a.for = 93,
5624         _a.from = 149,
5625         _a.function = 94,
5626         _a.get = 131,
5627         _a.if = 95,
5628         _a.implements = 113,
5629         _a.import = 96,
5630         _a.in = 97,
5631         _a.infer = 132,
5632         _a.instanceof = 98,
5633         _a.interface = 114,
5634         _a.is = 133,
5635         _a.keyof = 134,
5636         _a.let = 115,
5637         _a.module = 135,
5638         _a.namespace = 136,
5639         _a.never = 137,
5640         _a.new = 99,
5641         _a.null = 100,
5642         _a.number = 140,
5643         _a.object = 141,
5644         _a.package = 116,
5645         _a.private = 117,
5646         _a.protected = 118,
5647         _a.public = 119,
5648         _a.readonly = 138,
5649         _a.require = 139,
5650         _a.global = 150,
5651         _a.return = 101,
5652         _a.set = 142,
5653         _a.static = 120,
5654         _a.string = 143,
5655         _a.super = 102,
5656         _a.switch = 103,
5657         _a.symbol = 144,
5658         _a.this = 104,
5659         _a.throw = 105,
5660         _a.true = 106,
5661         _a.try = 107,
5662         _a.type = 145,
5663         _a.typeof = 108,
5664         _a.undefined = 146,
5665         _a.unique = 147,
5666         _a.unknown = 148,
5667         _a.var = 109,
5668         _a.void = 110,
5669         _a.while = 111,
5670         _a.with = 112,
5671         _a.yield = 121,
5672         _a.async = 126,
5673         _a.await = 127,
5674         _a.of = 152,
5675         _a);
5676     var textToKeyword = ts.createMapFromTemplate(textToKeywordObj);
5677     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 }));
5678     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,];
5679     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,];
5680     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,];
5681     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,];
5682     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];
5683     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];
5684     var commentDirectiveRegExSingleLine = /^\s*\/\/\/?\s*@(ts-expect-error|ts-ignore)/;
5685     var commentDirectiveRegExMultiLine = /^\s*(?:\/|\*)*\s*@(ts-expect-error|ts-ignore)/;
5686     function lookupInUnicodeMap(code, map) {
5687         if (code < map[0]) {
5688             return false;
5689         }
5690         var lo = 0;
5691         var hi = map.length;
5692         var mid;
5693         while (lo + 1 < hi) {
5694             mid = lo + (hi - lo) / 2;
5695             mid -= mid % 2;
5696             if (map[mid] <= code && code <= map[mid + 1]) {
5697                 return true;
5698             }
5699             if (code < map[mid]) {
5700                 hi = mid;
5701             }
5702             else {
5703                 lo = mid + 2;
5704             }
5705         }
5706         return false;
5707     }
5708     function isUnicodeIdentifierStart(code, languageVersion) {
5709         return languageVersion >= 2 ?
5710             lookupInUnicodeMap(code, unicodeESNextIdentifierStart) :
5711             languageVersion === 1 ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) :
5712                 lookupInUnicodeMap(code, unicodeES3IdentifierStart);
5713     }
5714     ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart;
5715     function isUnicodeIdentifierPart(code, languageVersion) {
5716         return languageVersion >= 2 ?
5717             lookupInUnicodeMap(code, unicodeESNextIdentifierPart) :
5718             languageVersion === 1 ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) :
5719                 lookupInUnicodeMap(code, unicodeES3IdentifierPart);
5720     }
5721     function makeReverseMap(source) {
5722         var result = [];
5723         source.forEach(function (value, name) {
5724             result[value] = name;
5725         });
5726         return result;
5727     }
5728     var tokenStrings = makeReverseMap(textToToken);
5729     function tokenToString(t) {
5730         return tokenStrings[t];
5731     }
5732     ts.tokenToString = tokenToString;
5733     function stringToToken(s) {
5734         return textToToken.get(s);
5735     }
5736     ts.stringToToken = stringToToken;
5737     function computeLineStarts(text) {
5738         var result = new Array();
5739         var pos = 0;
5740         var lineStart = 0;
5741         while (pos < text.length) {
5742             var ch = text.charCodeAt(pos);
5743             pos++;
5744             switch (ch) {
5745                 case 13:
5746                     if (text.charCodeAt(pos) === 10) {
5747                         pos++;
5748                     }
5749                 case 10:
5750                     result.push(lineStart);
5751                     lineStart = pos;
5752                     break;
5753                 default:
5754                     if (ch > 127 && isLineBreak(ch)) {
5755                         result.push(lineStart);
5756                         lineStart = pos;
5757                     }
5758                     break;
5759             }
5760         }
5761         result.push(lineStart);
5762         return result;
5763     }
5764     ts.computeLineStarts = computeLineStarts;
5765     function getPositionOfLineAndCharacter(sourceFile, line, character, allowEdits) {
5766         return sourceFile.getPositionOfLineAndCharacter ?
5767             sourceFile.getPositionOfLineAndCharacter(line, character, allowEdits) :
5768             computePositionOfLineAndCharacter(getLineStarts(sourceFile), line, character, sourceFile.text, allowEdits);
5769     }
5770     ts.getPositionOfLineAndCharacter = getPositionOfLineAndCharacter;
5771     function computePositionOfLineAndCharacter(lineStarts, line, character, debugText, allowEdits) {
5772         if (line < 0 || line >= lineStarts.length) {
5773             if (allowEdits) {
5774                 line = line < 0 ? 0 : line >= lineStarts.length ? lineStarts.length - 1 : line;
5775             }
5776             else {
5777                 ts.Debug.fail("Bad line number. Line: " + line + ", lineStarts.length: " + lineStarts.length + " , line map is correct? " + (debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown"));
5778             }
5779         }
5780         var res = lineStarts[line] + character;
5781         if (allowEdits) {
5782             return res > lineStarts[line + 1] ? lineStarts[line + 1] : typeof debugText === "string" && res > debugText.length ? debugText.length : res;
5783         }
5784         if (line < lineStarts.length - 1) {
5785             ts.Debug.assert(res < lineStarts[line + 1]);
5786         }
5787         else if (debugText !== undefined) {
5788             ts.Debug.assert(res <= debugText.length);
5789         }
5790         return res;
5791     }
5792     ts.computePositionOfLineAndCharacter = computePositionOfLineAndCharacter;
5793     function getLineStarts(sourceFile) {
5794         return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text));
5795     }
5796     ts.getLineStarts = getLineStarts;
5797     function computeLineAndCharacterOfPosition(lineStarts, position) {
5798         var lineNumber = computeLineOfPosition(lineStarts, position);
5799         return {
5800             line: lineNumber,
5801             character: position - lineStarts[lineNumber]
5802         };
5803     }
5804     ts.computeLineAndCharacterOfPosition = computeLineAndCharacterOfPosition;
5805     function computeLineOfPosition(lineStarts, position, lowerBound) {
5806         var lineNumber = ts.binarySearch(lineStarts, position, ts.identity, ts.compareValues, lowerBound);
5807         if (lineNumber < 0) {
5808             lineNumber = ~lineNumber - 1;
5809             ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file");
5810         }
5811         return lineNumber;
5812     }
5813     ts.computeLineOfPosition = computeLineOfPosition;
5814     function getLinesBetweenPositions(sourceFile, pos1, pos2) {
5815         if (pos1 === pos2)
5816             return 0;
5817         var lineStarts = getLineStarts(sourceFile);
5818         var lower = Math.min(pos1, pos2);
5819         var isNegative = lower === pos2;
5820         var upper = isNegative ? pos1 : pos2;
5821         var lowerLine = computeLineOfPosition(lineStarts, lower);
5822         var upperLine = computeLineOfPosition(lineStarts, upper, lowerLine);
5823         return isNegative ? lowerLine - upperLine : upperLine - lowerLine;
5824     }
5825     ts.getLinesBetweenPositions = getLinesBetweenPositions;
5826     function getLineAndCharacterOfPosition(sourceFile, position) {
5827         return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position);
5828     }
5829     ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition;
5830     function isWhiteSpaceLike(ch) {
5831         return isWhiteSpaceSingleLine(ch) || isLineBreak(ch);
5832     }
5833     ts.isWhiteSpaceLike = isWhiteSpaceLike;
5834     function isWhiteSpaceSingleLine(ch) {
5835         return ch === 32 ||
5836             ch === 9 ||
5837             ch === 11 ||
5838             ch === 12 ||
5839             ch === 160 ||
5840             ch === 133 ||
5841             ch === 5760 ||
5842             ch >= 8192 && ch <= 8203 ||
5843             ch === 8239 ||
5844             ch === 8287 ||
5845             ch === 12288 ||
5846             ch === 65279;
5847     }
5848     ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine;
5849     function isLineBreak(ch) {
5850         return ch === 10 ||
5851             ch === 13 ||
5852             ch === 8232 ||
5853             ch === 8233;
5854     }
5855     ts.isLineBreak = isLineBreak;
5856     function isDigit(ch) {
5857         return ch >= 48 && ch <= 57;
5858     }
5859     function isHexDigit(ch) {
5860         return isDigit(ch) || ch >= 65 && ch <= 70 || ch >= 97 && ch <= 102;
5861     }
5862     function isCodePoint(code) {
5863         return code <= 0x10FFFF;
5864     }
5865     function isOctalDigit(ch) {
5866         return ch >= 48 && ch <= 55;
5867     }
5868     ts.isOctalDigit = isOctalDigit;
5869     function couldStartTrivia(text, pos) {
5870         var ch = text.charCodeAt(pos);
5871         switch (ch) {
5872             case 13:
5873             case 10:
5874             case 9:
5875             case 11:
5876             case 12:
5877             case 32:
5878             case 47:
5879             case 60:
5880             case 124:
5881             case 61:
5882             case 62:
5883                 return true;
5884             case 35:
5885                 return pos === 0;
5886             default:
5887                 return ch > 127;
5888         }
5889     }
5890     ts.couldStartTrivia = couldStartTrivia;
5891     function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments) {
5892         if (stopAtComments === void 0) { stopAtComments = false; }
5893         if (ts.positionIsSynthesized(pos)) {
5894             return pos;
5895         }
5896         while (true) {
5897             var ch = text.charCodeAt(pos);
5898             switch (ch) {
5899                 case 13:
5900                     if (text.charCodeAt(pos + 1) === 10) {
5901                         pos++;
5902                     }
5903                 case 10:
5904                     pos++;
5905                     if (stopAfterLineBreak) {
5906                         return pos;
5907                     }
5908                     continue;
5909                 case 9:
5910                 case 11:
5911                 case 12:
5912                 case 32:
5913                     pos++;
5914                     continue;
5915                 case 47:
5916                     if (stopAtComments) {
5917                         break;
5918                     }
5919                     if (text.charCodeAt(pos + 1) === 47) {
5920                         pos += 2;
5921                         while (pos < text.length) {
5922                             if (isLineBreak(text.charCodeAt(pos))) {
5923                                 break;
5924                             }
5925                             pos++;
5926                         }
5927                         continue;
5928                     }
5929                     if (text.charCodeAt(pos + 1) === 42) {
5930                         pos += 2;
5931                         while (pos < text.length) {
5932                             if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) {
5933                                 pos += 2;
5934                                 break;
5935                             }
5936                             pos++;
5937                         }
5938                         continue;
5939                     }
5940                     break;
5941                 case 60:
5942                 case 124:
5943                 case 61:
5944                 case 62:
5945                     if (isConflictMarkerTrivia(text, pos)) {
5946                         pos = scanConflictMarkerTrivia(text, pos);
5947                         continue;
5948                     }
5949                     break;
5950                 case 35:
5951                     if (pos === 0 && isShebangTrivia(text, pos)) {
5952                         pos = scanShebangTrivia(text, pos);
5953                         continue;
5954                     }
5955                     break;
5956                 default:
5957                     if (ch > 127 && (isWhiteSpaceLike(ch))) {
5958                         pos++;
5959                         continue;
5960                     }
5961                     break;
5962             }
5963             return pos;
5964         }
5965     }
5966     ts.skipTrivia = skipTrivia;
5967     var mergeConflictMarkerLength = "<<<<<<<".length;
5968     function isConflictMarkerTrivia(text, pos) {
5969         ts.Debug.assert(pos >= 0);
5970         if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) {
5971             var ch = text.charCodeAt(pos);
5972             if ((pos + mergeConflictMarkerLength) < text.length) {
5973                 for (var i = 0; i < mergeConflictMarkerLength; i++) {
5974                     if (text.charCodeAt(pos + i) !== ch) {
5975                         return false;
5976                     }
5977                 }
5978                 return ch === 61 ||
5979                     text.charCodeAt(pos + mergeConflictMarkerLength) === 32;
5980             }
5981         }
5982         return false;
5983     }
5984     function scanConflictMarkerTrivia(text, pos, error) {
5985         if (error) {
5986             error(ts.Diagnostics.Merge_conflict_marker_encountered, pos, mergeConflictMarkerLength);
5987         }
5988         var ch = text.charCodeAt(pos);
5989         var len = text.length;
5990         if (ch === 60 || ch === 62) {
5991             while (pos < len && !isLineBreak(text.charCodeAt(pos))) {
5992                 pos++;
5993             }
5994         }
5995         else {
5996             ts.Debug.assert(ch === 124 || ch === 61);
5997             while (pos < len) {
5998                 var currentChar = text.charCodeAt(pos);
5999                 if ((currentChar === 61 || currentChar === 62) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) {
6000                     break;
6001                 }
6002                 pos++;
6003             }
6004         }
6005         return pos;
6006     }
6007     var shebangTriviaRegex = /^#!.*/;
6008     function isShebangTrivia(text, pos) {
6009         ts.Debug.assert(pos === 0);
6010         return shebangTriviaRegex.test(text);
6011     }
6012     ts.isShebangTrivia = isShebangTrivia;
6013     function scanShebangTrivia(text, pos) {
6014         var shebang = shebangTriviaRegex.exec(text)[0];
6015         pos = pos + shebang.length;
6016         return pos;
6017     }
6018     ts.scanShebangTrivia = scanShebangTrivia;
6019     function iterateCommentRanges(reduce, text, pos, trailing, cb, state, initial) {
6020         var pendingPos;
6021         var pendingEnd;
6022         var pendingKind;
6023         var pendingHasTrailingNewLine;
6024         var hasPendingCommentRange = false;
6025         var collecting = trailing;
6026         var accumulator = initial;
6027         if (pos === 0) {
6028             collecting = true;
6029             var shebang = getShebang(text);
6030             if (shebang) {
6031                 pos = shebang.length;
6032             }
6033         }
6034         scan: while (pos >= 0 && pos < text.length) {
6035             var ch = text.charCodeAt(pos);
6036             switch (ch) {
6037                 case 13:
6038                     if (text.charCodeAt(pos + 1) === 10) {
6039                         pos++;
6040                     }
6041                 case 10:
6042                     pos++;
6043                     if (trailing) {
6044                         break scan;
6045                     }
6046                     collecting = true;
6047                     if (hasPendingCommentRange) {
6048                         pendingHasTrailingNewLine = true;
6049                     }
6050                     continue;
6051                 case 9:
6052                 case 11:
6053                 case 12:
6054                 case 32:
6055                     pos++;
6056                     continue;
6057                 case 47:
6058                     var nextChar = text.charCodeAt(pos + 1);
6059                     var hasTrailingNewLine = false;
6060                     if (nextChar === 47 || nextChar === 42) {
6061                         var kind = nextChar === 47 ? 2 : 3;
6062                         var startPos = pos;
6063                         pos += 2;
6064                         if (nextChar === 47) {
6065                             while (pos < text.length) {
6066                                 if (isLineBreak(text.charCodeAt(pos))) {
6067                                     hasTrailingNewLine = true;
6068                                     break;
6069                                 }
6070                                 pos++;
6071                             }
6072                         }
6073                         else {
6074                             while (pos < text.length) {
6075                                 if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) {
6076                                     pos += 2;
6077                                     break;
6078                                 }
6079                                 pos++;
6080                             }
6081                         }
6082                         if (collecting) {
6083                             if (hasPendingCommentRange) {
6084                                 accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator);
6085                                 if (!reduce && accumulator) {
6086                                     return accumulator;
6087                                 }
6088                             }
6089                             pendingPos = startPos;
6090                             pendingEnd = pos;
6091                             pendingKind = kind;
6092                             pendingHasTrailingNewLine = hasTrailingNewLine;
6093                             hasPendingCommentRange = true;
6094                         }
6095                         continue;
6096                     }
6097                     break scan;
6098                 default:
6099                     if (ch > 127 && (isWhiteSpaceLike(ch))) {
6100                         if (hasPendingCommentRange && isLineBreak(ch)) {
6101                             pendingHasTrailingNewLine = true;
6102                         }
6103                         pos++;
6104                         continue;
6105                     }
6106                     break scan;
6107             }
6108         }
6109         if (hasPendingCommentRange) {
6110             accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator);
6111         }
6112         return accumulator;
6113     }
6114     function forEachLeadingCommentRange(text, pos, cb, state) {
6115         return iterateCommentRanges(false, text, pos, false, cb, state);
6116     }
6117     ts.forEachLeadingCommentRange = forEachLeadingCommentRange;
6118     function forEachTrailingCommentRange(text, pos, cb, state) {
6119         return iterateCommentRanges(false, text, pos, true, cb, state);
6120     }
6121     ts.forEachTrailingCommentRange = forEachTrailingCommentRange;
6122     function reduceEachLeadingCommentRange(text, pos, cb, state, initial) {
6123         return iterateCommentRanges(true, text, pos, false, cb, state, initial);
6124     }
6125     ts.reduceEachLeadingCommentRange = reduceEachLeadingCommentRange;
6126     function reduceEachTrailingCommentRange(text, pos, cb, state, initial) {
6127         return iterateCommentRanges(true, text, pos, true, cb, state, initial);
6128     }
6129     ts.reduceEachTrailingCommentRange = reduceEachTrailingCommentRange;
6130     function appendCommentRange(pos, end, kind, hasTrailingNewLine, _state, comments) {
6131         if (!comments) {
6132             comments = [];
6133         }
6134         comments.push({ kind: kind, pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine });
6135         return comments;
6136     }
6137     function getLeadingCommentRanges(text, pos) {
6138         return reduceEachLeadingCommentRange(text, pos, appendCommentRange, undefined, undefined);
6139     }
6140     ts.getLeadingCommentRanges = getLeadingCommentRanges;
6141     function getTrailingCommentRanges(text, pos) {
6142         return reduceEachTrailingCommentRange(text, pos, appendCommentRange, undefined, undefined);
6143     }
6144     ts.getTrailingCommentRanges = getTrailingCommentRanges;
6145     function getShebang(text) {
6146         var match = shebangTriviaRegex.exec(text);
6147         if (match) {
6148             return match[0];
6149         }
6150     }
6151     ts.getShebang = getShebang;
6152     function isIdentifierStart(ch, languageVersion) {
6153         return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 ||
6154             ch === 36 || ch === 95 ||
6155             ch > 127 && isUnicodeIdentifierStart(ch, languageVersion);
6156     }
6157     ts.isIdentifierStart = isIdentifierStart;
6158     function isIdentifierPart(ch, languageVersion, identifierVariant) {
6159         return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 ||
6160             ch >= 48 && ch <= 57 || ch === 36 || ch === 95 ||
6161             (identifierVariant === 1 ? (ch === 45 || ch === 58) : false) ||
6162             ch > 127 && isUnicodeIdentifierPart(ch, languageVersion);
6163     }
6164     ts.isIdentifierPart = isIdentifierPart;
6165     function isIdentifierText(name, languageVersion, identifierVariant) {
6166         var ch = codePointAt(name, 0);
6167         if (!isIdentifierStart(ch, languageVersion)) {
6168             return false;
6169         }
6170         for (var i = charSize(ch); i < name.length; i += charSize(ch)) {
6171             if (!isIdentifierPart(ch = codePointAt(name, i), languageVersion, identifierVariant)) {
6172                 return false;
6173             }
6174         }
6175         return true;
6176     }
6177     ts.isIdentifierText = isIdentifierText;
6178     function createScanner(languageVersion, skipTrivia, languageVariant, textInitial, onError, start, length) {
6179         if (languageVariant === void 0) { languageVariant = 0; }
6180         var text = textInitial;
6181         var pos;
6182         var end;
6183         var startPos;
6184         var tokenPos;
6185         var token;
6186         var tokenValue;
6187         var tokenFlags;
6188         var commentDirectives;
6189         var inJSDocType = 0;
6190         setText(text, start, length);
6191         var scanner = {
6192             getStartPos: function () { return startPos; },
6193             getTextPos: function () { return pos; },
6194             getToken: function () { return token; },
6195             getTokenPos: function () { return tokenPos; },
6196             getTokenText: function () { return text.substring(tokenPos, pos); },
6197             getTokenValue: function () { return tokenValue; },
6198             hasUnicodeEscape: function () { return (tokenFlags & 1024) !== 0; },
6199             hasExtendedUnicodeEscape: function () { return (tokenFlags & 8) !== 0; },
6200             hasPrecedingLineBreak: function () { return (tokenFlags & 1) !== 0; },
6201             isIdentifier: function () { return token === 75 || token > 112; },
6202             isReservedWord: function () { return token >= 77 && token <= 112; },
6203             isUnterminated: function () { return (tokenFlags & 4) !== 0; },
6204             getCommentDirectives: function () { return commentDirectives; },
6205             getTokenFlags: function () { return tokenFlags; },
6206             reScanGreaterToken: reScanGreaterToken,
6207             reScanSlashToken: reScanSlashToken,
6208             reScanTemplateToken: reScanTemplateToken,
6209             reScanTemplateHeadOrNoSubstitutionTemplate: reScanTemplateHeadOrNoSubstitutionTemplate,
6210             scanJsxIdentifier: scanJsxIdentifier,
6211             scanJsxAttributeValue: scanJsxAttributeValue,
6212             reScanJsxAttributeValue: reScanJsxAttributeValue,
6213             reScanJsxToken: reScanJsxToken,
6214             reScanLessThanToken: reScanLessThanToken,
6215             reScanQuestionToken: reScanQuestionToken,
6216             scanJsxToken: scanJsxToken,
6217             scanJsDocToken: scanJsDocToken,
6218             scan: scan,
6219             getText: getText,
6220             clearCommentDirectives: clearCommentDirectives,
6221             setText: setText,
6222             setScriptTarget: setScriptTarget,
6223             setLanguageVariant: setLanguageVariant,
6224             setOnError: setOnError,
6225             setTextPos: setTextPos,
6226             setInJSDocType: setInJSDocType,
6227             tryScan: tryScan,
6228             lookAhead: lookAhead,
6229             scanRange: scanRange,
6230         };
6231         if (ts.Debug.isDebugging) {
6232             Object.defineProperty(scanner, "__debugShowCurrentPositionInText", {
6233                 get: function () {
6234                     var text = scanner.getText();
6235                     return text.slice(0, scanner.getStartPos()) + "â•‘" + text.slice(scanner.getStartPos());
6236                 },
6237             });
6238         }
6239         return scanner;
6240         function error(message, errPos, length) {
6241             if (errPos === void 0) { errPos = pos; }
6242             if (onError) {
6243                 var oldPos = pos;
6244                 pos = errPos;
6245                 onError(message, length || 0);
6246                 pos = oldPos;
6247             }
6248         }
6249         function scanNumberFragment() {
6250             var start = pos;
6251             var allowSeparator = false;
6252             var isPreviousTokenSeparator = false;
6253             var result = "";
6254             while (true) {
6255                 var ch = text.charCodeAt(pos);
6256                 if (ch === 95) {
6257                     tokenFlags |= 512;
6258                     if (allowSeparator) {
6259                         allowSeparator = false;
6260                         isPreviousTokenSeparator = true;
6261                         result += text.substring(start, pos);
6262                     }
6263                     else if (isPreviousTokenSeparator) {
6264                         error(ts.Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
6265                     }
6266                     else {
6267                         error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
6268                     }
6269                     pos++;
6270                     start = pos;
6271                     continue;
6272                 }
6273                 if (isDigit(ch)) {
6274                     allowSeparator = true;
6275                     isPreviousTokenSeparator = false;
6276                     pos++;
6277                     continue;
6278                 }
6279                 break;
6280             }
6281             if (text.charCodeAt(pos - 1) === 95) {
6282                 error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
6283             }
6284             return result + text.substring(start, pos);
6285         }
6286         function scanNumber() {
6287             var start = pos;
6288             var mainFragment = scanNumberFragment();
6289             var decimalFragment;
6290             var scientificFragment;
6291             if (text.charCodeAt(pos) === 46) {
6292                 pos++;
6293                 decimalFragment = scanNumberFragment();
6294             }
6295             var end = pos;
6296             if (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101) {
6297                 pos++;
6298                 tokenFlags |= 16;
6299                 if (text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45)
6300                     pos++;
6301                 var preNumericPart = pos;
6302                 var finalFragment = scanNumberFragment();
6303                 if (!finalFragment) {
6304                     error(ts.Diagnostics.Digit_expected);
6305                 }
6306                 else {
6307                     scientificFragment = text.substring(end, preNumericPart) + finalFragment;
6308                     end = pos;
6309                 }
6310             }
6311             var result;
6312             if (tokenFlags & 512) {
6313                 result = mainFragment;
6314                 if (decimalFragment) {
6315                     result += "." + decimalFragment;
6316                 }
6317                 if (scientificFragment) {
6318                     result += scientificFragment;
6319                 }
6320             }
6321             else {
6322                 result = text.substring(start, end);
6323             }
6324             if (decimalFragment !== undefined || tokenFlags & 16) {
6325                 checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16));
6326                 return {
6327                     type: 8,
6328                     value: "" + +result
6329                 };
6330             }
6331             else {
6332                 tokenValue = result;
6333                 var type = checkBigIntSuffix();
6334                 checkForIdentifierStartAfterNumericLiteral(start);
6335                 return { type: type, value: tokenValue };
6336             }
6337         }
6338         function checkForIdentifierStartAfterNumericLiteral(numericStart, isScientific) {
6339             if (!isIdentifierStart(codePointAt(text, pos), languageVersion)) {
6340                 return;
6341             }
6342             var identifierStart = pos;
6343             var length = scanIdentifierParts().length;
6344             if (length === 1 && text[identifierStart] === "n") {
6345                 if (isScientific) {
6346                     error(ts.Diagnostics.A_bigint_literal_cannot_use_exponential_notation, numericStart, identifierStart - numericStart + 1);
6347                 }
6348                 else {
6349                     error(ts.Diagnostics.A_bigint_literal_must_be_an_integer, numericStart, identifierStart - numericStart + 1);
6350                 }
6351             }
6352             else {
6353                 error(ts.Diagnostics.An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal, identifierStart, length);
6354                 pos = identifierStart;
6355             }
6356         }
6357         function scanOctalDigits() {
6358             var start = pos;
6359             while (isOctalDigit(text.charCodeAt(pos))) {
6360                 pos++;
6361             }
6362             return +(text.substring(start, pos));
6363         }
6364         function scanExactNumberOfHexDigits(count, canHaveSeparators) {
6365             var valueString = scanHexDigits(count, false, canHaveSeparators);
6366             return valueString ? parseInt(valueString, 16) : -1;
6367         }
6368         function scanMinimumNumberOfHexDigits(count, canHaveSeparators) {
6369             return scanHexDigits(count, true, canHaveSeparators);
6370         }
6371         function scanHexDigits(minCount, scanAsManyAsPossible, canHaveSeparators) {
6372             var valueChars = [];
6373             var allowSeparator = false;
6374             var isPreviousTokenSeparator = false;
6375             while (valueChars.length < minCount || scanAsManyAsPossible) {
6376                 var ch = text.charCodeAt(pos);
6377                 if (canHaveSeparators && ch === 95) {
6378                     tokenFlags |= 512;
6379                     if (allowSeparator) {
6380                         allowSeparator = false;
6381                         isPreviousTokenSeparator = true;
6382                     }
6383                     else if (isPreviousTokenSeparator) {
6384                         error(ts.Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
6385                     }
6386                     else {
6387                         error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
6388                     }
6389                     pos++;
6390                     continue;
6391                 }
6392                 allowSeparator = canHaveSeparators;
6393                 if (ch >= 65 && ch <= 70) {
6394                     ch += 97 - 65;
6395                 }
6396                 else if (!((ch >= 48 && ch <= 57) ||
6397                     (ch >= 97 && ch <= 102))) {
6398                     break;
6399                 }
6400                 valueChars.push(ch);
6401                 pos++;
6402                 isPreviousTokenSeparator = false;
6403             }
6404             if (valueChars.length < minCount) {
6405                 valueChars = [];
6406             }
6407             if (text.charCodeAt(pos - 1) === 95) {
6408                 error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
6409             }
6410             return String.fromCharCode.apply(String, valueChars);
6411         }
6412         function scanString(jsxAttributeString) {
6413             if (jsxAttributeString === void 0) { jsxAttributeString = false; }
6414             var quote = text.charCodeAt(pos);
6415             pos++;
6416             var result = "";
6417             var start = pos;
6418             while (true) {
6419                 if (pos >= end) {
6420                     result += text.substring(start, pos);
6421                     tokenFlags |= 4;
6422                     error(ts.Diagnostics.Unterminated_string_literal);
6423                     break;
6424                 }
6425                 var ch = text.charCodeAt(pos);
6426                 if (ch === quote) {
6427                     result += text.substring(start, pos);
6428                     pos++;
6429                     break;
6430                 }
6431                 if (ch === 92 && !jsxAttributeString) {
6432                     result += text.substring(start, pos);
6433                     result += scanEscapeSequence();
6434                     start = pos;
6435                     continue;
6436                 }
6437                 if (isLineBreak(ch) && !jsxAttributeString) {
6438                     result += text.substring(start, pos);
6439                     tokenFlags |= 4;
6440                     error(ts.Diagnostics.Unterminated_string_literal);
6441                     break;
6442                 }
6443                 pos++;
6444             }
6445             return result;
6446         }
6447         function scanTemplateAndSetTokenValue(isTaggedTemplate) {
6448             var startedWithBacktick = text.charCodeAt(pos) === 96;
6449             pos++;
6450             var start = pos;
6451             var contents = "";
6452             var resultingToken;
6453             while (true) {
6454                 if (pos >= end) {
6455                     contents += text.substring(start, pos);
6456                     tokenFlags |= 4;
6457                     error(ts.Diagnostics.Unterminated_template_literal);
6458                     resultingToken = startedWithBacktick ? 14 : 17;
6459                     break;
6460                 }
6461                 var currChar = text.charCodeAt(pos);
6462                 if (currChar === 96) {
6463                     contents += text.substring(start, pos);
6464                     pos++;
6465                     resultingToken = startedWithBacktick ? 14 : 17;
6466                     break;
6467                 }
6468                 if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) {
6469                     contents += text.substring(start, pos);
6470                     pos += 2;
6471                     resultingToken = startedWithBacktick ? 15 : 16;
6472                     break;
6473                 }
6474                 if (currChar === 92) {
6475                     contents += text.substring(start, pos);
6476                     contents += scanEscapeSequence(isTaggedTemplate);
6477                     start = pos;
6478                     continue;
6479                 }
6480                 if (currChar === 13) {
6481                     contents += text.substring(start, pos);
6482                     pos++;
6483                     if (pos < end && text.charCodeAt(pos) === 10) {
6484                         pos++;
6485                     }
6486                     contents += "\n";
6487                     start = pos;
6488                     continue;
6489                 }
6490                 pos++;
6491             }
6492             ts.Debug.assert(resultingToken !== undefined);
6493             tokenValue = contents;
6494             return resultingToken;
6495         }
6496         function scanEscapeSequence(isTaggedTemplate) {
6497             var start = pos;
6498             pos++;
6499             if (pos >= end) {
6500                 error(ts.Diagnostics.Unexpected_end_of_text);
6501                 return "";
6502             }
6503             var ch = text.charCodeAt(pos);
6504             pos++;
6505             switch (ch) {
6506                 case 48:
6507                     if (isTaggedTemplate && pos < end && isDigit(text.charCodeAt(pos))) {
6508                         pos++;
6509                         tokenFlags |= 2048;
6510                         return text.substring(start, pos);
6511                     }
6512                     return "\0";
6513                 case 98:
6514                     return "\b";
6515                 case 116:
6516                     return "\t";
6517                 case 110:
6518                     return "\n";
6519                 case 118:
6520                     return "\v";
6521                 case 102:
6522                     return "\f";
6523                 case 114:
6524                     return "\r";
6525                 case 39:
6526                     return "\'";
6527                 case 34:
6528                     return "\"";
6529                 case 117:
6530                     if (isTaggedTemplate) {
6531                         for (var escapePos = pos; escapePos < pos + 4; escapePos++) {
6532                             if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123) {
6533                                 pos = escapePos;
6534                                 tokenFlags |= 2048;
6535                                 return text.substring(start, pos);
6536                             }
6537                         }
6538                     }
6539                     if (pos < end && text.charCodeAt(pos) === 123) {
6540                         pos++;
6541                         if (isTaggedTemplate && !isHexDigit(text.charCodeAt(pos))) {
6542                             tokenFlags |= 2048;
6543                             return text.substring(start, pos);
6544                         }
6545                         if (isTaggedTemplate) {
6546                             var savePos = pos;
6547                             var escapedValueString = scanMinimumNumberOfHexDigits(1, false);
6548                             var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
6549                             if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125) {
6550                                 tokenFlags |= 2048;
6551                                 return text.substring(start, pos);
6552                             }
6553                             else {
6554                                 pos = savePos;
6555                             }
6556                         }
6557                         tokenFlags |= 8;
6558                         return scanExtendedUnicodeEscape();
6559                     }
6560                     tokenFlags |= 1024;
6561                     return scanHexadecimalEscape(4);
6562                 case 120:
6563                     if (isTaggedTemplate) {
6564                         if (!isHexDigit(text.charCodeAt(pos))) {
6565                             tokenFlags |= 2048;
6566                             return text.substring(start, pos);
6567                         }
6568                         else if (!isHexDigit(text.charCodeAt(pos + 1))) {
6569                             pos++;
6570                             tokenFlags |= 2048;
6571                             return text.substring(start, pos);
6572                         }
6573                     }
6574                     return scanHexadecimalEscape(2);
6575                 case 13:
6576                     if (pos < end && text.charCodeAt(pos) === 10) {
6577                         pos++;
6578                     }
6579                 case 10:
6580                 case 8232:
6581                 case 8233:
6582                     return "";
6583                 default:
6584                     return String.fromCharCode(ch);
6585             }
6586         }
6587         function scanHexadecimalEscape(numDigits) {
6588             var escapedValue = scanExactNumberOfHexDigits(numDigits, false);
6589             if (escapedValue >= 0) {
6590                 return String.fromCharCode(escapedValue);
6591             }
6592             else {
6593                 error(ts.Diagnostics.Hexadecimal_digit_expected);
6594                 return "";
6595             }
6596         }
6597         function scanExtendedUnicodeEscape() {
6598             var escapedValueString = scanMinimumNumberOfHexDigits(1, false);
6599             var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
6600             var isInvalidExtendedEscape = false;
6601             if (escapedValue < 0) {
6602                 error(ts.Diagnostics.Hexadecimal_digit_expected);
6603                 isInvalidExtendedEscape = true;
6604             }
6605             else if (escapedValue > 0x10FFFF) {
6606                 error(ts.Diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive);
6607                 isInvalidExtendedEscape = true;
6608             }
6609             if (pos >= end) {
6610                 error(ts.Diagnostics.Unexpected_end_of_text);
6611                 isInvalidExtendedEscape = true;
6612             }
6613             else if (text.charCodeAt(pos) === 125) {
6614                 pos++;
6615             }
6616             else {
6617                 error(ts.Diagnostics.Unterminated_Unicode_escape_sequence);
6618                 isInvalidExtendedEscape = true;
6619             }
6620             if (isInvalidExtendedEscape) {
6621                 return "";
6622             }
6623             return utf16EncodeAsString(escapedValue);
6624         }
6625         function peekUnicodeEscape() {
6626             if (pos + 5 < end && text.charCodeAt(pos + 1) === 117) {
6627                 var start_1 = pos;
6628                 pos += 2;
6629                 var value = scanExactNumberOfHexDigits(4, false);
6630                 pos = start_1;
6631                 return value;
6632             }
6633             return -1;
6634         }
6635         function peekExtendedUnicodeEscape() {
6636             if (languageVersion >= 2 && codePointAt(text, pos + 1) === 117 && codePointAt(text, pos + 2) === 123) {
6637                 var start_2 = pos;
6638                 pos += 3;
6639                 var escapedValueString = scanMinimumNumberOfHexDigits(1, false);
6640                 var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
6641                 pos = start_2;
6642                 return escapedValue;
6643             }
6644             return -1;
6645         }
6646         function scanIdentifierParts() {
6647             var result = "";
6648             var start = pos;
6649             while (pos < end) {
6650                 var ch = codePointAt(text, pos);
6651                 if (isIdentifierPart(ch, languageVersion)) {
6652                     pos += charSize(ch);
6653                 }
6654                 else if (ch === 92) {
6655                     ch = peekExtendedUnicodeEscape();
6656                     if (ch >= 0 && isIdentifierPart(ch, languageVersion)) {
6657                         pos += 3;
6658                         tokenFlags |= 8;
6659                         result += scanExtendedUnicodeEscape();
6660                         start = pos;
6661                         continue;
6662                     }
6663                     ch = peekUnicodeEscape();
6664                     if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) {
6665                         break;
6666                     }
6667                     tokenFlags |= 1024;
6668                     result += text.substring(start, pos);
6669                     result += utf16EncodeAsString(ch);
6670                     pos += 6;
6671                     start = pos;
6672                 }
6673                 else {
6674                     break;
6675                 }
6676             }
6677             result += text.substring(start, pos);
6678             return result;
6679         }
6680         function getIdentifierToken() {
6681             var len = tokenValue.length;
6682             if (len >= 2 && len <= 11) {
6683                 var ch = tokenValue.charCodeAt(0);
6684                 if (ch >= 97 && ch <= 122) {
6685                     var keyword = textToKeyword.get(tokenValue);
6686                     if (keyword !== undefined) {
6687                         return token = keyword;
6688                     }
6689                 }
6690             }
6691             return token = 75;
6692         }
6693         function scanBinaryOrOctalDigits(base) {
6694             var value = "";
6695             var separatorAllowed = false;
6696             var isPreviousTokenSeparator = false;
6697             while (true) {
6698                 var ch = text.charCodeAt(pos);
6699                 if (ch === 95) {
6700                     tokenFlags |= 512;
6701                     if (separatorAllowed) {
6702                         separatorAllowed = false;
6703                         isPreviousTokenSeparator = true;
6704                     }
6705                     else if (isPreviousTokenSeparator) {
6706                         error(ts.Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
6707                     }
6708                     else {
6709                         error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
6710                     }
6711                     pos++;
6712                     continue;
6713                 }
6714                 separatorAllowed = true;
6715                 if (!isDigit(ch) || ch - 48 >= base) {
6716                     break;
6717                 }
6718                 value += text[pos];
6719                 pos++;
6720                 isPreviousTokenSeparator = false;
6721             }
6722             if (text.charCodeAt(pos - 1) === 95) {
6723                 error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
6724             }
6725             return value;
6726         }
6727         function checkBigIntSuffix() {
6728             if (text.charCodeAt(pos) === 110) {
6729                 tokenValue += "n";
6730                 if (tokenFlags & 384) {
6731                     tokenValue = ts.parsePseudoBigInt(tokenValue) + "n";
6732                 }
6733                 pos++;
6734                 return 9;
6735             }
6736             else {
6737                 var numericValue = tokenFlags & 128
6738                     ? parseInt(tokenValue.slice(2), 2)
6739                     : tokenFlags & 256
6740                         ? parseInt(tokenValue.slice(2), 8)
6741                         : +tokenValue;
6742                 tokenValue = "" + numericValue;
6743                 return 8;
6744             }
6745         }
6746         function scan() {
6747             var _a;
6748             startPos = pos;
6749             tokenFlags = 0;
6750             var asteriskSeen = false;
6751             while (true) {
6752                 tokenPos = pos;
6753                 if (pos >= end) {
6754                     return token = 1;
6755                 }
6756                 var ch = codePointAt(text, pos);
6757                 if (ch === 35 && pos === 0 && isShebangTrivia(text, pos)) {
6758                     pos = scanShebangTrivia(text, pos);
6759                     if (skipTrivia) {
6760                         continue;
6761                     }
6762                     else {
6763                         return token = 6;
6764                     }
6765                 }
6766                 switch (ch) {
6767                     case 10:
6768                     case 13:
6769                         tokenFlags |= 1;
6770                         if (skipTrivia) {
6771                             pos++;
6772                             continue;
6773                         }
6774                         else {
6775                             if (ch === 13 && pos + 1 < end && text.charCodeAt(pos + 1) === 10) {
6776                                 pos += 2;
6777                             }
6778                             else {
6779                                 pos++;
6780                             }
6781                             return token = 4;
6782                         }
6783                     case 9:
6784                     case 11:
6785                     case 12:
6786                     case 32:
6787                     case 160:
6788                     case 5760:
6789                     case 8192:
6790                     case 8193:
6791                     case 8194:
6792                     case 8195:
6793                     case 8196:
6794                     case 8197:
6795                     case 8198:
6796                     case 8199:
6797                     case 8200:
6798                     case 8201:
6799                     case 8202:
6800                     case 8203:
6801                     case 8239:
6802                     case 8287:
6803                     case 12288:
6804                     case 65279:
6805                         if (skipTrivia) {
6806                             pos++;
6807                             continue;
6808                         }
6809                         else {
6810                             while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) {
6811                                 pos++;
6812                             }
6813                             return token = 5;
6814                         }
6815                     case 33:
6816                         if (text.charCodeAt(pos + 1) === 61) {
6817                             if (text.charCodeAt(pos + 2) === 61) {
6818                                 return pos += 3, token = 37;
6819                             }
6820                             return pos += 2, token = 35;
6821                         }
6822                         pos++;
6823                         return token = 53;
6824                     case 34:
6825                     case 39:
6826                         tokenValue = scanString();
6827                         return token = 10;
6828                     case 96:
6829                         return token = scanTemplateAndSetTokenValue(false);
6830                     case 37:
6831                         if (text.charCodeAt(pos + 1) === 61) {
6832                             return pos += 2, token = 68;
6833                         }
6834                         pos++;
6835                         return token = 44;
6836                     case 38:
6837                         if (text.charCodeAt(pos + 1) === 38) {
6838                             return pos += 2, token = 55;
6839                         }
6840                         if (text.charCodeAt(pos + 1) === 61) {
6841                             return pos += 2, token = 72;
6842                         }
6843                         pos++;
6844                         return token = 50;
6845                     case 40:
6846                         pos++;
6847                         return token = 20;
6848                     case 41:
6849                         pos++;
6850                         return token = 21;
6851                     case 42:
6852                         if (text.charCodeAt(pos + 1) === 61) {
6853                             return pos += 2, token = 65;
6854                         }
6855                         if (text.charCodeAt(pos + 1) === 42) {
6856                             if (text.charCodeAt(pos + 2) === 61) {
6857                                 return pos += 3, token = 66;
6858                             }
6859                             return pos += 2, token = 42;
6860                         }
6861                         pos++;
6862                         if (inJSDocType && !asteriskSeen && (tokenFlags & 1)) {
6863                             asteriskSeen = true;
6864                             continue;
6865                         }
6866                         return token = 41;
6867                     case 43:
6868                         if (text.charCodeAt(pos + 1) === 43) {
6869                             return pos += 2, token = 45;
6870                         }
6871                         if (text.charCodeAt(pos + 1) === 61) {
6872                             return pos += 2, token = 63;
6873                         }
6874                         pos++;
6875                         return token = 39;
6876                     case 44:
6877                         pos++;
6878                         return token = 27;
6879                     case 45:
6880                         if (text.charCodeAt(pos + 1) === 45) {
6881                             return pos += 2, token = 46;
6882                         }
6883                         if (text.charCodeAt(pos + 1) === 61) {
6884                             return pos += 2, token = 64;
6885                         }
6886                         pos++;
6887                         return token = 40;
6888                     case 46:
6889                         if (isDigit(text.charCodeAt(pos + 1))) {
6890                             tokenValue = scanNumber().value;
6891                             return token = 8;
6892                         }
6893                         if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) {
6894                             return pos += 3, token = 25;
6895                         }
6896                         pos++;
6897                         return token = 24;
6898                     case 47:
6899                         if (text.charCodeAt(pos + 1) === 47) {
6900                             pos += 2;
6901                             while (pos < end) {
6902                                 if (isLineBreak(text.charCodeAt(pos))) {
6903                                     break;
6904                                 }
6905                                 pos++;
6906                             }
6907                             commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(tokenPos, pos), commentDirectiveRegExSingleLine, tokenPos);
6908                             if (skipTrivia) {
6909                                 continue;
6910                             }
6911                             else {
6912                                 return token = 2;
6913                             }
6914                         }
6915                         if (text.charCodeAt(pos + 1) === 42) {
6916                             pos += 2;
6917                             if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) !== 47) {
6918                                 tokenFlags |= 2;
6919                             }
6920                             var commentClosed = false;
6921                             var lastLineStart = tokenPos;
6922                             while (pos < end) {
6923                                 var ch_1 = text.charCodeAt(pos);
6924                                 if (ch_1 === 42 && text.charCodeAt(pos + 1) === 47) {
6925                                     pos += 2;
6926                                     commentClosed = true;
6927                                     break;
6928                                 }
6929                                 pos++;
6930                                 if (isLineBreak(ch_1)) {
6931                                     lastLineStart = pos;
6932                                     tokenFlags |= 1;
6933                                 }
6934                             }
6935                             commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(lastLineStart, pos), commentDirectiveRegExMultiLine, lastLineStart);
6936                             if (!commentClosed) {
6937                                 error(ts.Diagnostics.Asterisk_Slash_expected);
6938                             }
6939                             if (skipTrivia) {
6940                                 continue;
6941                             }
6942                             else {
6943                                 if (!commentClosed) {
6944                                     tokenFlags |= 4;
6945                                 }
6946                                 return token = 3;
6947                             }
6948                         }
6949                         if (text.charCodeAt(pos + 1) === 61) {
6950                             return pos += 2, token = 67;
6951                         }
6952                         pos++;
6953                         return token = 43;
6954                     case 48:
6955                         if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) {
6956                             pos += 2;
6957                             tokenValue = scanMinimumNumberOfHexDigits(1, true);
6958                             if (!tokenValue) {
6959                                 error(ts.Diagnostics.Hexadecimal_digit_expected);
6960                                 tokenValue = "0";
6961                             }
6962                             tokenValue = "0x" + tokenValue;
6963                             tokenFlags |= 64;
6964                             return token = checkBigIntSuffix();
6965                         }
6966                         else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) {
6967                             pos += 2;
6968                             tokenValue = scanBinaryOrOctalDigits(2);
6969                             if (!tokenValue) {
6970                                 error(ts.Diagnostics.Binary_digit_expected);
6971                                 tokenValue = "0";
6972                             }
6973                             tokenValue = "0b" + tokenValue;
6974                             tokenFlags |= 128;
6975                             return token = checkBigIntSuffix();
6976                         }
6977                         else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) {
6978                             pos += 2;
6979                             tokenValue = scanBinaryOrOctalDigits(8);
6980                             if (!tokenValue) {
6981                                 error(ts.Diagnostics.Octal_digit_expected);
6982                                 tokenValue = "0";
6983                             }
6984                             tokenValue = "0o" + tokenValue;
6985                             tokenFlags |= 256;
6986                             return token = checkBigIntSuffix();
6987                         }
6988                         if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) {
6989                             tokenValue = "" + scanOctalDigits();
6990                             tokenFlags |= 32;
6991                             return token = 8;
6992                         }
6993                     case 49:
6994                     case 50:
6995                     case 51:
6996                     case 52:
6997                     case 53:
6998                     case 54:
6999                     case 55:
7000                     case 56:
7001                     case 57:
7002                         (_a = scanNumber(), token = _a.type, tokenValue = _a.value);
7003                         return token;
7004                     case 58:
7005                         pos++;
7006                         return token = 58;
7007                     case 59:
7008                         pos++;
7009                         return token = 26;
7010                     case 60:
7011                         if (isConflictMarkerTrivia(text, pos)) {
7012                             pos = scanConflictMarkerTrivia(text, pos, error);
7013                             if (skipTrivia) {
7014                                 continue;
7015                             }
7016                             else {
7017                                 return token = 7;
7018                             }
7019                         }
7020                         if (text.charCodeAt(pos + 1) === 60) {
7021                             if (text.charCodeAt(pos + 2) === 61) {
7022                                 return pos += 3, token = 69;
7023                             }
7024                             return pos += 2, token = 47;
7025                         }
7026                         if (text.charCodeAt(pos + 1) === 61) {
7027                             return pos += 2, token = 32;
7028                         }
7029                         if (languageVariant === 1 &&
7030                             text.charCodeAt(pos + 1) === 47 &&
7031                             text.charCodeAt(pos + 2) !== 42) {
7032                             return pos += 2, token = 30;
7033                         }
7034                         pos++;
7035                         return token = 29;
7036                     case 61:
7037                         if (isConflictMarkerTrivia(text, pos)) {
7038                             pos = scanConflictMarkerTrivia(text, pos, error);
7039                             if (skipTrivia) {
7040                                 continue;
7041                             }
7042                             else {
7043                                 return token = 7;
7044                             }
7045                         }
7046                         if (text.charCodeAt(pos + 1) === 61) {
7047                             if (text.charCodeAt(pos + 2) === 61) {
7048                                 return pos += 3, token = 36;
7049                             }
7050                             return pos += 2, token = 34;
7051                         }
7052                         if (text.charCodeAt(pos + 1) === 62) {
7053                             return pos += 2, token = 38;
7054                         }
7055                         pos++;
7056                         return token = 62;
7057                     case 62:
7058                         if (isConflictMarkerTrivia(text, pos)) {
7059                             pos = scanConflictMarkerTrivia(text, pos, error);
7060                             if (skipTrivia) {
7061                                 continue;
7062                             }
7063                             else {
7064                                 return token = 7;
7065                             }
7066                         }
7067                         pos++;
7068                         return token = 31;
7069                     case 63:
7070                         pos++;
7071                         if (text.charCodeAt(pos) === 46 && !isDigit(text.charCodeAt(pos + 1))) {
7072                             pos++;
7073                             return token = 28;
7074                         }
7075                         if (text.charCodeAt(pos) === 63) {
7076                             pos++;
7077                             return token = 60;
7078                         }
7079                         return token = 57;
7080                     case 91:
7081                         pos++;
7082                         return token = 22;
7083                     case 93:
7084                         pos++;
7085                         return token = 23;
7086                     case 94:
7087                         if (text.charCodeAt(pos + 1) === 61) {
7088                             return pos += 2, token = 74;
7089                         }
7090                         pos++;
7091                         return token = 52;
7092                     case 123:
7093                         pos++;
7094                         return token = 18;
7095                     case 124:
7096                         if (isConflictMarkerTrivia(text, pos)) {
7097                             pos = scanConflictMarkerTrivia(text, pos, error);
7098                             if (skipTrivia) {
7099                                 continue;
7100                             }
7101                             else {
7102                                 return token = 7;
7103                             }
7104                         }
7105                         if (text.charCodeAt(pos + 1) === 124) {
7106                             return pos += 2, token = 56;
7107                         }
7108                         if (text.charCodeAt(pos + 1) === 61) {
7109                             return pos += 2, token = 73;
7110                         }
7111                         pos++;
7112                         return token = 51;
7113                     case 125:
7114                         pos++;
7115                         return token = 19;
7116                     case 126:
7117                         pos++;
7118                         return token = 54;
7119                     case 64:
7120                         pos++;
7121                         return token = 59;
7122                     case 92:
7123                         var extendedCookedChar = peekExtendedUnicodeEscape();
7124                         if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) {
7125                             pos += 3;
7126                             tokenFlags |= 8;
7127                             tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts();
7128                             return token = getIdentifierToken();
7129                         }
7130                         var cookedChar = peekUnicodeEscape();
7131                         if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) {
7132                             pos += 6;
7133                             tokenFlags |= 1024;
7134                             tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts();
7135                             return token = getIdentifierToken();
7136                         }
7137                         error(ts.Diagnostics.Invalid_character);
7138                         pos++;
7139                         return token = 0;
7140                     case 35:
7141                         if (pos !== 0 && text[pos + 1] === "!") {
7142                             error(ts.Diagnostics.can_only_be_used_at_the_start_of_a_file);
7143                             pos++;
7144                             return token = 0;
7145                         }
7146                         pos++;
7147                         if (isIdentifierStart(ch = text.charCodeAt(pos), languageVersion)) {
7148                             pos++;
7149                             while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion))
7150                                 pos++;
7151                             tokenValue = text.substring(tokenPos, pos);
7152                             if (ch === 92) {
7153                                 tokenValue += scanIdentifierParts();
7154                             }
7155                         }
7156                         else {
7157                             tokenValue = "#";
7158                             error(ts.Diagnostics.Invalid_character);
7159                         }
7160                         return token = 76;
7161                     default:
7162                         if (isIdentifierStart(ch, languageVersion)) {
7163                             pos += charSize(ch);
7164                             while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion))
7165                                 pos += charSize(ch);
7166                             tokenValue = text.substring(tokenPos, pos);
7167                             if (ch === 92) {
7168                                 tokenValue += scanIdentifierParts();
7169                             }
7170                             return token = getIdentifierToken();
7171                         }
7172                         else if (isWhiteSpaceSingleLine(ch)) {
7173                             pos += charSize(ch);
7174                             continue;
7175                         }
7176                         else if (isLineBreak(ch)) {
7177                             tokenFlags |= 1;
7178                             pos += charSize(ch);
7179                             continue;
7180                         }
7181                         error(ts.Diagnostics.Invalid_character);
7182                         pos += charSize(ch);
7183                         return token = 0;
7184                 }
7185             }
7186         }
7187         function reScanGreaterToken() {
7188             if (token === 31) {
7189                 if (text.charCodeAt(pos) === 62) {
7190                     if (text.charCodeAt(pos + 1) === 62) {
7191                         if (text.charCodeAt(pos + 2) === 61) {
7192                             return pos += 3, token = 71;
7193                         }
7194                         return pos += 2, token = 49;
7195                     }
7196                     if (text.charCodeAt(pos + 1) === 61) {
7197                         return pos += 2, token = 70;
7198                     }
7199                     pos++;
7200                     return token = 48;
7201                 }
7202                 if (text.charCodeAt(pos) === 61) {
7203                     pos++;
7204                     return token = 33;
7205                 }
7206             }
7207             return token;
7208         }
7209         function reScanSlashToken() {
7210             if (token === 43 || token === 67) {
7211                 var p = tokenPos + 1;
7212                 var inEscape = false;
7213                 var inCharacterClass = false;
7214                 while (true) {
7215                     if (p >= end) {
7216                         tokenFlags |= 4;
7217                         error(ts.Diagnostics.Unterminated_regular_expression_literal);
7218                         break;
7219                     }
7220                     var ch = text.charCodeAt(p);
7221                     if (isLineBreak(ch)) {
7222                         tokenFlags |= 4;
7223                         error(ts.Diagnostics.Unterminated_regular_expression_literal);
7224                         break;
7225                     }
7226                     if (inEscape) {
7227                         inEscape = false;
7228                     }
7229                     else if (ch === 47 && !inCharacterClass) {
7230                         p++;
7231                         break;
7232                     }
7233                     else if (ch === 91) {
7234                         inCharacterClass = true;
7235                     }
7236                     else if (ch === 92) {
7237                         inEscape = true;
7238                     }
7239                     else if (ch === 93) {
7240                         inCharacterClass = false;
7241                     }
7242                     p++;
7243                 }
7244                 while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) {
7245                     p++;
7246                 }
7247                 pos = p;
7248                 tokenValue = text.substring(tokenPos, pos);
7249                 token = 13;
7250             }
7251             return token;
7252         }
7253         function appendIfCommentDirective(commentDirectives, text, commentDirectiveRegEx, lineStart) {
7254             var type = getDirectiveFromComment(text, commentDirectiveRegEx);
7255             if (type === undefined) {
7256                 return commentDirectives;
7257             }
7258             return ts.append(commentDirectives, {
7259                 range: { pos: lineStart, end: pos },
7260                 type: type,
7261             });
7262         }
7263         function getDirectiveFromComment(text, commentDirectiveRegEx) {
7264             var match = commentDirectiveRegEx.exec(text);
7265             if (!match) {
7266                 return undefined;
7267             }
7268             switch (match[1]) {
7269                 case "ts-expect-error":
7270                     return 0;
7271                 case "ts-ignore":
7272                     return 1;
7273             }
7274             return undefined;
7275         }
7276         function reScanTemplateToken(isTaggedTemplate) {
7277             ts.Debug.assert(token === 19, "'reScanTemplateToken' should only be called on a '}'");
7278             pos = tokenPos;
7279             return token = scanTemplateAndSetTokenValue(isTaggedTemplate);
7280         }
7281         function reScanTemplateHeadOrNoSubstitutionTemplate() {
7282             pos = tokenPos;
7283             return token = scanTemplateAndSetTokenValue(true);
7284         }
7285         function reScanJsxToken() {
7286             pos = tokenPos = startPos;
7287             return token = scanJsxToken();
7288         }
7289         function reScanLessThanToken() {
7290             if (token === 47) {
7291                 pos = tokenPos + 1;
7292                 return token = 29;
7293             }
7294             return token;
7295         }
7296         function reScanQuestionToken() {
7297             ts.Debug.assert(token === 60, "'reScanQuestionToken' should only be called on a '??'");
7298             pos = tokenPos + 1;
7299             return token = 57;
7300         }
7301         function scanJsxToken() {
7302             startPos = tokenPos = pos;
7303             if (pos >= end) {
7304                 return token = 1;
7305             }
7306             var char = text.charCodeAt(pos);
7307             if (char === 60) {
7308                 if (text.charCodeAt(pos + 1) === 47) {
7309                     pos += 2;
7310                     return token = 30;
7311                 }
7312                 pos++;
7313                 return token = 29;
7314             }
7315             if (char === 123) {
7316                 pos++;
7317                 return token = 18;
7318             }
7319             var firstNonWhitespace = 0;
7320             var lastNonWhitespace = -1;
7321             while (pos < end) {
7322                 if (!isWhiteSpaceSingleLine(char)) {
7323                     lastNonWhitespace = pos;
7324                 }
7325                 char = text.charCodeAt(pos);
7326                 if (char === 123) {
7327                     break;
7328                 }
7329                 if (char === 60) {
7330                     if (isConflictMarkerTrivia(text, pos)) {
7331                         pos = scanConflictMarkerTrivia(text, pos, error);
7332                         return token = 7;
7333                     }
7334                     break;
7335                 }
7336                 if (char === 62) {
7337                     error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_gt, pos, 1);
7338                 }
7339                 if (char === 125) {
7340                     error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1);
7341                 }
7342                 if (lastNonWhitespace > 0)
7343                     lastNonWhitespace++;
7344                 if (isLineBreak(char) && firstNonWhitespace === 0) {
7345                     firstNonWhitespace = -1;
7346                 }
7347                 else if (!isWhiteSpaceLike(char)) {
7348                     firstNonWhitespace = pos;
7349                 }
7350                 pos++;
7351             }
7352             var endPosition = lastNonWhitespace === -1 ? pos : lastNonWhitespace;
7353             tokenValue = text.substring(startPos, endPosition);
7354             return firstNonWhitespace === -1 ? 12 : 11;
7355         }
7356         function scanJsxIdentifier() {
7357             if (tokenIsIdentifierOrKeyword(token)) {
7358                 while (pos < end) {
7359                     var ch = text.charCodeAt(pos);
7360                     if (ch === 45) {
7361                         tokenValue += "-";
7362                         pos++;
7363                         continue;
7364                     }
7365                     var oldPos = pos;
7366                     tokenValue += scanIdentifierParts();
7367                     if (pos === oldPos) {
7368                         break;
7369                     }
7370                 }
7371             }
7372             return token;
7373         }
7374         function scanJsxAttributeValue() {
7375             startPos = pos;
7376             switch (text.charCodeAt(pos)) {
7377                 case 34:
7378                 case 39:
7379                     tokenValue = scanString(true);
7380                     return token = 10;
7381                 default:
7382                     return scan();
7383             }
7384         }
7385         function reScanJsxAttributeValue() {
7386             pos = tokenPos = startPos;
7387             return scanJsxAttributeValue();
7388         }
7389         function scanJsDocToken() {
7390             startPos = tokenPos = pos;
7391             tokenFlags = 0;
7392             if (pos >= end) {
7393                 return token = 1;
7394             }
7395             var ch = codePointAt(text, pos);
7396             pos += charSize(ch);
7397             switch (ch) {
7398                 case 9:
7399                 case 11:
7400                 case 12:
7401                 case 32:
7402                     while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) {
7403                         pos++;
7404                     }
7405                     return token = 5;
7406                 case 64:
7407                     return token = 59;
7408                 case 10:
7409                 case 13:
7410                     tokenFlags |= 1;
7411                     return token = 4;
7412                 case 42:
7413                     return token = 41;
7414                 case 123:
7415                     return token = 18;
7416                 case 125:
7417                     return token = 19;
7418                 case 91:
7419                     return token = 22;
7420                 case 93:
7421                     return token = 23;
7422                 case 60:
7423                     return token = 29;
7424                 case 62:
7425                     return token = 31;
7426                 case 61:
7427                     return token = 62;
7428                 case 44:
7429                     return token = 27;
7430                 case 46:
7431                     return token = 24;
7432                 case 96:
7433                     return token = 61;
7434                 case 92:
7435                     pos--;
7436                     var extendedCookedChar = peekExtendedUnicodeEscape();
7437                     if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) {
7438                         pos += 3;
7439                         tokenFlags |= 8;
7440                         tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts();
7441                         return token = getIdentifierToken();
7442                     }
7443                     var cookedChar = peekUnicodeEscape();
7444                     if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) {
7445                         pos += 6;
7446                         tokenFlags |= 1024;
7447                         tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts();
7448                         return token = getIdentifierToken();
7449                     }
7450                     pos++;
7451                     return token = 0;
7452             }
7453             if (isIdentifierStart(ch, languageVersion)) {
7454                 var char = ch;
7455                 while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45)
7456                     pos += charSize(char);
7457                 tokenValue = text.substring(tokenPos, pos);
7458                 if (char === 92) {
7459                     tokenValue += scanIdentifierParts();
7460                 }
7461                 return token = getIdentifierToken();
7462             }
7463             else {
7464                 return token = 0;
7465             }
7466         }
7467         function speculationHelper(callback, isLookahead) {
7468             var savePos = pos;
7469             var saveStartPos = startPos;
7470             var saveTokenPos = tokenPos;
7471             var saveToken = token;
7472             var saveTokenValue = tokenValue;
7473             var saveTokenFlags = tokenFlags;
7474             var result = callback();
7475             if (!result || isLookahead) {
7476                 pos = savePos;
7477                 startPos = saveStartPos;
7478                 tokenPos = saveTokenPos;
7479                 token = saveToken;
7480                 tokenValue = saveTokenValue;
7481                 tokenFlags = saveTokenFlags;
7482             }
7483             return result;
7484         }
7485         function scanRange(start, length, callback) {
7486             var saveEnd = end;
7487             var savePos = pos;
7488             var saveStartPos = startPos;
7489             var saveTokenPos = tokenPos;
7490             var saveToken = token;
7491             var saveTokenValue = tokenValue;
7492             var saveTokenFlags = tokenFlags;
7493             var saveErrorExpectations = commentDirectives;
7494             setText(text, start, length);
7495             var result = callback();
7496             end = saveEnd;
7497             pos = savePos;
7498             startPos = saveStartPos;
7499             tokenPos = saveTokenPos;
7500             token = saveToken;
7501             tokenValue = saveTokenValue;
7502             tokenFlags = saveTokenFlags;
7503             commentDirectives = saveErrorExpectations;
7504             return result;
7505         }
7506         function lookAhead(callback) {
7507             return speculationHelper(callback, true);
7508         }
7509         function tryScan(callback) {
7510             return speculationHelper(callback, false);
7511         }
7512         function getText() {
7513             return text;
7514         }
7515         function clearCommentDirectives() {
7516             commentDirectives = undefined;
7517         }
7518         function setText(newText, start, length) {
7519             text = newText || "";
7520             end = length === undefined ? text.length : start + length;
7521             setTextPos(start || 0);
7522         }
7523         function setOnError(errorCallback) {
7524             onError = errorCallback;
7525         }
7526         function setScriptTarget(scriptTarget) {
7527             languageVersion = scriptTarget;
7528         }
7529         function setLanguageVariant(variant) {
7530             languageVariant = variant;
7531         }
7532         function setTextPos(textPos) {
7533             ts.Debug.assert(textPos >= 0);
7534             pos = textPos;
7535             startPos = textPos;
7536             tokenPos = textPos;
7537             token = 0;
7538             tokenValue = undefined;
7539             tokenFlags = 0;
7540         }
7541         function setInJSDocType(inType) {
7542             inJSDocType += inType ? 1 : -1;
7543         }
7544     }
7545     ts.createScanner = createScanner;
7546     var codePointAt = String.prototype.codePointAt ? function (s, i) { return s.codePointAt(i); } : function codePointAt(str, i) {
7547         var size = str.length;
7548         if (i < 0 || i >= size) {
7549             return undefined;
7550         }
7551         var first = str.charCodeAt(i);
7552         if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) {
7553             var second = str.charCodeAt(i + 1);
7554             if (second >= 0xDC00 && second <= 0xDFFF) {
7555                 return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
7556             }
7557         }
7558         return first;
7559     };
7560     function charSize(ch) {
7561         if (ch >= 0x10000) {
7562             return 2;
7563         }
7564         return 1;
7565     }
7566     function utf16EncodeAsStringFallback(codePoint) {
7567         ts.Debug.assert(0x0 <= codePoint && codePoint <= 0x10FFFF);
7568         if (codePoint <= 65535) {
7569             return String.fromCharCode(codePoint);
7570         }
7571         var codeUnit1 = Math.floor((codePoint - 65536) / 1024) + 0xD800;
7572         var codeUnit2 = ((codePoint - 65536) % 1024) + 0xDC00;
7573         return String.fromCharCode(codeUnit1, codeUnit2);
7574     }
7575     var utf16EncodeAsStringWorker = String.fromCodePoint ? function (codePoint) { return String.fromCodePoint(codePoint); } : utf16EncodeAsStringFallback;
7576     function utf16EncodeAsString(codePoint) {
7577         return utf16EncodeAsStringWorker(codePoint);
7578     }
7579     ts.utf16EncodeAsString = utf16EncodeAsString;
7580 })(ts || (ts = {}));
7581 var ts;
7582 (function (ts) {
7583     function isExternalModuleNameRelative(moduleName) {
7584         return ts.pathIsRelative(moduleName) || ts.isRootedDiskPath(moduleName);
7585     }
7586     ts.isExternalModuleNameRelative = isExternalModuleNameRelative;
7587     function sortAndDeduplicateDiagnostics(diagnostics) {
7588         return ts.sortAndDeduplicate(diagnostics, ts.compareDiagnostics);
7589     }
7590     ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics;
7591     function getDefaultLibFileName(options) {
7592         switch (options.target) {
7593             case 99:
7594                 return "lib.esnext.full.d.ts";
7595             case 7:
7596                 return "lib.es2020.full.d.ts";
7597             case 6:
7598                 return "lib.es2019.full.d.ts";
7599             case 5:
7600                 return "lib.es2018.full.d.ts";
7601             case 4:
7602                 return "lib.es2017.full.d.ts";
7603             case 3:
7604                 return "lib.es2016.full.d.ts";
7605             case 2:
7606                 return "lib.es6.d.ts";
7607             default:
7608                 return "lib.d.ts";
7609         }
7610     }
7611     ts.getDefaultLibFileName = getDefaultLibFileName;
7612     function textSpanEnd(span) {
7613         return span.start + span.length;
7614     }
7615     ts.textSpanEnd = textSpanEnd;
7616     function textSpanIsEmpty(span) {
7617         return span.length === 0;
7618     }
7619     ts.textSpanIsEmpty = textSpanIsEmpty;
7620     function textSpanContainsPosition(span, position) {
7621         return position >= span.start && position < textSpanEnd(span);
7622     }
7623     ts.textSpanContainsPosition = textSpanContainsPosition;
7624     function textRangeContainsPositionInclusive(span, position) {
7625         return position >= span.pos && position <= span.end;
7626     }
7627     ts.textRangeContainsPositionInclusive = textRangeContainsPositionInclusive;
7628     function textSpanContainsTextSpan(span, other) {
7629         return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span);
7630     }
7631     ts.textSpanContainsTextSpan = textSpanContainsTextSpan;
7632     function textSpanOverlapsWith(span, other) {
7633         return textSpanOverlap(span, other) !== undefined;
7634     }
7635     ts.textSpanOverlapsWith = textSpanOverlapsWith;
7636     function textSpanOverlap(span1, span2) {
7637         var overlap = textSpanIntersection(span1, span2);
7638         return overlap && overlap.length === 0 ? undefined : overlap;
7639     }
7640     ts.textSpanOverlap = textSpanOverlap;
7641     function textSpanIntersectsWithTextSpan(span, other) {
7642         return decodedTextSpanIntersectsWith(span.start, span.length, other.start, other.length);
7643     }
7644     ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan;
7645     function textSpanIntersectsWith(span, start, length) {
7646         return decodedTextSpanIntersectsWith(span.start, span.length, start, length);
7647     }
7648     ts.textSpanIntersectsWith = textSpanIntersectsWith;
7649     function decodedTextSpanIntersectsWith(start1, length1, start2, length2) {
7650         var end1 = start1 + length1;
7651         var end2 = start2 + length2;
7652         return start2 <= end1 && end2 >= start1;
7653     }
7654     ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith;
7655     function textSpanIntersectsWithPosition(span, position) {
7656         return position <= textSpanEnd(span) && position >= span.start;
7657     }
7658     ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition;
7659     function textSpanIntersection(span1, span2) {
7660         var start = Math.max(span1.start, span2.start);
7661         var end = Math.min(textSpanEnd(span1), textSpanEnd(span2));
7662         return start <= end ? createTextSpanFromBounds(start, end) : undefined;
7663     }
7664     ts.textSpanIntersection = textSpanIntersection;
7665     function createTextSpan(start, length) {
7666         if (start < 0) {
7667             throw new Error("start < 0");
7668         }
7669         if (length < 0) {
7670             throw new Error("length < 0");
7671         }
7672         return { start: start, length: length };
7673     }
7674     ts.createTextSpan = createTextSpan;
7675     function createTextSpanFromBounds(start, end) {
7676         return createTextSpan(start, end - start);
7677     }
7678     ts.createTextSpanFromBounds = createTextSpanFromBounds;
7679     function textChangeRangeNewSpan(range) {
7680         return createTextSpan(range.span.start, range.newLength);
7681     }
7682     ts.textChangeRangeNewSpan = textChangeRangeNewSpan;
7683     function textChangeRangeIsUnchanged(range) {
7684         return textSpanIsEmpty(range.span) && range.newLength === 0;
7685     }
7686     ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged;
7687     function createTextChangeRange(span, newLength) {
7688         if (newLength < 0) {
7689             throw new Error("newLength < 0");
7690         }
7691         return { span: span, newLength: newLength };
7692     }
7693     ts.createTextChangeRange = createTextChangeRange;
7694     ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0);
7695     function collapseTextChangeRangesAcrossMultipleVersions(changes) {
7696         if (changes.length === 0) {
7697             return ts.unchangedTextChangeRange;
7698         }
7699         if (changes.length === 1) {
7700             return changes[0];
7701         }
7702         var change0 = changes[0];
7703         var oldStartN = change0.span.start;
7704         var oldEndN = textSpanEnd(change0.span);
7705         var newEndN = oldStartN + change0.newLength;
7706         for (var i = 1; i < changes.length; i++) {
7707             var nextChange = changes[i];
7708             var oldStart1 = oldStartN;
7709             var oldEnd1 = oldEndN;
7710             var newEnd1 = newEndN;
7711             var oldStart2 = nextChange.span.start;
7712             var oldEnd2 = textSpanEnd(nextChange.span);
7713             var newEnd2 = oldStart2 + nextChange.newLength;
7714             oldStartN = Math.min(oldStart1, oldStart2);
7715             oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1));
7716             newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2));
7717         }
7718         return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN);
7719     }
7720     ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions;
7721     function getTypeParameterOwner(d) {
7722         if (d && d.kind === 155) {
7723             for (var current = d; current; current = current.parent) {
7724                 if (isFunctionLike(current) || isClassLike(current) || current.kind === 246) {
7725                     return current;
7726                 }
7727             }
7728         }
7729     }
7730     ts.getTypeParameterOwner = getTypeParameterOwner;
7731     function isParameterPropertyDeclaration(node, parent) {
7732         return ts.hasModifier(node, 92) && parent.kind === 162;
7733     }
7734     ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration;
7735     function isEmptyBindingPattern(node) {
7736         if (isBindingPattern(node)) {
7737             return ts.every(node.elements, isEmptyBindingElement);
7738         }
7739         return false;
7740     }
7741     ts.isEmptyBindingPattern = isEmptyBindingPattern;
7742     function isEmptyBindingElement(node) {
7743         if (isOmittedExpression(node)) {
7744             return true;
7745         }
7746         return isEmptyBindingPattern(node.name);
7747     }
7748     ts.isEmptyBindingElement = isEmptyBindingElement;
7749     function walkUpBindingElementsAndPatterns(binding) {
7750         var node = binding.parent;
7751         while (isBindingElement(node.parent)) {
7752             node = node.parent.parent;
7753         }
7754         return node.parent;
7755     }
7756     ts.walkUpBindingElementsAndPatterns = walkUpBindingElementsAndPatterns;
7757     function getCombinedFlags(node, getFlags) {
7758         if (isBindingElement(node)) {
7759             node = walkUpBindingElementsAndPatterns(node);
7760         }
7761         var flags = getFlags(node);
7762         if (node.kind === 242) {
7763             node = node.parent;
7764         }
7765         if (node && node.kind === 243) {
7766             flags |= getFlags(node);
7767             node = node.parent;
7768         }
7769         if (node && node.kind === 225) {
7770             flags |= getFlags(node);
7771         }
7772         return flags;
7773     }
7774     function getCombinedModifierFlags(node) {
7775         return getCombinedFlags(node, ts.getModifierFlags);
7776     }
7777     ts.getCombinedModifierFlags = getCombinedModifierFlags;
7778     function getCombinedNodeFlags(node) {
7779         return getCombinedFlags(node, function (n) { return n.flags; });
7780     }
7781     ts.getCombinedNodeFlags = getCombinedNodeFlags;
7782     function validateLocaleAndSetLanguage(locale, sys, errors) {
7783         var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase());
7784         if (!matchResult) {
7785             if (errors) {
7786                 errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp"));
7787             }
7788             return;
7789         }
7790         var language = matchResult[1];
7791         var territory = matchResult[3];
7792         if (!trySetLanguageAndTerritory(language, territory, errors)) {
7793             trySetLanguageAndTerritory(language, undefined, errors);
7794         }
7795         ts.setUILocale(locale);
7796         function trySetLanguageAndTerritory(language, territory, errors) {
7797             var compilerFilePath = ts.normalizePath(sys.getExecutingFilePath());
7798             var containingDirectoryPath = ts.getDirectoryPath(compilerFilePath);
7799             var filePath = ts.combinePaths(containingDirectoryPath, language);
7800             if (territory) {
7801                 filePath = filePath + "-" + territory;
7802             }
7803             filePath = sys.resolvePath(ts.combinePaths(filePath, "diagnosticMessages.generated.json"));
7804             if (!sys.fileExists(filePath)) {
7805                 return false;
7806             }
7807             var fileContents = "";
7808             try {
7809                 fileContents = sys.readFile(filePath);
7810             }
7811             catch (e) {
7812                 if (errors) {
7813                     errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unable_to_open_file_0, filePath));
7814                 }
7815                 return false;
7816             }
7817             try {
7818                 ts.setLocalizedDiagnosticMessages(JSON.parse(fileContents));
7819             }
7820             catch (_a) {
7821                 if (errors) {
7822                     errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Corrupted_locale_file_0, filePath));
7823                 }
7824                 return false;
7825             }
7826             return true;
7827         }
7828     }
7829     ts.validateLocaleAndSetLanguage = validateLocaleAndSetLanguage;
7830     function getOriginalNode(node, nodeTest) {
7831         if (node) {
7832             while (node.original !== undefined) {
7833                 node = node.original;
7834             }
7835         }
7836         return !nodeTest || nodeTest(node) ? node : undefined;
7837     }
7838     ts.getOriginalNode = getOriginalNode;
7839     function isParseTreeNode(node) {
7840         return (node.flags & 8) === 0;
7841     }
7842     ts.isParseTreeNode = isParseTreeNode;
7843     function getParseTreeNode(node, nodeTest) {
7844         if (node === undefined || isParseTreeNode(node)) {
7845             return node;
7846         }
7847         node = getOriginalNode(node);
7848         if (isParseTreeNode(node) && (!nodeTest || nodeTest(node))) {
7849             return node;
7850         }
7851         return undefined;
7852     }
7853     ts.getParseTreeNode = getParseTreeNode;
7854     function escapeLeadingUnderscores(identifier) {
7855         return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 ? "_" + identifier : identifier);
7856     }
7857     ts.escapeLeadingUnderscores = escapeLeadingUnderscores;
7858     function unescapeLeadingUnderscores(identifier) {
7859         var id = identifier;
7860         return id.length >= 3 && id.charCodeAt(0) === 95 && id.charCodeAt(1) === 95 && id.charCodeAt(2) === 95 ? id.substr(1) : id;
7861     }
7862     ts.unescapeLeadingUnderscores = unescapeLeadingUnderscores;
7863     function idText(identifierOrPrivateName) {
7864         return unescapeLeadingUnderscores(identifierOrPrivateName.escapedText);
7865     }
7866     ts.idText = idText;
7867     function symbolName(symbol) {
7868         if (symbol.valueDeclaration && isPrivateIdentifierPropertyDeclaration(symbol.valueDeclaration)) {
7869             return idText(symbol.valueDeclaration.name);
7870         }
7871         return unescapeLeadingUnderscores(symbol.escapedName);
7872     }
7873     ts.symbolName = symbolName;
7874     function nameForNamelessJSDocTypedef(declaration) {
7875         var hostNode = declaration.parent.parent;
7876         if (!hostNode) {
7877             return undefined;
7878         }
7879         if (isDeclaration(hostNode)) {
7880             return getDeclarationIdentifier(hostNode);
7881         }
7882         switch (hostNode.kind) {
7883             case 225:
7884                 if (hostNode.declarationList && hostNode.declarationList.declarations[0]) {
7885                     return getDeclarationIdentifier(hostNode.declarationList.declarations[0]);
7886                 }
7887                 break;
7888             case 226:
7889                 var expr = hostNode.expression;
7890                 if (expr.kind === 209 && expr.operatorToken.kind === 62) {
7891                     expr = expr.left;
7892                 }
7893                 switch (expr.kind) {
7894                     case 194:
7895                         return expr.name;
7896                     case 195:
7897                         var arg = expr.argumentExpression;
7898                         if (isIdentifier(arg)) {
7899                             return arg;
7900                         }
7901                 }
7902                 break;
7903             case 200: {
7904                 return getDeclarationIdentifier(hostNode.expression);
7905             }
7906             case 238: {
7907                 if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) {
7908                     return getDeclarationIdentifier(hostNode.statement);
7909                 }
7910                 break;
7911             }
7912         }
7913     }
7914     function getDeclarationIdentifier(node) {
7915         var name = getNameOfDeclaration(node);
7916         return name && isIdentifier(name) ? name : undefined;
7917     }
7918     function nodeHasName(statement, name) {
7919         if (isNamedDeclaration(statement) && isIdentifier(statement.name) && idText(statement.name) === idText(name)) {
7920             return true;
7921         }
7922         if (isVariableStatement(statement) && ts.some(statement.declarationList.declarations, function (d) { return nodeHasName(d, name); })) {
7923             return true;
7924         }
7925         return false;
7926     }
7927     ts.nodeHasName = nodeHasName;
7928     function getNameOfJSDocTypedef(declaration) {
7929         return declaration.name || nameForNamelessJSDocTypedef(declaration);
7930     }
7931     ts.getNameOfJSDocTypedef = getNameOfJSDocTypedef;
7932     function isNamedDeclaration(node) {
7933         return !!node.name;
7934     }
7935     ts.isNamedDeclaration = isNamedDeclaration;
7936     function getNonAssignedNameOfDeclaration(declaration) {
7937         switch (declaration.kind) {
7938             case 75:
7939                 return declaration;
7940             case 323:
7941             case 317: {
7942                 var name = declaration.name;
7943                 if (name.kind === 153) {
7944                     return name.right;
7945                 }
7946                 break;
7947             }
7948             case 196:
7949             case 209: {
7950                 var expr_1 = declaration;
7951                 switch (ts.getAssignmentDeclarationKind(expr_1)) {
7952                     case 1:
7953                     case 4:
7954                     case 5:
7955                     case 3:
7956                         return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left);
7957                     case 7:
7958                     case 8:
7959                     case 9:
7960                         return expr_1.arguments[1];
7961                     default:
7962                         return undefined;
7963                 }
7964             }
7965             case 322:
7966                 return getNameOfJSDocTypedef(declaration);
7967             case 316:
7968                 return nameForNamelessJSDocTypedef(declaration);
7969             case 259: {
7970                 var expression = declaration.expression;
7971                 return isIdentifier(expression) ? expression : undefined;
7972             }
7973             case 195:
7974                 var expr = declaration;
7975                 if (ts.isBindableStaticElementAccessExpression(expr)) {
7976                     return expr.argumentExpression;
7977                 }
7978         }
7979         return declaration.name;
7980     }
7981     ts.getNonAssignedNameOfDeclaration = getNonAssignedNameOfDeclaration;
7982     function getNameOfDeclaration(declaration) {
7983         if (declaration === undefined)
7984             return undefined;
7985         return getNonAssignedNameOfDeclaration(declaration) ||
7986             (isFunctionExpression(declaration) || isClassExpression(declaration) ? getAssignedName(declaration) : undefined);
7987     }
7988     ts.getNameOfDeclaration = getNameOfDeclaration;
7989     function getAssignedName(node) {
7990         if (!node.parent) {
7991             return undefined;
7992         }
7993         else if (isPropertyAssignment(node.parent) || isBindingElement(node.parent)) {
7994             return node.parent.name;
7995         }
7996         else if (isBinaryExpression(node.parent) && node === node.parent.right) {
7997             if (isIdentifier(node.parent.left)) {
7998                 return node.parent.left;
7999             }
8000             else if (ts.isAccessExpression(node.parent.left)) {
8001                 return ts.getElementOrPropertyAccessArgumentExpressionOrName(node.parent.left);
8002             }
8003         }
8004         else if (isVariableDeclaration(node.parent) && isIdentifier(node.parent.name)) {
8005             return node.parent.name;
8006         }
8007     }
8008     function getJSDocParameterTags(param) {
8009         if (param.name) {
8010             if (isIdentifier(param.name)) {
8011                 var name_1 = param.name.escapedText;
8012                 return getJSDocTags(param.parent).filter(function (tag) { return isJSDocParameterTag(tag) && isIdentifier(tag.name) && tag.name.escapedText === name_1; });
8013             }
8014             else {
8015                 var i = param.parent.parameters.indexOf(param);
8016                 ts.Debug.assert(i > -1, "Parameters should always be in their parents' parameter list");
8017                 var paramTags = getJSDocTags(param.parent).filter(isJSDocParameterTag);
8018                 if (i < paramTags.length) {
8019                     return [paramTags[i]];
8020                 }
8021             }
8022         }
8023         return ts.emptyArray;
8024     }
8025     ts.getJSDocParameterTags = getJSDocParameterTags;
8026     function getJSDocTypeParameterTags(param) {
8027         var name = param.name.escapedText;
8028         return getJSDocTags(param.parent).filter(function (tag) {
8029             return isJSDocTemplateTag(tag) && tag.typeParameters.some(function (tp) { return tp.name.escapedText === name; });
8030         });
8031     }
8032     ts.getJSDocTypeParameterTags = getJSDocTypeParameterTags;
8033     function hasJSDocParameterTags(node) {
8034         return !!getFirstJSDocTag(node, isJSDocParameterTag);
8035     }
8036     ts.hasJSDocParameterTags = hasJSDocParameterTags;
8037     function getJSDocAugmentsTag(node) {
8038         return getFirstJSDocTag(node, isJSDocAugmentsTag);
8039     }
8040     ts.getJSDocAugmentsTag = getJSDocAugmentsTag;
8041     function getJSDocImplementsTags(node) {
8042         return getAllJSDocTags(node, isJSDocImplementsTag);
8043     }
8044     ts.getJSDocImplementsTags = getJSDocImplementsTags;
8045     function getJSDocClassTag(node) {
8046         return getFirstJSDocTag(node, isJSDocClassTag);
8047     }
8048     ts.getJSDocClassTag = getJSDocClassTag;
8049     function getJSDocPublicTag(node) {
8050         return getFirstJSDocTag(node, isJSDocPublicTag);
8051     }
8052     ts.getJSDocPublicTag = getJSDocPublicTag;
8053     function getJSDocPrivateTag(node) {
8054         return getFirstJSDocTag(node, isJSDocPrivateTag);
8055     }
8056     ts.getJSDocPrivateTag = getJSDocPrivateTag;
8057     function getJSDocProtectedTag(node) {
8058         return getFirstJSDocTag(node, isJSDocProtectedTag);
8059     }
8060     ts.getJSDocProtectedTag = getJSDocProtectedTag;
8061     function getJSDocReadonlyTag(node) {
8062         return getFirstJSDocTag(node, isJSDocReadonlyTag);
8063     }
8064     ts.getJSDocReadonlyTag = getJSDocReadonlyTag;
8065     function getJSDocEnumTag(node) {
8066         return getFirstJSDocTag(node, isJSDocEnumTag);
8067     }
8068     ts.getJSDocEnumTag = getJSDocEnumTag;
8069     function getJSDocThisTag(node) {
8070         return getFirstJSDocTag(node, isJSDocThisTag);
8071     }
8072     ts.getJSDocThisTag = getJSDocThisTag;
8073     function getJSDocReturnTag(node) {
8074         return getFirstJSDocTag(node, isJSDocReturnTag);
8075     }
8076     ts.getJSDocReturnTag = getJSDocReturnTag;
8077     function getJSDocTemplateTag(node) {
8078         return getFirstJSDocTag(node, isJSDocTemplateTag);
8079     }
8080     ts.getJSDocTemplateTag = getJSDocTemplateTag;
8081     function getJSDocTypeTag(node) {
8082         var tag = getFirstJSDocTag(node, isJSDocTypeTag);
8083         if (tag && tag.typeExpression && tag.typeExpression.type) {
8084             return tag;
8085         }
8086         return undefined;
8087     }
8088     ts.getJSDocTypeTag = getJSDocTypeTag;
8089     function getJSDocType(node) {
8090         var tag = getFirstJSDocTag(node, isJSDocTypeTag);
8091         if (!tag && isParameter(node)) {
8092             tag = ts.find(getJSDocParameterTags(node), function (tag) { return !!tag.typeExpression; });
8093         }
8094         return tag && tag.typeExpression && tag.typeExpression.type;
8095     }
8096     ts.getJSDocType = getJSDocType;
8097     function getJSDocReturnType(node) {
8098         var returnTag = getJSDocReturnTag(node);
8099         if (returnTag && returnTag.typeExpression) {
8100             return returnTag.typeExpression.type;
8101         }
8102         var typeTag = getJSDocTypeTag(node);
8103         if (typeTag && typeTag.typeExpression) {
8104             var type = typeTag.typeExpression.type;
8105             if (isTypeLiteralNode(type)) {
8106                 var sig = ts.find(type.members, isCallSignatureDeclaration);
8107                 return sig && sig.type;
8108             }
8109             if (isFunctionTypeNode(type) || isJSDocFunctionType(type)) {
8110                 return type.type;
8111             }
8112         }
8113     }
8114     ts.getJSDocReturnType = getJSDocReturnType;
8115     function getJSDocTags(node) {
8116         var tags = node.jsDocCache;
8117         if (tags === undefined) {
8118             var comments = ts.getJSDocCommentsAndTags(node);
8119             ts.Debug.assert(comments.length < 2 || comments[0] !== comments[1]);
8120             node.jsDocCache = tags = ts.flatMap(comments, function (j) { return isJSDoc(j) ? j.tags : j; });
8121         }
8122         return tags;
8123     }
8124     ts.getJSDocTags = getJSDocTags;
8125     function getFirstJSDocTag(node, predicate) {
8126         return ts.find(getJSDocTags(node), predicate);
8127     }
8128     function getAllJSDocTags(node, predicate) {
8129         return getJSDocTags(node).filter(predicate);
8130     }
8131     ts.getAllJSDocTags = getAllJSDocTags;
8132     function getAllJSDocTagsOfKind(node, kind) {
8133         return getJSDocTags(node).filter(function (doc) { return doc.kind === kind; });
8134     }
8135     ts.getAllJSDocTagsOfKind = getAllJSDocTagsOfKind;
8136     function getEffectiveTypeParameterDeclarations(node) {
8137         if (isJSDocSignature(node)) {
8138             return ts.emptyArray;
8139         }
8140         if (ts.isJSDocTypeAlias(node)) {
8141             ts.Debug.assert(node.parent.kind === 303);
8142             return ts.flatMap(node.parent.tags, function (tag) { return isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; });
8143         }
8144         if (node.typeParameters) {
8145             return node.typeParameters;
8146         }
8147         if (ts.isInJSFile(node)) {
8148             var decls = ts.getJSDocTypeParameterDeclarations(node);
8149             if (decls.length) {
8150                 return decls;
8151             }
8152             var typeTag = getJSDocType(node);
8153             if (typeTag && isFunctionTypeNode(typeTag) && typeTag.typeParameters) {
8154                 return typeTag.typeParameters;
8155             }
8156         }
8157         return ts.emptyArray;
8158     }
8159     ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations;
8160     function getEffectiveConstraintOfTypeParameter(node) {
8161         return node.constraint ? node.constraint :
8162             isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] ? node.parent.constraint :
8163                 undefined;
8164     }
8165     ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter;
8166     function isNumericLiteral(node) {
8167         return node.kind === 8;
8168     }
8169     ts.isNumericLiteral = isNumericLiteral;
8170     function isBigIntLiteral(node) {
8171         return node.kind === 9;
8172     }
8173     ts.isBigIntLiteral = isBigIntLiteral;
8174     function isStringLiteral(node) {
8175         return node.kind === 10;
8176     }
8177     ts.isStringLiteral = isStringLiteral;
8178     function isJsxText(node) {
8179         return node.kind === 11;
8180     }
8181     ts.isJsxText = isJsxText;
8182     function isRegularExpressionLiteral(node) {
8183         return node.kind === 13;
8184     }
8185     ts.isRegularExpressionLiteral = isRegularExpressionLiteral;
8186     function isNoSubstitutionTemplateLiteral(node) {
8187         return node.kind === 14;
8188     }
8189     ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral;
8190     function isTemplateHead(node) {
8191         return node.kind === 15;
8192     }
8193     ts.isTemplateHead = isTemplateHead;
8194     function isTemplateMiddle(node) {
8195         return node.kind === 16;
8196     }
8197     ts.isTemplateMiddle = isTemplateMiddle;
8198     function isTemplateTail(node) {
8199         return node.kind === 17;
8200     }
8201     ts.isTemplateTail = isTemplateTail;
8202     function isIdentifier(node) {
8203         return node.kind === 75;
8204     }
8205     ts.isIdentifier = isIdentifier;
8206     function isQualifiedName(node) {
8207         return node.kind === 153;
8208     }
8209     ts.isQualifiedName = isQualifiedName;
8210     function isComputedPropertyName(node) {
8211         return node.kind === 154;
8212     }
8213     ts.isComputedPropertyName = isComputedPropertyName;
8214     function isPrivateIdentifier(node) {
8215         return node.kind === 76;
8216     }
8217     ts.isPrivateIdentifier = isPrivateIdentifier;
8218     function isIdentifierOrPrivateIdentifier(node) {
8219         return node.kind === 75 || node.kind === 76;
8220     }
8221     ts.isIdentifierOrPrivateIdentifier = isIdentifierOrPrivateIdentifier;
8222     function isTypeParameterDeclaration(node) {
8223         return node.kind === 155;
8224     }
8225     ts.isTypeParameterDeclaration = isTypeParameterDeclaration;
8226     function isParameter(node) {
8227         return node.kind === 156;
8228     }
8229     ts.isParameter = isParameter;
8230     function isDecorator(node) {
8231         return node.kind === 157;
8232     }
8233     ts.isDecorator = isDecorator;
8234     function isPropertySignature(node) {
8235         return node.kind === 158;
8236     }
8237     ts.isPropertySignature = isPropertySignature;
8238     function isPropertyDeclaration(node) {
8239         return node.kind === 159;
8240     }
8241     ts.isPropertyDeclaration = isPropertyDeclaration;
8242     function isMethodSignature(node) {
8243         return node.kind === 160;
8244     }
8245     ts.isMethodSignature = isMethodSignature;
8246     function isMethodDeclaration(node) {
8247         return node.kind === 161;
8248     }
8249     ts.isMethodDeclaration = isMethodDeclaration;
8250     function isConstructorDeclaration(node) {
8251         return node.kind === 162;
8252     }
8253     ts.isConstructorDeclaration = isConstructorDeclaration;
8254     function isGetAccessorDeclaration(node) {
8255         return node.kind === 163;
8256     }
8257     ts.isGetAccessorDeclaration = isGetAccessorDeclaration;
8258     function isSetAccessorDeclaration(node) {
8259         return node.kind === 164;
8260     }
8261     ts.isSetAccessorDeclaration = isSetAccessorDeclaration;
8262     function isCallSignatureDeclaration(node) {
8263         return node.kind === 165;
8264     }
8265     ts.isCallSignatureDeclaration = isCallSignatureDeclaration;
8266     function isConstructSignatureDeclaration(node) {
8267         return node.kind === 166;
8268     }
8269     ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration;
8270     function isIndexSignatureDeclaration(node) {
8271         return node.kind === 167;
8272     }
8273     ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration;
8274     function isGetOrSetAccessorDeclaration(node) {
8275         return node.kind === 164 || node.kind === 163;
8276     }
8277     ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration;
8278     function isTypePredicateNode(node) {
8279         return node.kind === 168;
8280     }
8281     ts.isTypePredicateNode = isTypePredicateNode;
8282     function isTypeReferenceNode(node) {
8283         return node.kind === 169;
8284     }
8285     ts.isTypeReferenceNode = isTypeReferenceNode;
8286     function isFunctionTypeNode(node) {
8287         return node.kind === 170;
8288     }
8289     ts.isFunctionTypeNode = isFunctionTypeNode;
8290     function isConstructorTypeNode(node) {
8291         return node.kind === 171;
8292     }
8293     ts.isConstructorTypeNode = isConstructorTypeNode;
8294     function isTypeQueryNode(node) {
8295         return node.kind === 172;
8296     }
8297     ts.isTypeQueryNode = isTypeQueryNode;
8298     function isTypeLiteralNode(node) {
8299         return node.kind === 173;
8300     }
8301     ts.isTypeLiteralNode = isTypeLiteralNode;
8302     function isArrayTypeNode(node) {
8303         return node.kind === 174;
8304     }
8305     ts.isArrayTypeNode = isArrayTypeNode;
8306     function isTupleTypeNode(node) {
8307         return node.kind === 175;
8308     }
8309     ts.isTupleTypeNode = isTupleTypeNode;
8310     function isUnionTypeNode(node) {
8311         return node.kind === 178;
8312     }
8313     ts.isUnionTypeNode = isUnionTypeNode;
8314     function isIntersectionTypeNode(node) {
8315         return node.kind === 179;
8316     }
8317     ts.isIntersectionTypeNode = isIntersectionTypeNode;
8318     function isConditionalTypeNode(node) {
8319         return node.kind === 180;
8320     }
8321     ts.isConditionalTypeNode = isConditionalTypeNode;
8322     function isInferTypeNode(node) {
8323         return node.kind === 181;
8324     }
8325     ts.isInferTypeNode = isInferTypeNode;
8326     function isParenthesizedTypeNode(node) {
8327         return node.kind === 182;
8328     }
8329     ts.isParenthesizedTypeNode = isParenthesizedTypeNode;
8330     function isThisTypeNode(node) {
8331         return node.kind === 183;
8332     }
8333     ts.isThisTypeNode = isThisTypeNode;
8334     function isTypeOperatorNode(node) {
8335         return node.kind === 184;
8336     }
8337     ts.isTypeOperatorNode = isTypeOperatorNode;
8338     function isIndexedAccessTypeNode(node) {
8339         return node.kind === 185;
8340     }
8341     ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode;
8342     function isMappedTypeNode(node) {
8343         return node.kind === 186;
8344     }
8345     ts.isMappedTypeNode = isMappedTypeNode;
8346     function isLiteralTypeNode(node) {
8347         return node.kind === 187;
8348     }
8349     ts.isLiteralTypeNode = isLiteralTypeNode;
8350     function isImportTypeNode(node) {
8351         return node.kind === 188;
8352     }
8353     ts.isImportTypeNode = isImportTypeNode;
8354     function isObjectBindingPattern(node) {
8355         return node.kind === 189;
8356     }
8357     ts.isObjectBindingPattern = isObjectBindingPattern;
8358     function isArrayBindingPattern(node) {
8359         return node.kind === 190;
8360     }
8361     ts.isArrayBindingPattern = isArrayBindingPattern;
8362     function isBindingElement(node) {
8363         return node.kind === 191;
8364     }
8365     ts.isBindingElement = isBindingElement;
8366     function isArrayLiteralExpression(node) {
8367         return node.kind === 192;
8368     }
8369     ts.isArrayLiteralExpression = isArrayLiteralExpression;
8370     function isObjectLiteralExpression(node) {
8371         return node.kind === 193;
8372     }
8373     ts.isObjectLiteralExpression = isObjectLiteralExpression;
8374     function isPropertyAccessExpression(node) {
8375         return node.kind === 194;
8376     }
8377     ts.isPropertyAccessExpression = isPropertyAccessExpression;
8378     function isPropertyAccessChain(node) {
8379         return isPropertyAccessExpression(node) && !!(node.flags & 32);
8380     }
8381     ts.isPropertyAccessChain = isPropertyAccessChain;
8382     function isElementAccessExpression(node) {
8383         return node.kind === 195;
8384     }
8385     ts.isElementAccessExpression = isElementAccessExpression;
8386     function isElementAccessChain(node) {
8387         return isElementAccessExpression(node) && !!(node.flags & 32);
8388     }
8389     ts.isElementAccessChain = isElementAccessChain;
8390     function isCallExpression(node) {
8391         return node.kind === 196;
8392     }
8393     ts.isCallExpression = isCallExpression;
8394     function isCallChain(node) {
8395         return isCallExpression(node) && !!(node.flags & 32);
8396     }
8397     ts.isCallChain = isCallChain;
8398     function isOptionalChain(node) {
8399         var kind = node.kind;
8400         return !!(node.flags & 32) &&
8401             (kind === 194
8402                 || kind === 195
8403                 || kind === 196
8404                 || kind === 218);
8405     }
8406     ts.isOptionalChain = isOptionalChain;
8407     function isOptionalChainRoot(node) {
8408         return isOptionalChain(node) && !isNonNullExpression(node) && !!node.questionDotToken;
8409     }
8410     ts.isOptionalChainRoot = isOptionalChainRoot;
8411     function isExpressionOfOptionalChainRoot(node) {
8412         return isOptionalChainRoot(node.parent) && node.parent.expression === node;
8413     }
8414     ts.isExpressionOfOptionalChainRoot = isExpressionOfOptionalChainRoot;
8415     function isOutermostOptionalChain(node) {
8416         return !isOptionalChain(node.parent)
8417             || isOptionalChainRoot(node.parent)
8418             || node !== node.parent.expression;
8419     }
8420     ts.isOutermostOptionalChain = isOutermostOptionalChain;
8421     function isNullishCoalesce(node) {
8422         return node.kind === 209 && node.operatorToken.kind === 60;
8423     }
8424     ts.isNullishCoalesce = isNullishCoalesce;
8425     function isNewExpression(node) {
8426         return node.kind === 197;
8427     }
8428     ts.isNewExpression = isNewExpression;
8429     function isTaggedTemplateExpression(node) {
8430         return node.kind === 198;
8431     }
8432     ts.isTaggedTemplateExpression = isTaggedTemplateExpression;
8433     function isTypeAssertion(node) {
8434         return node.kind === 199;
8435     }
8436     ts.isTypeAssertion = isTypeAssertion;
8437     function isConstTypeReference(node) {
8438         return isTypeReferenceNode(node) && isIdentifier(node.typeName) &&
8439             node.typeName.escapedText === "const" && !node.typeArguments;
8440     }
8441     ts.isConstTypeReference = isConstTypeReference;
8442     function isParenthesizedExpression(node) {
8443         return node.kind === 200;
8444     }
8445     ts.isParenthesizedExpression = isParenthesizedExpression;
8446     function skipPartiallyEmittedExpressions(node) {
8447         return ts.skipOuterExpressions(node, 8);
8448     }
8449     ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions;
8450     function isFunctionExpression(node) {
8451         return node.kind === 201;
8452     }
8453     ts.isFunctionExpression = isFunctionExpression;
8454     function isArrowFunction(node) {
8455         return node.kind === 202;
8456     }
8457     ts.isArrowFunction = isArrowFunction;
8458     function isDeleteExpression(node) {
8459         return node.kind === 203;
8460     }
8461     ts.isDeleteExpression = isDeleteExpression;
8462     function isTypeOfExpression(node) {
8463         return node.kind === 204;
8464     }
8465     ts.isTypeOfExpression = isTypeOfExpression;
8466     function isVoidExpression(node) {
8467         return node.kind === 205;
8468     }
8469     ts.isVoidExpression = isVoidExpression;
8470     function isAwaitExpression(node) {
8471         return node.kind === 206;
8472     }
8473     ts.isAwaitExpression = isAwaitExpression;
8474     function isPrefixUnaryExpression(node) {
8475         return node.kind === 207;
8476     }
8477     ts.isPrefixUnaryExpression = isPrefixUnaryExpression;
8478     function isPostfixUnaryExpression(node) {
8479         return node.kind === 208;
8480     }
8481     ts.isPostfixUnaryExpression = isPostfixUnaryExpression;
8482     function isBinaryExpression(node) {
8483         return node.kind === 209;
8484     }
8485     ts.isBinaryExpression = isBinaryExpression;
8486     function isConditionalExpression(node) {
8487         return node.kind === 210;
8488     }
8489     ts.isConditionalExpression = isConditionalExpression;
8490     function isTemplateExpression(node) {
8491         return node.kind === 211;
8492     }
8493     ts.isTemplateExpression = isTemplateExpression;
8494     function isYieldExpression(node) {
8495         return node.kind === 212;
8496     }
8497     ts.isYieldExpression = isYieldExpression;
8498     function isSpreadElement(node) {
8499         return node.kind === 213;
8500     }
8501     ts.isSpreadElement = isSpreadElement;
8502     function isClassExpression(node) {
8503         return node.kind === 214;
8504     }
8505     ts.isClassExpression = isClassExpression;
8506     function isOmittedExpression(node) {
8507         return node.kind === 215;
8508     }
8509     ts.isOmittedExpression = isOmittedExpression;
8510     function isExpressionWithTypeArguments(node) {
8511         return node.kind === 216;
8512     }
8513     ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments;
8514     function isAsExpression(node) {
8515         return node.kind === 217;
8516     }
8517     ts.isAsExpression = isAsExpression;
8518     function isNonNullExpression(node) {
8519         return node.kind === 218;
8520     }
8521     ts.isNonNullExpression = isNonNullExpression;
8522     function isNonNullChain(node) {
8523         return isNonNullExpression(node) && !!(node.flags & 32);
8524     }
8525     ts.isNonNullChain = isNonNullChain;
8526     function isMetaProperty(node) {
8527         return node.kind === 219;
8528     }
8529     ts.isMetaProperty = isMetaProperty;
8530     function isTemplateSpan(node) {
8531         return node.kind === 221;
8532     }
8533     ts.isTemplateSpan = isTemplateSpan;
8534     function isSemicolonClassElement(node) {
8535         return node.kind === 222;
8536     }
8537     ts.isSemicolonClassElement = isSemicolonClassElement;
8538     function isBlock(node) {
8539         return node.kind === 223;
8540     }
8541     ts.isBlock = isBlock;
8542     function isVariableStatement(node) {
8543         return node.kind === 225;
8544     }
8545     ts.isVariableStatement = isVariableStatement;
8546     function isEmptyStatement(node) {
8547         return node.kind === 224;
8548     }
8549     ts.isEmptyStatement = isEmptyStatement;
8550     function isExpressionStatement(node) {
8551         return node.kind === 226;
8552     }
8553     ts.isExpressionStatement = isExpressionStatement;
8554     function isIfStatement(node) {
8555         return node.kind === 227;
8556     }
8557     ts.isIfStatement = isIfStatement;
8558     function isDoStatement(node) {
8559         return node.kind === 228;
8560     }
8561     ts.isDoStatement = isDoStatement;
8562     function isWhileStatement(node) {
8563         return node.kind === 229;
8564     }
8565     ts.isWhileStatement = isWhileStatement;
8566     function isForStatement(node) {
8567         return node.kind === 230;
8568     }
8569     ts.isForStatement = isForStatement;
8570     function isForInStatement(node) {
8571         return node.kind === 231;
8572     }
8573     ts.isForInStatement = isForInStatement;
8574     function isForOfStatement(node) {
8575         return node.kind === 232;
8576     }
8577     ts.isForOfStatement = isForOfStatement;
8578     function isContinueStatement(node) {
8579         return node.kind === 233;
8580     }
8581     ts.isContinueStatement = isContinueStatement;
8582     function isBreakStatement(node) {
8583         return node.kind === 234;
8584     }
8585     ts.isBreakStatement = isBreakStatement;
8586     function isBreakOrContinueStatement(node) {
8587         return node.kind === 234 || node.kind === 233;
8588     }
8589     ts.isBreakOrContinueStatement = isBreakOrContinueStatement;
8590     function isReturnStatement(node) {
8591         return node.kind === 235;
8592     }
8593     ts.isReturnStatement = isReturnStatement;
8594     function isWithStatement(node) {
8595         return node.kind === 236;
8596     }
8597     ts.isWithStatement = isWithStatement;
8598     function isSwitchStatement(node) {
8599         return node.kind === 237;
8600     }
8601     ts.isSwitchStatement = isSwitchStatement;
8602     function isLabeledStatement(node) {
8603         return node.kind === 238;
8604     }
8605     ts.isLabeledStatement = isLabeledStatement;
8606     function isThrowStatement(node) {
8607         return node.kind === 239;
8608     }
8609     ts.isThrowStatement = isThrowStatement;
8610     function isTryStatement(node) {
8611         return node.kind === 240;
8612     }
8613     ts.isTryStatement = isTryStatement;
8614     function isDebuggerStatement(node) {
8615         return node.kind === 241;
8616     }
8617     ts.isDebuggerStatement = isDebuggerStatement;
8618     function isVariableDeclaration(node) {
8619         return node.kind === 242;
8620     }
8621     ts.isVariableDeclaration = isVariableDeclaration;
8622     function isVariableDeclarationList(node) {
8623         return node.kind === 243;
8624     }
8625     ts.isVariableDeclarationList = isVariableDeclarationList;
8626     function isFunctionDeclaration(node) {
8627         return node.kind === 244;
8628     }
8629     ts.isFunctionDeclaration = isFunctionDeclaration;
8630     function isClassDeclaration(node) {
8631         return node.kind === 245;
8632     }
8633     ts.isClassDeclaration = isClassDeclaration;
8634     function isInterfaceDeclaration(node) {
8635         return node.kind === 246;
8636     }
8637     ts.isInterfaceDeclaration = isInterfaceDeclaration;
8638     function isTypeAliasDeclaration(node) {
8639         return node.kind === 247;
8640     }
8641     ts.isTypeAliasDeclaration = isTypeAliasDeclaration;
8642     function isEnumDeclaration(node) {
8643         return node.kind === 248;
8644     }
8645     ts.isEnumDeclaration = isEnumDeclaration;
8646     function isModuleDeclaration(node) {
8647         return node.kind === 249;
8648     }
8649     ts.isModuleDeclaration = isModuleDeclaration;
8650     function isModuleBlock(node) {
8651         return node.kind === 250;
8652     }
8653     ts.isModuleBlock = isModuleBlock;
8654     function isCaseBlock(node) {
8655         return node.kind === 251;
8656     }
8657     ts.isCaseBlock = isCaseBlock;
8658     function isNamespaceExportDeclaration(node) {
8659         return node.kind === 252;
8660     }
8661     ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration;
8662     function isImportEqualsDeclaration(node) {
8663         return node.kind === 253;
8664     }
8665     ts.isImportEqualsDeclaration = isImportEqualsDeclaration;
8666     function isImportDeclaration(node) {
8667         return node.kind === 254;
8668     }
8669     ts.isImportDeclaration = isImportDeclaration;
8670     function isImportClause(node) {
8671         return node.kind === 255;
8672     }
8673     ts.isImportClause = isImportClause;
8674     function isNamespaceImport(node) {
8675         return node.kind === 256;
8676     }
8677     ts.isNamespaceImport = isNamespaceImport;
8678     function isNamespaceExport(node) {
8679         return node.kind === 262;
8680     }
8681     ts.isNamespaceExport = isNamespaceExport;
8682     function isNamedExportBindings(node) {
8683         return node.kind === 262 || node.kind === 261;
8684     }
8685     ts.isNamedExportBindings = isNamedExportBindings;
8686     function isNamedImports(node) {
8687         return node.kind === 257;
8688     }
8689     ts.isNamedImports = isNamedImports;
8690     function isImportSpecifier(node) {
8691         return node.kind === 258;
8692     }
8693     ts.isImportSpecifier = isImportSpecifier;
8694     function isExportAssignment(node) {
8695         return node.kind === 259;
8696     }
8697     ts.isExportAssignment = isExportAssignment;
8698     function isExportDeclaration(node) {
8699         return node.kind === 260;
8700     }
8701     ts.isExportDeclaration = isExportDeclaration;
8702     function isNamedExports(node) {
8703         return node.kind === 261;
8704     }
8705     ts.isNamedExports = isNamedExports;
8706     function isExportSpecifier(node) {
8707         return node.kind === 263;
8708     }
8709     ts.isExportSpecifier = isExportSpecifier;
8710     function isMissingDeclaration(node) {
8711         return node.kind === 264;
8712     }
8713     ts.isMissingDeclaration = isMissingDeclaration;
8714     function isExternalModuleReference(node) {
8715         return node.kind === 265;
8716     }
8717     ts.isExternalModuleReference = isExternalModuleReference;
8718     function isJsxElement(node) {
8719         return node.kind === 266;
8720     }
8721     ts.isJsxElement = isJsxElement;
8722     function isJsxSelfClosingElement(node) {
8723         return node.kind === 267;
8724     }
8725     ts.isJsxSelfClosingElement = isJsxSelfClosingElement;
8726     function isJsxOpeningElement(node) {
8727         return node.kind === 268;
8728     }
8729     ts.isJsxOpeningElement = isJsxOpeningElement;
8730     function isJsxClosingElement(node) {
8731         return node.kind === 269;
8732     }
8733     ts.isJsxClosingElement = isJsxClosingElement;
8734     function isJsxFragment(node) {
8735         return node.kind === 270;
8736     }
8737     ts.isJsxFragment = isJsxFragment;
8738     function isJsxOpeningFragment(node) {
8739         return node.kind === 271;
8740     }
8741     ts.isJsxOpeningFragment = isJsxOpeningFragment;
8742     function isJsxClosingFragment(node) {
8743         return node.kind === 272;
8744     }
8745     ts.isJsxClosingFragment = isJsxClosingFragment;
8746     function isJsxAttribute(node) {
8747         return node.kind === 273;
8748     }
8749     ts.isJsxAttribute = isJsxAttribute;
8750     function isJsxAttributes(node) {
8751         return node.kind === 274;
8752     }
8753     ts.isJsxAttributes = isJsxAttributes;
8754     function isJsxSpreadAttribute(node) {
8755         return node.kind === 275;
8756     }
8757     ts.isJsxSpreadAttribute = isJsxSpreadAttribute;
8758     function isJsxExpression(node) {
8759         return node.kind === 276;
8760     }
8761     ts.isJsxExpression = isJsxExpression;
8762     function isCaseClause(node) {
8763         return node.kind === 277;
8764     }
8765     ts.isCaseClause = isCaseClause;
8766     function isDefaultClause(node) {
8767         return node.kind === 278;
8768     }
8769     ts.isDefaultClause = isDefaultClause;
8770     function isHeritageClause(node) {
8771         return node.kind === 279;
8772     }
8773     ts.isHeritageClause = isHeritageClause;
8774     function isCatchClause(node) {
8775         return node.kind === 280;
8776     }
8777     ts.isCatchClause = isCatchClause;
8778     function isPropertyAssignment(node) {
8779         return node.kind === 281;
8780     }
8781     ts.isPropertyAssignment = isPropertyAssignment;
8782     function isShorthandPropertyAssignment(node) {
8783         return node.kind === 282;
8784     }
8785     ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment;
8786     function isSpreadAssignment(node) {
8787         return node.kind === 283;
8788     }
8789     ts.isSpreadAssignment = isSpreadAssignment;
8790     function isEnumMember(node) {
8791         return node.kind === 284;
8792     }
8793     ts.isEnumMember = isEnumMember;
8794     function isSourceFile(node) {
8795         return node.kind === 290;
8796     }
8797     ts.isSourceFile = isSourceFile;
8798     function isBundle(node) {
8799         return node.kind === 291;
8800     }
8801     ts.isBundle = isBundle;
8802     function isUnparsedSource(node) {
8803         return node.kind === 292;
8804     }
8805     ts.isUnparsedSource = isUnparsedSource;
8806     function isUnparsedPrepend(node) {
8807         return node.kind === 286;
8808     }
8809     ts.isUnparsedPrepend = isUnparsedPrepend;
8810     function isUnparsedTextLike(node) {
8811         switch (node.kind) {
8812             case 287:
8813             case 288:
8814                 return true;
8815             default:
8816                 return false;
8817         }
8818     }
8819     ts.isUnparsedTextLike = isUnparsedTextLike;
8820     function isUnparsedNode(node) {
8821         return isUnparsedTextLike(node) ||
8822             node.kind === 285 ||
8823             node.kind === 289;
8824     }
8825     ts.isUnparsedNode = isUnparsedNode;
8826     function isJSDocTypeExpression(node) {
8827         return node.kind === 294;
8828     }
8829     ts.isJSDocTypeExpression = isJSDocTypeExpression;
8830     function isJSDocAllType(node) {
8831         return node.kind === 295;
8832     }
8833     ts.isJSDocAllType = isJSDocAllType;
8834     function isJSDocUnknownType(node) {
8835         return node.kind === 296;
8836     }
8837     ts.isJSDocUnknownType = isJSDocUnknownType;
8838     function isJSDocNullableType(node) {
8839         return node.kind === 297;
8840     }
8841     ts.isJSDocNullableType = isJSDocNullableType;
8842     function isJSDocNonNullableType(node) {
8843         return node.kind === 298;
8844     }
8845     ts.isJSDocNonNullableType = isJSDocNonNullableType;
8846     function isJSDocOptionalType(node) {
8847         return node.kind === 299;
8848     }
8849     ts.isJSDocOptionalType = isJSDocOptionalType;
8850     function isJSDocFunctionType(node) {
8851         return node.kind === 300;
8852     }
8853     ts.isJSDocFunctionType = isJSDocFunctionType;
8854     function isJSDocVariadicType(node) {
8855         return node.kind === 301;
8856     }
8857     ts.isJSDocVariadicType = isJSDocVariadicType;
8858     function isJSDoc(node) {
8859         return node.kind === 303;
8860     }
8861     ts.isJSDoc = isJSDoc;
8862     function isJSDocAuthorTag(node) {
8863         return node.kind === 309;
8864     }
8865     ts.isJSDocAuthorTag = isJSDocAuthorTag;
8866     function isJSDocAugmentsTag(node) {
8867         return node.kind === 307;
8868     }
8869     ts.isJSDocAugmentsTag = isJSDocAugmentsTag;
8870     function isJSDocImplementsTag(node) {
8871         return node.kind === 308;
8872     }
8873     ts.isJSDocImplementsTag = isJSDocImplementsTag;
8874     function isJSDocClassTag(node) {
8875         return node.kind === 310;
8876     }
8877     ts.isJSDocClassTag = isJSDocClassTag;
8878     function isJSDocPublicTag(node) {
8879         return node.kind === 311;
8880     }
8881     ts.isJSDocPublicTag = isJSDocPublicTag;
8882     function isJSDocPrivateTag(node) {
8883         return node.kind === 312;
8884     }
8885     ts.isJSDocPrivateTag = isJSDocPrivateTag;
8886     function isJSDocProtectedTag(node) {
8887         return node.kind === 313;
8888     }
8889     ts.isJSDocProtectedTag = isJSDocProtectedTag;
8890     function isJSDocReadonlyTag(node) {
8891         return node.kind === 314;
8892     }
8893     ts.isJSDocReadonlyTag = isJSDocReadonlyTag;
8894     function isJSDocEnumTag(node) {
8895         return node.kind === 316;
8896     }
8897     ts.isJSDocEnumTag = isJSDocEnumTag;
8898     function isJSDocThisTag(node) {
8899         return node.kind === 319;
8900     }
8901     ts.isJSDocThisTag = isJSDocThisTag;
8902     function isJSDocParameterTag(node) {
8903         return node.kind === 317;
8904     }
8905     ts.isJSDocParameterTag = isJSDocParameterTag;
8906     function isJSDocReturnTag(node) {
8907         return node.kind === 318;
8908     }
8909     ts.isJSDocReturnTag = isJSDocReturnTag;
8910     function isJSDocTypeTag(node) {
8911         return node.kind === 320;
8912     }
8913     ts.isJSDocTypeTag = isJSDocTypeTag;
8914     function isJSDocTemplateTag(node) {
8915         return node.kind === 321;
8916     }
8917     ts.isJSDocTemplateTag = isJSDocTemplateTag;
8918     function isJSDocTypedefTag(node) {
8919         return node.kind === 322;
8920     }
8921     ts.isJSDocTypedefTag = isJSDocTypedefTag;
8922     function isJSDocPropertyTag(node) {
8923         return node.kind === 323;
8924     }
8925     ts.isJSDocPropertyTag = isJSDocPropertyTag;
8926     function isJSDocPropertyLikeTag(node) {
8927         return node.kind === 323 || node.kind === 317;
8928     }
8929     ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag;
8930     function isJSDocTypeLiteral(node) {
8931         return node.kind === 304;
8932     }
8933     ts.isJSDocTypeLiteral = isJSDocTypeLiteral;
8934     function isJSDocCallbackTag(node) {
8935         return node.kind === 315;
8936     }
8937     ts.isJSDocCallbackTag = isJSDocCallbackTag;
8938     function isJSDocSignature(node) {
8939         return node.kind === 305;
8940     }
8941     ts.isJSDocSignature = isJSDocSignature;
8942     function isSyntaxList(n) {
8943         return n.kind === 324;
8944     }
8945     ts.isSyntaxList = isSyntaxList;
8946     function isNode(node) {
8947         return isNodeKind(node.kind);
8948     }
8949     ts.isNode = isNode;
8950     function isNodeKind(kind) {
8951         return kind >= 153;
8952     }
8953     ts.isNodeKind = isNodeKind;
8954     function isToken(n) {
8955         return n.kind >= 0 && n.kind <= 152;
8956     }
8957     ts.isToken = isToken;
8958     function isNodeArray(array) {
8959         return array.hasOwnProperty("pos") && array.hasOwnProperty("end");
8960     }
8961     ts.isNodeArray = isNodeArray;
8962     function isLiteralKind(kind) {
8963         return 8 <= kind && kind <= 14;
8964     }
8965     ts.isLiteralKind = isLiteralKind;
8966     function isLiteralExpression(node) {
8967         return isLiteralKind(node.kind);
8968     }
8969     ts.isLiteralExpression = isLiteralExpression;
8970     function isTemplateLiteralKind(kind) {
8971         return 14 <= kind && kind <= 17;
8972     }
8973     ts.isTemplateLiteralKind = isTemplateLiteralKind;
8974     function isTemplateLiteralToken(node) {
8975         return isTemplateLiteralKind(node.kind);
8976     }
8977     ts.isTemplateLiteralToken = isTemplateLiteralToken;
8978     function isTemplateMiddleOrTemplateTail(node) {
8979         var kind = node.kind;
8980         return kind === 16
8981             || kind === 17;
8982     }
8983     ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail;
8984     function isImportOrExportSpecifier(node) {
8985         return isImportSpecifier(node) || isExportSpecifier(node);
8986     }
8987     ts.isImportOrExportSpecifier = isImportOrExportSpecifier;
8988     function isTypeOnlyImportOrExportDeclaration(node) {
8989         switch (node.kind) {
8990             case 258:
8991             case 263:
8992                 return node.parent.parent.isTypeOnly;
8993             case 256:
8994                 return node.parent.isTypeOnly;
8995             case 255:
8996                 return node.isTypeOnly;
8997             default:
8998                 return false;
8999         }
9000     }
9001     ts.isTypeOnlyImportOrExportDeclaration = isTypeOnlyImportOrExportDeclaration;
9002     function isStringTextContainingNode(node) {
9003         return node.kind === 10 || isTemplateLiteralKind(node.kind);
9004     }
9005     ts.isStringTextContainingNode = isStringTextContainingNode;
9006     function isGeneratedIdentifier(node) {
9007         return isIdentifier(node) && (node.autoGenerateFlags & 7) > 0;
9008     }
9009     ts.isGeneratedIdentifier = isGeneratedIdentifier;
9010     function isPrivateIdentifierPropertyDeclaration(node) {
9011         return isPropertyDeclaration(node) && isPrivateIdentifier(node.name);
9012     }
9013     ts.isPrivateIdentifierPropertyDeclaration = isPrivateIdentifierPropertyDeclaration;
9014     function isPrivateIdentifierPropertyAccessExpression(node) {
9015         return isPropertyAccessExpression(node) && isPrivateIdentifier(node.name);
9016     }
9017     ts.isPrivateIdentifierPropertyAccessExpression = isPrivateIdentifierPropertyAccessExpression;
9018     function isModifierKind(token) {
9019         switch (token) {
9020             case 122:
9021             case 126:
9022             case 81:
9023             case 130:
9024             case 84:
9025             case 89:
9026             case 119:
9027             case 117:
9028             case 118:
9029             case 138:
9030             case 120:
9031                 return true;
9032         }
9033         return false;
9034     }
9035     ts.isModifierKind = isModifierKind;
9036     function isParameterPropertyModifier(kind) {
9037         return !!(ts.modifierToFlag(kind) & 92);
9038     }
9039     ts.isParameterPropertyModifier = isParameterPropertyModifier;
9040     function isClassMemberModifier(idToken) {
9041         return isParameterPropertyModifier(idToken) || idToken === 120;
9042     }
9043     ts.isClassMemberModifier = isClassMemberModifier;
9044     function isModifier(node) {
9045         return isModifierKind(node.kind);
9046     }
9047     ts.isModifier = isModifier;
9048     function isEntityName(node) {
9049         var kind = node.kind;
9050         return kind === 153
9051             || kind === 75;
9052     }
9053     ts.isEntityName = isEntityName;
9054     function isPropertyName(node) {
9055         var kind = node.kind;
9056         return kind === 75
9057             || kind === 76
9058             || kind === 10
9059             || kind === 8
9060             || kind === 154;
9061     }
9062     ts.isPropertyName = isPropertyName;
9063     function isBindingName(node) {
9064         var kind = node.kind;
9065         return kind === 75
9066             || kind === 189
9067             || kind === 190;
9068     }
9069     ts.isBindingName = isBindingName;
9070     function isFunctionLike(node) {
9071         return node && isFunctionLikeKind(node.kind);
9072     }
9073     ts.isFunctionLike = isFunctionLike;
9074     function isFunctionLikeDeclaration(node) {
9075         return node && isFunctionLikeDeclarationKind(node.kind);
9076     }
9077     ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration;
9078     function isFunctionLikeDeclarationKind(kind) {
9079         switch (kind) {
9080             case 244:
9081             case 161:
9082             case 162:
9083             case 163:
9084             case 164:
9085             case 201:
9086             case 202:
9087                 return true;
9088             default:
9089                 return false;
9090         }
9091     }
9092     function isFunctionLikeKind(kind) {
9093         switch (kind) {
9094             case 160:
9095             case 165:
9096             case 305:
9097             case 166:
9098             case 167:
9099             case 170:
9100             case 300:
9101             case 171:
9102                 return true;
9103             default:
9104                 return isFunctionLikeDeclarationKind(kind);
9105         }
9106     }
9107     ts.isFunctionLikeKind = isFunctionLikeKind;
9108     function isFunctionOrModuleBlock(node) {
9109         return isSourceFile(node) || isModuleBlock(node) || isBlock(node) && isFunctionLike(node.parent);
9110     }
9111     ts.isFunctionOrModuleBlock = isFunctionOrModuleBlock;
9112     function isClassElement(node) {
9113         var kind = node.kind;
9114         return kind === 162
9115             || kind === 159
9116             || kind === 161
9117             || kind === 163
9118             || kind === 164
9119             || kind === 167
9120             || kind === 222;
9121     }
9122     ts.isClassElement = isClassElement;
9123     function isClassLike(node) {
9124         return node && (node.kind === 245 || node.kind === 214);
9125     }
9126     ts.isClassLike = isClassLike;
9127     function isAccessor(node) {
9128         return node && (node.kind === 163 || node.kind === 164);
9129     }
9130     ts.isAccessor = isAccessor;
9131     function isMethodOrAccessor(node) {
9132         switch (node.kind) {
9133             case 161:
9134             case 163:
9135             case 164:
9136                 return true;
9137             default:
9138                 return false;
9139         }
9140     }
9141     ts.isMethodOrAccessor = isMethodOrAccessor;
9142     function isTypeElement(node) {
9143         var kind = node.kind;
9144         return kind === 166
9145             || kind === 165
9146             || kind === 158
9147             || kind === 160
9148             || kind === 167;
9149     }
9150     ts.isTypeElement = isTypeElement;
9151     function isClassOrTypeElement(node) {
9152         return isTypeElement(node) || isClassElement(node);
9153     }
9154     ts.isClassOrTypeElement = isClassOrTypeElement;
9155     function isObjectLiteralElementLike(node) {
9156         var kind = node.kind;
9157         return kind === 281
9158             || kind === 282
9159             || kind === 283
9160             || kind === 161
9161             || kind === 163
9162             || kind === 164;
9163     }
9164     ts.isObjectLiteralElementLike = isObjectLiteralElementLike;
9165     function isTypeNode(node) {
9166         return ts.isTypeNodeKind(node.kind);
9167     }
9168     ts.isTypeNode = isTypeNode;
9169     function isFunctionOrConstructorTypeNode(node) {
9170         switch (node.kind) {
9171             case 170:
9172             case 171:
9173                 return true;
9174         }
9175         return false;
9176     }
9177     ts.isFunctionOrConstructorTypeNode = isFunctionOrConstructorTypeNode;
9178     function isBindingPattern(node) {
9179         if (node) {
9180             var kind = node.kind;
9181             return kind === 190
9182                 || kind === 189;
9183         }
9184         return false;
9185     }
9186     ts.isBindingPattern = isBindingPattern;
9187     function isAssignmentPattern(node) {
9188         var kind = node.kind;
9189         return kind === 192
9190             || kind === 193;
9191     }
9192     ts.isAssignmentPattern = isAssignmentPattern;
9193     function isArrayBindingElement(node) {
9194         var kind = node.kind;
9195         return kind === 191
9196             || kind === 215;
9197     }
9198     ts.isArrayBindingElement = isArrayBindingElement;
9199     function isDeclarationBindingElement(bindingElement) {
9200         switch (bindingElement.kind) {
9201             case 242:
9202             case 156:
9203             case 191:
9204                 return true;
9205         }
9206         return false;
9207     }
9208     ts.isDeclarationBindingElement = isDeclarationBindingElement;
9209     function isBindingOrAssignmentPattern(node) {
9210         return isObjectBindingOrAssignmentPattern(node)
9211             || isArrayBindingOrAssignmentPattern(node);
9212     }
9213     ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern;
9214     function isObjectBindingOrAssignmentPattern(node) {
9215         switch (node.kind) {
9216             case 189:
9217             case 193:
9218                 return true;
9219         }
9220         return false;
9221     }
9222     ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern;
9223     function isArrayBindingOrAssignmentPattern(node) {
9224         switch (node.kind) {
9225             case 190:
9226             case 192:
9227                 return true;
9228         }
9229         return false;
9230     }
9231     ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern;
9232     function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) {
9233         var kind = node.kind;
9234         return kind === 194
9235             || kind === 153
9236             || kind === 188;
9237     }
9238     ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode;
9239     function isPropertyAccessOrQualifiedName(node) {
9240         var kind = node.kind;
9241         return kind === 194
9242             || kind === 153;
9243     }
9244     ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName;
9245     function isCallLikeExpression(node) {
9246         switch (node.kind) {
9247             case 268:
9248             case 267:
9249             case 196:
9250             case 197:
9251             case 198:
9252             case 157:
9253                 return true;
9254             default:
9255                 return false;
9256         }
9257     }
9258     ts.isCallLikeExpression = isCallLikeExpression;
9259     function isCallOrNewExpression(node) {
9260         return node.kind === 196 || node.kind === 197;
9261     }
9262     ts.isCallOrNewExpression = isCallOrNewExpression;
9263     function isTemplateLiteral(node) {
9264         var kind = node.kind;
9265         return kind === 211
9266             || kind === 14;
9267     }
9268     ts.isTemplateLiteral = isTemplateLiteral;
9269     function isLeftHandSideExpression(node) {
9270         return isLeftHandSideExpressionKind(skipPartiallyEmittedExpressions(node).kind);
9271     }
9272     ts.isLeftHandSideExpression = isLeftHandSideExpression;
9273     function isLeftHandSideExpressionKind(kind) {
9274         switch (kind) {
9275             case 194:
9276             case 195:
9277             case 197:
9278             case 196:
9279             case 266:
9280             case 267:
9281             case 270:
9282             case 198:
9283             case 192:
9284             case 200:
9285             case 193:
9286             case 214:
9287             case 201:
9288             case 75:
9289             case 13:
9290             case 8:
9291             case 9:
9292             case 10:
9293             case 14:
9294             case 211:
9295             case 91:
9296             case 100:
9297             case 104:
9298             case 106:
9299             case 102:
9300             case 218:
9301             case 219:
9302             case 96:
9303                 return true;
9304             default:
9305                 return false;
9306         }
9307     }
9308     function isUnaryExpression(node) {
9309         return isUnaryExpressionKind(skipPartiallyEmittedExpressions(node).kind);
9310     }
9311     ts.isUnaryExpression = isUnaryExpression;
9312     function isUnaryExpressionKind(kind) {
9313         switch (kind) {
9314             case 207:
9315             case 208:
9316             case 203:
9317             case 204:
9318             case 205:
9319             case 206:
9320             case 199:
9321                 return true;
9322             default:
9323                 return isLeftHandSideExpressionKind(kind);
9324         }
9325     }
9326     function isUnaryExpressionWithWrite(expr) {
9327         switch (expr.kind) {
9328             case 208:
9329                 return true;
9330             case 207:
9331                 return expr.operator === 45 ||
9332                     expr.operator === 46;
9333             default:
9334                 return false;
9335         }
9336     }
9337     ts.isUnaryExpressionWithWrite = isUnaryExpressionWithWrite;
9338     function isExpression(node) {
9339         return isExpressionKind(skipPartiallyEmittedExpressions(node).kind);
9340     }
9341     ts.isExpression = isExpression;
9342     function isExpressionKind(kind) {
9343         switch (kind) {
9344             case 210:
9345             case 212:
9346             case 202:
9347             case 209:
9348             case 213:
9349             case 217:
9350             case 215:
9351             case 327:
9352             case 326:
9353                 return true;
9354             default:
9355                 return isUnaryExpressionKind(kind);
9356         }
9357     }
9358     function isAssertionExpression(node) {
9359         var kind = node.kind;
9360         return kind === 199
9361             || kind === 217;
9362     }
9363     ts.isAssertionExpression = isAssertionExpression;
9364     function isPartiallyEmittedExpression(node) {
9365         return node.kind === 326;
9366     }
9367     ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression;
9368     function isNotEmittedStatement(node) {
9369         return node.kind === 325;
9370     }
9371     ts.isNotEmittedStatement = isNotEmittedStatement;
9372     function isSyntheticReference(node) {
9373         return node.kind === 330;
9374     }
9375     ts.isSyntheticReference = isSyntheticReference;
9376     function isNotEmittedOrPartiallyEmittedNode(node) {
9377         return isNotEmittedStatement(node)
9378             || isPartiallyEmittedExpression(node);
9379     }
9380     ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode;
9381     function isIterationStatement(node, lookInLabeledStatements) {
9382         switch (node.kind) {
9383             case 230:
9384             case 231:
9385             case 232:
9386             case 228:
9387             case 229:
9388                 return true;
9389             case 238:
9390                 return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements);
9391         }
9392         return false;
9393     }
9394     ts.isIterationStatement = isIterationStatement;
9395     function isScopeMarker(node) {
9396         return isExportAssignment(node) || isExportDeclaration(node);
9397     }
9398     ts.isScopeMarker = isScopeMarker;
9399     function hasScopeMarker(statements) {
9400         return ts.some(statements, isScopeMarker);
9401     }
9402     ts.hasScopeMarker = hasScopeMarker;
9403     function needsScopeMarker(result) {
9404         return !ts.isAnyImportOrReExport(result) && !isExportAssignment(result) && !ts.hasModifier(result, 1) && !ts.isAmbientModule(result);
9405     }
9406     ts.needsScopeMarker = needsScopeMarker;
9407     function isExternalModuleIndicator(result) {
9408         return ts.isAnyImportOrReExport(result) || isExportAssignment(result) || ts.hasModifier(result, 1);
9409     }
9410     ts.isExternalModuleIndicator = isExternalModuleIndicator;
9411     function isForInOrOfStatement(node) {
9412         return node.kind === 231 || node.kind === 232;
9413     }
9414     ts.isForInOrOfStatement = isForInOrOfStatement;
9415     function isConciseBody(node) {
9416         return isBlock(node)
9417             || isExpression(node);
9418     }
9419     ts.isConciseBody = isConciseBody;
9420     function isFunctionBody(node) {
9421         return isBlock(node);
9422     }
9423     ts.isFunctionBody = isFunctionBody;
9424     function isForInitializer(node) {
9425         return isVariableDeclarationList(node)
9426             || isExpression(node);
9427     }
9428     ts.isForInitializer = isForInitializer;
9429     function isModuleBody(node) {
9430         var kind = node.kind;
9431         return kind === 250
9432             || kind === 249
9433             || kind === 75;
9434     }
9435     ts.isModuleBody = isModuleBody;
9436     function isNamespaceBody(node) {
9437         var kind = node.kind;
9438         return kind === 250
9439             || kind === 249;
9440     }
9441     ts.isNamespaceBody = isNamespaceBody;
9442     function isJSDocNamespaceBody(node) {
9443         var kind = node.kind;
9444         return kind === 75
9445             || kind === 249;
9446     }
9447     ts.isJSDocNamespaceBody = isJSDocNamespaceBody;
9448     function isNamedImportBindings(node) {
9449         var kind = node.kind;
9450         return kind === 257
9451             || kind === 256;
9452     }
9453     ts.isNamedImportBindings = isNamedImportBindings;
9454     function isModuleOrEnumDeclaration(node) {
9455         return node.kind === 249 || node.kind === 248;
9456     }
9457     ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration;
9458     function isDeclarationKind(kind) {
9459         return kind === 202
9460             || kind === 191
9461             || kind === 245
9462             || kind === 214
9463             || kind === 162
9464             || kind === 248
9465             || kind === 284
9466             || kind === 263
9467             || kind === 244
9468             || kind === 201
9469             || kind === 163
9470             || kind === 255
9471             || kind === 253
9472             || kind === 258
9473             || kind === 246
9474             || kind === 273
9475             || kind === 161
9476             || kind === 160
9477             || kind === 249
9478             || kind === 252
9479             || kind === 256
9480             || kind === 262
9481             || kind === 156
9482             || kind === 281
9483             || kind === 159
9484             || kind === 158
9485             || kind === 164
9486             || kind === 282
9487             || kind === 247
9488             || kind === 155
9489             || kind === 242
9490             || kind === 322
9491             || kind === 315
9492             || kind === 323;
9493     }
9494     function isDeclarationStatementKind(kind) {
9495         return kind === 244
9496             || kind === 264
9497             || kind === 245
9498             || kind === 246
9499             || kind === 247
9500             || kind === 248
9501             || kind === 249
9502             || kind === 254
9503             || kind === 253
9504             || kind === 260
9505             || kind === 259
9506             || kind === 252;
9507     }
9508     function isStatementKindButNotDeclarationKind(kind) {
9509         return kind === 234
9510             || kind === 233
9511             || kind === 241
9512             || kind === 228
9513             || kind === 226
9514             || kind === 224
9515             || kind === 231
9516             || kind === 232
9517             || kind === 230
9518             || kind === 227
9519             || kind === 238
9520             || kind === 235
9521             || kind === 237
9522             || kind === 239
9523             || kind === 240
9524             || kind === 225
9525             || kind === 229
9526             || kind === 236
9527             || kind === 325
9528             || kind === 329
9529             || kind === 328;
9530     }
9531     function isDeclaration(node) {
9532         if (node.kind === 155) {
9533             return (node.parent && node.parent.kind !== 321) || ts.isInJSFile(node);
9534         }
9535         return isDeclarationKind(node.kind);
9536     }
9537     ts.isDeclaration = isDeclaration;
9538     function isDeclarationStatement(node) {
9539         return isDeclarationStatementKind(node.kind);
9540     }
9541     ts.isDeclarationStatement = isDeclarationStatement;
9542     function isStatementButNotDeclaration(node) {
9543         return isStatementKindButNotDeclarationKind(node.kind);
9544     }
9545     ts.isStatementButNotDeclaration = isStatementButNotDeclaration;
9546     function isStatement(node) {
9547         var kind = node.kind;
9548         return isStatementKindButNotDeclarationKind(kind)
9549             || isDeclarationStatementKind(kind)
9550             || isBlockStatement(node);
9551     }
9552     ts.isStatement = isStatement;
9553     function isBlockStatement(node) {
9554         if (node.kind !== 223)
9555             return false;
9556         if (node.parent !== undefined) {
9557             if (node.parent.kind === 240 || node.parent.kind === 280) {
9558                 return false;
9559             }
9560         }
9561         return !ts.isFunctionBlock(node);
9562     }
9563     function isModuleReference(node) {
9564         var kind = node.kind;
9565         return kind === 265
9566             || kind === 153
9567             || kind === 75;
9568     }
9569     ts.isModuleReference = isModuleReference;
9570     function isJsxTagNameExpression(node) {
9571         var kind = node.kind;
9572         return kind === 104
9573             || kind === 75
9574             || kind === 194;
9575     }
9576     ts.isJsxTagNameExpression = isJsxTagNameExpression;
9577     function isJsxChild(node) {
9578         var kind = node.kind;
9579         return kind === 266
9580             || kind === 276
9581             || kind === 267
9582             || kind === 11
9583             || kind === 270;
9584     }
9585     ts.isJsxChild = isJsxChild;
9586     function isJsxAttributeLike(node) {
9587         var kind = node.kind;
9588         return kind === 273
9589             || kind === 275;
9590     }
9591     ts.isJsxAttributeLike = isJsxAttributeLike;
9592     function isStringLiteralOrJsxExpression(node) {
9593         var kind = node.kind;
9594         return kind === 10
9595             || kind === 276;
9596     }
9597     ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression;
9598     function isJsxOpeningLikeElement(node) {
9599         var kind = node.kind;
9600         return kind === 268
9601             || kind === 267;
9602     }
9603     ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement;
9604     function isCaseOrDefaultClause(node) {
9605         var kind = node.kind;
9606         return kind === 277
9607             || kind === 278;
9608     }
9609     ts.isCaseOrDefaultClause = isCaseOrDefaultClause;
9610     function isJSDocNode(node) {
9611         return node.kind >= 294 && node.kind <= 323;
9612     }
9613     ts.isJSDocNode = isJSDocNode;
9614     function isJSDocCommentContainingNode(node) {
9615         return node.kind === 303 || node.kind === 302 || isJSDocTag(node) || isJSDocTypeLiteral(node) || isJSDocSignature(node);
9616     }
9617     ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode;
9618     function isJSDocTag(node) {
9619         return node.kind >= 306 && node.kind <= 323;
9620     }
9621     ts.isJSDocTag = isJSDocTag;
9622     function isSetAccessor(node) {
9623         return node.kind === 164;
9624     }
9625     ts.isSetAccessor = isSetAccessor;
9626     function isGetAccessor(node) {
9627         return node.kind === 163;
9628     }
9629     ts.isGetAccessor = isGetAccessor;
9630     function hasJSDocNodes(node) {
9631         var jsDoc = node.jsDoc;
9632         return !!jsDoc && jsDoc.length > 0;
9633     }
9634     ts.hasJSDocNodes = hasJSDocNodes;
9635     function hasType(node) {
9636         return !!node.type;
9637     }
9638     ts.hasType = hasType;
9639     function hasInitializer(node) {
9640         return !!node.initializer;
9641     }
9642     ts.hasInitializer = hasInitializer;
9643     function hasOnlyExpressionInitializer(node) {
9644         switch (node.kind) {
9645             case 242:
9646             case 156:
9647             case 191:
9648             case 158:
9649             case 159:
9650             case 281:
9651             case 284:
9652                 return true;
9653             default:
9654                 return false;
9655         }
9656     }
9657     ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer;
9658     function isObjectLiteralElement(node) {
9659         return node.kind === 273 || node.kind === 275 || isObjectLiteralElementLike(node);
9660     }
9661     ts.isObjectLiteralElement = isObjectLiteralElement;
9662     function isTypeReferenceType(node) {
9663         return node.kind === 169 || node.kind === 216;
9664     }
9665     ts.isTypeReferenceType = isTypeReferenceType;
9666     var MAX_SMI_X86 = 1073741823;
9667     function guessIndentation(lines) {
9668         var indentation = MAX_SMI_X86;
9669         for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
9670             var line = lines_1[_i];
9671             if (!line.length) {
9672                 continue;
9673             }
9674             var i = 0;
9675             for (; i < line.length && i < indentation; i++) {
9676                 if (!ts.isWhiteSpaceLike(line.charCodeAt(i))) {
9677                     break;
9678                 }
9679             }
9680             if (i < indentation) {
9681                 indentation = i;
9682             }
9683             if (indentation === 0) {
9684                 return 0;
9685             }
9686         }
9687         return indentation === MAX_SMI_X86 ? undefined : indentation;
9688     }
9689     ts.guessIndentation = guessIndentation;
9690     function isStringLiteralLike(node) {
9691         return node.kind === 10 || node.kind === 14;
9692     }
9693     ts.isStringLiteralLike = isStringLiteralLike;
9694 })(ts || (ts = {}));
9695 var ts;
9696 (function (ts) {
9697     ts.resolvingEmptyArray = [];
9698     ts.emptyMap = ts.createMap();
9699     ts.emptyUnderscoreEscapedMap = ts.emptyMap;
9700     ts.externalHelpersModuleNameText = "tslib";
9701     ts.defaultMaximumTruncationLength = 160;
9702     ts.noTruncationMaximumTruncationLength = 1000000;
9703     function getDeclarationOfKind(symbol, kind) {
9704         var declarations = symbol.declarations;
9705         if (declarations) {
9706             for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) {
9707                 var declaration = declarations_1[_i];
9708                 if (declaration.kind === kind) {
9709                     return declaration;
9710                 }
9711             }
9712         }
9713         return undefined;
9714     }
9715     ts.getDeclarationOfKind = getDeclarationOfKind;
9716     function createUnderscoreEscapedMap() {
9717         return new ts.Map();
9718     }
9719     ts.createUnderscoreEscapedMap = createUnderscoreEscapedMap;
9720     function hasEntries(map) {
9721         return !!map && !!map.size;
9722     }
9723     ts.hasEntries = hasEntries;
9724     function createSymbolTable(symbols) {
9725         var result = ts.createMap();
9726         if (symbols) {
9727             for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
9728                 var symbol = symbols_1[_i];
9729                 result.set(symbol.escapedName, symbol);
9730             }
9731         }
9732         return result;
9733     }
9734     ts.createSymbolTable = createSymbolTable;
9735     function isTransientSymbol(symbol) {
9736         return (symbol.flags & 33554432) !== 0;
9737     }
9738     ts.isTransientSymbol = isTransientSymbol;
9739     var stringWriter = createSingleLineStringWriter();
9740     function createSingleLineStringWriter() {
9741         var str = "";
9742         var writeText = function (text) { return str += text; };
9743         return {
9744             getText: function () { return str; },
9745             write: writeText,
9746             rawWrite: writeText,
9747             writeKeyword: writeText,
9748             writeOperator: writeText,
9749             writePunctuation: writeText,
9750             writeSpace: writeText,
9751             writeStringLiteral: writeText,
9752             writeLiteral: writeText,
9753             writeParameter: writeText,
9754             writeProperty: writeText,
9755             writeSymbol: function (s, _) { return writeText(s); },
9756             writeTrailingSemicolon: writeText,
9757             writeComment: writeText,
9758             getTextPos: function () { return str.length; },
9759             getLine: function () { return 0; },
9760             getColumn: function () { return 0; },
9761             getIndent: function () { return 0; },
9762             isAtStartOfLine: function () { return false; },
9763             hasTrailingComment: function () { return false; },
9764             hasTrailingWhitespace: function () { return !!str.length && ts.isWhiteSpaceLike(str.charCodeAt(str.length - 1)); },
9765             writeLine: function () { return str += " "; },
9766             increaseIndent: ts.noop,
9767             decreaseIndent: ts.noop,
9768             clear: function () { return str = ""; },
9769             trackSymbol: ts.noop,
9770             reportInaccessibleThisError: ts.noop,
9771             reportInaccessibleUniqueSymbolError: ts.noop,
9772             reportPrivateInBaseOfClassExpression: ts.noop,
9773         };
9774     }
9775     function changesAffectModuleResolution(oldOptions, newOptions) {
9776         return oldOptions.configFilePath !== newOptions.configFilePath ||
9777             optionsHaveModuleResolutionChanges(oldOptions, newOptions);
9778     }
9779     ts.changesAffectModuleResolution = changesAffectModuleResolution;
9780     function optionsHaveModuleResolutionChanges(oldOptions, newOptions) {
9781         return ts.moduleResolutionOptionDeclarations.some(function (o) {
9782             return !isJsonEqual(getCompilerOptionValue(oldOptions, o), getCompilerOptionValue(newOptions, o));
9783         });
9784     }
9785     ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges;
9786     function findAncestor(node, callback) {
9787         while (node) {
9788             var result = callback(node);
9789             if (result === "quit") {
9790                 return undefined;
9791             }
9792             else if (result) {
9793                 return node;
9794             }
9795             node = node.parent;
9796         }
9797         return undefined;
9798     }
9799     ts.findAncestor = findAncestor;
9800     function forEachAncestor(node, callback) {
9801         while (true) {
9802             var res = callback(node);
9803             if (res === "quit")
9804                 return undefined;
9805             if (res !== undefined)
9806                 return res;
9807             if (ts.isSourceFile(node))
9808                 return undefined;
9809             node = node.parent;
9810         }
9811     }
9812     ts.forEachAncestor = forEachAncestor;
9813     function forEachEntry(map, callback) {
9814         var iterator = map.entries();
9815         for (var iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) {
9816             var _a = iterResult.value, key = _a[0], value = _a[1];
9817             var result = callback(value, key);
9818             if (result) {
9819                 return result;
9820             }
9821         }
9822         return undefined;
9823     }
9824     ts.forEachEntry = forEachEntry;
9825     function forEachKey(map, callback) {
9826         var iterator = map.keys();
9827         for (var iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) {
9828             var result = callback(iterResult.value);
9829             if (result) {
9830                 return result;
9831             }
9832         }
9833         return undefined;
9834     }
9835     ts.forEachKey = forEachKey;
9836     function copyEntries(source, target) {
9837         source.forEach(function (value, key) {
9838             target.set(key, value);
9839         });
9840     }
9841     ts.copyEntries = copyEntries;
9842     function arrayToSet(array, makeKey) {
9843         return ts.arrayToMap(array, makeKey || (function (s) { return s; }), ts.returnTrue);
9844     }
9845     ts.arrayToSet = arrayToSet;
9846     function cloneMap(map) {
9847         var clone = ts.createMap();
9848         copyEntries(map, clone);
9849         return clone;
9850     }
9851     ts.cloneMap = cloneMap;
9852     function usingSingleLineStringWriter(action) {
9853         var oldString = stringWriter.getText();
9854         try {
9855             action(stringWriter);
9856             return stringWriter.getText();
9857         }
9858         finally {
9859             stringWriter.clear();
9860             stringWriter.writeKeyword(oldString);
9861         }
9862     }
9863     ts.usingSingleLineStringWriter = usingSingleLineStringWriter;
9864     function getFullWidth(node) {
9865         return node.end - node.pos;
9866     }
9867     ts.getFullWidth = getFullWidth;
9868     function getResolvedModule(sourceFile, moduleNameText) {
9869         return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText);
9870     }
9871     ts.getResolvedModule = getResolvedModule;
9872     function setResolvedModule(sourceFile, moduleNameText, resolvedModule) {
9873         if (!sourceFile.resolvedModules) {
9874             sourceFile.resolvedModules = ts.createMap();
9875         }
9876         sourceFile.resolvedModules.set(moduleNameText, resolvedModule);
9877     }
9878     ts.setResolvedModule = setResolvedModule;
9879     function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) {
9880         if (!sourceFile.resolvedTypeReferenceDirectiveNames) {
9881             sourceFile.resolvedTypeReferenceDirectiveNames = ts.createMap();
9882         }
9883         sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective);
9884     }
9885     ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective;
9886     function projectReferenceIsEqualTo(oldRef, newRef) {
9887         return oldRef.path === newRef.path &&
9888             !oldRef.prepend === !newRef.prepend &&
9889             !oldRef.circular === !newRef.circular;
9890     }
9891     ts.projectReferenceIsEqualTo = projectReferenceIsEqualTo;
9892     function moduleResolutionIsEqualTo(oldResolution, newResolution) {
9893         return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport &&
9894             oldResolution.extension === newResolution.extension &&
9895             oldResolution.resolvedFileName === newResolution.resolvedFileName &&
9896             oldResolution.originalPath === newResolution.originalPath &&
9897             packageIdIsEqual(oldResolution.packageId, newResolution.packageId);
9898     }
9899     ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo;
9900     function packageIdIsEqual(a, b) {
9901         return a === b || !!a && !!b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version;
9902     }
9903     function packageIdToString(_a) {
9904         var name = _a.name, subModuleName = _a.subModuleName, version = _a.version;
9905         var fullName = subModuleName ? name + "/" + subModuleName : name;
9906         return fullName + "@" + version;
9907     }
9908     ts.packageIdToString = packageIdToString;
9909     function typeDirectiveIsEqualTo(oldResolution, newResolution) {
9910         return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary;
9911     }
9912     ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo;
9913     function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) {
9914         ts.Debug.assert(names.length === newResolutions.length);
9915         for (var i = 0; i < names.length; i++) {
9916             var newResolution = newResolutions[i];
9917             var oldResolution = oldResolutions && oldResolutions.get(names[i]);
9918             var changed = oldResolution
9919                 ? !newResolution || !comparer(oldResolution, newResolution)
9920                 : newResolution;
9921             if (changed) {
9922                 return true;
9923             }
9924         }
9925         return false;
9926     }
9927     ts.hasChangesInResolutions = hasChangesInResolutions;
9928     function containsParseError(node) {
9929         aggregateChildData(node);
9930         return (node.flags & 262144) !== 0;
9931     }
9932     ts.containsParseError = containsParseError;
9933     function aggregateChildData(node) {
9934         if (!(node.flags & 524288)) {
9935             var thisNodeOrAnySubNodesHasError = ((node.flags & 65536) !== 0) ||
9936                 ts.forEachChild(node, containsParseError);
9937             if (thisNodeOrAnySubNodesHasError) {
9938                 node.flags |= 262144;
9939             }
9940             node.flags |= 524288;
9941         }
9942     }
9943     function getSourceFileOfNode(node) {
9944         while (node && node.kind !== 290) {
9945             node = node.parent;
9946         }
9947         return node;
9948     }
9949     ts.getSourceFileOfNode = getSourceFileOfNode;
9950     function isStatementWithLocals(node) {
9951         switch (node.kind) {
9952             case 223:
9953             case 251:
9954             case 230:
9955             case 231:
9956             case 232:
9957                 return true;
9958         }
9959         return false;
9960     }
9961     ts.isStatementWithLocals = isStatementWithLocals;
9962     function getStartPositionOfLine(line, sourceFile) {
9963         ts.Debug.assert(line >= 0);
9964         return ts.getLineStarts(sourceFile)[line];
9965     }
9966     ts.getStartPositionOfLine = getStartPositionOfLine;
9967     function nodePosToString(node) {
9968         var file = getSourceFileOfNode(node);
9969         var loc = ts.getLineAndCharacterOfPosition(file, node.pos);
9970         return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")";
9971     }
9972     ts.nodePosToString = nodePosToString;
9973     function getEndLinePosition(line, sourceFile) {
9974         ts.Debug.assert(line >= 0);
9975         var lineStarts = ts.getLineStarts(sourceFile);
9976         var lineIndex = line;
9977         var sourceText = sourceFile.text;
9978         if (lineIndex + 1 === lineStarts.length) {
9979             return sourceText.length - 1;
9980         }
9981         else {
9982             var start = lineStarts[lineIndex];
9983             var pos = lineStarts[lineIndex + 1] - 1;
9984             ts.Debug.assert(ts.isLineBreak(sourceText.charCodeAt(pos)));
9985             while (start <= pos && ts.isLineBreak(sourceText.charCodeAt(pos))) {
9986                 pos--;
9987             }
9988             return pos;
9989         }
9990     }
9991     ts.getEndLinePosition = getEndLinePosition;
9992     function isFileLevelUniqueName(sourceFile, name, hasGlobalName) {
9993         return !(hasGlobalName && hasGlobalName(name)) && !sourceFile.identifiers.has(name);
9994     }
9995     ts.isFileLevelUniqueName = isFileLevelUniqueName;
9996     function nodeIsMissing(node) {
9997         if (node === undefined) {
9998             return true;
9999         }
10000         return node.pos === node.end && node.pos >= 0 && node.kind !== 1;
10001     }
10002     ts.nodeIsMissing = nodeIsMissing;
10003     function nodeIsPresent(node) {
10004         return !nodeIsMissing(node);
10005     }
10006     ts.nodeIsPresent = nodeIsPresent;
10007     function insertStatementsAfterPrologue(to, from, isPrologueDirective) {
10008         if (from === undefined || from.length === 0)
10009             return to;
10010         var statementIndex = 0;
10011         for (; statementIndex < to.length; ++statementIndex) {
10012             if (!isPrologueDirective(to[statementIndex])) {
10013                 break;
10014             }
10015         }
10016         to.splice.apply(to, __spreadArrays([statementIndex, 0], from));
10017         return to;
10018     }
10019     function insertStatementAfterPrologue(to, statement, isPrologueDirective) {
10020         if (statement === undefined)
10021             return to;
10022         var statementIndex = 0;
10023         for (; statementIndex < to.length; ++statementIndex) {
10024             if (!isPrologueDirective(to[statementIndex])) {
10025                 break;
10026             }
10027         }
10028         to.splice(statementIndex, 0, statement);
10029         return to;
10030     }
10031     function isAnyPrologueDirective(node) {
10032         return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576);
10033     }
10034     function insertStatementsAfterStandardPrologue(to, from) {
10035         return insertStatementsAfterPrologue(to, from, isPrologueDirective);
10036     }
10037     ts.insertStatementsAfterStandardPrologue = insertStatementsAfterStandardPrologue;
10038     function insertStatementsAfterCustomPrologue(to, from) {
10039         return insertStatementsAfterPrologue(to, from, isAnyPrologueDirective);
10040     }
10041     ts.insertStatementsAfterCustomPrologue = insertStatementsAfterCustomPrologue;
10042     function insertStatementAfterStandardPrologue(to, statement) {
10043         return insertStatementAfterPrologue(to, statement, isPrologueDirective);
10044     }
10045     ts.insertStatementAfterStandardPrologue = insertStatementAfterStandardPrologue;
10046     function insertStatementAfterCustomPrologue(to, statement) {
10047         return insertStatementAfterPrologue(to, statement, isAnyPrologueDirective);
10048     }
10049     ts.insertStatementAfterCustomPrologue = insertStatementAfterCustomPrologue;
10050     function isRecognizedTripleSlashComment(text, commentPos, commentEnd) {
10051         if (text.charCodeAt(commentPos + 1) === 47 &&
10052             commentPos + 2 < commentEnd &&
10053             text.charCodeAt(commentPos + 2) === 47) {
10054             var textSubStr = text.substring(commentPos, commentEnd);
10055             return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) ||
10056                 textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ||
10057                 textSubStr.match(fullTripleSlashReferenceTypeReferenceDirectiveRegEx) ||
10058                 textSubStr.match(defaultLibReferenceRegEx) ?
10059                 true : false;
10060         }
10061         return false;
10062     }
10063     ts.isRecognizedTripleSlashComment = isRecognizedTripleSlashComment;
10064     function isPinnedComment(text, start) {
10065         return text.charCodeAt(start + 1) === 42 &&
10066             text.charCodeAt(start + 2) === 33;
10067     }
10068     ts.isPinnedComment = isPinnedComment;
10069     function createCommentDirectivesMap(sourceFile, commentDirectives) {
10070         var directivesByLine = ts.createMapFromEntries(commentDirectives.map(function (commentDirective) { return ([
10071             "" + ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line,
10072             commentDirective,
10073         ]); }));
10074         var usedLines = ts.createMap();
10075         return { getUnusedExpectations: getUnusedExpectations, markUsed: markUsed };
10076         function getUnusedExpectations() {
10077             return ts.arrayFrom(directivesByLine.entries())
10078                 .filter(function (_a) {
10079                 var line = _a[0], directive = _a[1];
10080                 return directive.type === 0 && !usedLines.get(line);
10081             })
10082                 .map(function (_a) {
10083                 var _ = _a[0], directive = _a[1];
10084                 return directive;
10085             });
10086         }
10087         function markUsed(line) {
10088             if (!directivesByLine.has("" + line)) {
10089                 return false;
10090             }
10091             usedLines.set("" + line, true);
10092             return true;
10093         }
10094     }
10095     ts.createCommentDirectivesMap = createCommentDirectivesMap;
10096     function getTokenPosOfNode(node, sourceFile, includeJsDoc) {
10097         if (nodeIsMissing(node)) {
10098             return node.pos;
10099         }
10100         if (ts.isJSDocNode(node)) {
10101             return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, false, true);
10102         }
10103         if (includeJsDoc && ts.hasJSDocNodes(node)) {
10104             return getTokenPosOfNode(node.jsDoc[0], sourceFile);
10105         }
10106         if (node.kind === 324 && node._children.length > 0) {
10107             return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc);
10108         }
10109         return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
10110     }
10111     ts.getTokenPosOfNode = getTokenPosOfNode;
10112     function getNonDecoratorTokenPosOfNode(node, sourceFile) {
10113         if (nodeIsMissing(node) || !node.decorators) {
10114             return getTokenPosOfNode(node, sourceFile);
10115         }
10116         return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end);
10117     }
10118     ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode;
10119     function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) {
10120         if (includeTrivia === void 0) { includeTrivia = false; }
10121         return getTextOfNodeFromSourceText(sourceFile.text, node, includeTrivia);
10122     }
10123     ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile;
10124     function isJSDocTypeExpressionOrChild(node) {
10125         return !!findAncestor(node, ts.isJSDocTypeExpression);
10126     }
10127     function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) {
10128         if (includeTrivia === void 0) { includeTrivia = false; }
10129         if (nodeIsMissing(node)) {
10130             return "";
10131         }
10132         var text = sourceText.substring(includeTrivia ? node.pos : ts.skipTrivia(sourceText, node.pos), node.end);
10133         if (isJSDocTypeExpressionOrChild(node)) {
10134             text = text.replace(/(^|\r?\n|\r)\s*\*\s*/g, "$1");
10135         }
10136         return text;
10137     }
10138     ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText;
10139     function getTextOfNode(node, includeTrivia) {
10140         if (includeTrivia === void 0) { includeTrivia = false; }
10141         return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia);
10142     }
10143     ts.getTextOfNode = getTextOfNode;
10144     function getPos(range) {
10145         return range.pos;
10146     }
10147     function indexOfNode(nodeArray, node) {
10148         return ts.binarySearch(nodeArray, node, getPos, ts.compareValues);
10149     }
10150     ts.indexOfNode = indexOfNode;
10151     function getEmitFlags(node) {
10152         var emitNode = node.emitNode;
10153         return emitNode && emitNode.flags || 0;
10154     }
10155     ts.getEmitFlags = getEmitFlags;
10156     function getLiteralText(node, sourceFile, neverAsciiEscape, jsxAttributeEscape) {
10157         if (!nodeIsSynthesized(node) && node.parent && !((ts.isNumericLiteral(node) && node.numericLiteralFlags & 512) ||
10158             ts.isBigIntLiteral(node))) {
10159             return getSourceTextOfNodeFromSourceFile(sourceFile, node);
10160         }
10161         switch (node.kind) {
10162             case 10: {
10163                 var escapeText = jsxAttributeEscape ? escapeJsxAttributeString :
10164                     neverAsciiEscape || (getEmitFlags(node) & 16777216) ? escapeString :
10165                         escapeNonAsciiString;
10166                 if (node.singleQuote) {
10167                     return "'" + escapeText(node.text, 39) + "'";
10168                 }
10169                 else {
10170                     return '"' + escapeText(node.text, 34) + '"';
10171                 }
10172             }
10173             case 14:
10174             case 15:
10175             case 16:
10176             case 17: {
10177                 var escapeText = neverAsciiEscape || (getEmitFlags(node) & 16777216) ? escapeString :
10178                     escapeNonAsciiString;
10179                 var rawText = node.rawText || escapeTemplateSubstitution(escapeText(node.text, 96));
10180                 switch (node.kind) {
10181                     case 14:
10182                         return "`" + rawText + "`";
10183                     case 15:
10184                         return "`" + rawText + "${";
10185                     case 16:
10186                         return "}" + rawText + "${";
10187                     case 17:
10188                         return "}" + rawText + "`";
10189                 }
10190                 break;
10191             }
10192             case 8:
10193             case 9:
10194             case 13:
10195                 return node.text;
10196         }
10197         return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for.");
10198     }
10199     ts.getLiteralText = getLiteralText;
10200     function getTextOfConstantValue(value) {
10201         return ts.isString(value) ? '"' + escapeNonAsciiString(value) + '"' : "" + value;
10202     }
10203     ts.getTextOfConstantValue = getTextOfConstantValue;
10204     function makeIdentifierFromModuleName(moduleName) {
10205         return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_");
10206     }
10207     ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName;
10208     function isBlockOrCatchScoped(declaration) {
10209         return (ts.getCombinedNodeFlags(declaration) & 3) !== 0 ||
10210             isCatchClauseVariableDeclarationOrBindingElement(declaration);
10211     }
10212     ts.isBlockOrCatchScoped = isBlockOrCatchScoped;
10213     function isCatchClauseVariableDeclarationOrBindingElement(declaration) {
10214         var node = getRootDeclaration(declaration);
10215         return node.kind === 242 && node.parent.kind === 280;
10216     }
10217     ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement;
10218     function isAmbientModule(node) {
10219         return ts.isModuleDeclaration(node) && (node.name.kind === 10 || isGlobalScopeAugmentation(node));
10220     }
10221     ts.isAmbientModule = isAmbientModule;
10222     function isModuleWithStringLiteralName(node) {
10223         return ts.isModuleDeclaration(node) && node.name.kind === 10;
10224     }
10225     ts.isModuleWithStringLiteralName = isModuleWithStringLiteralName;
10226     function isNonGlobalAmbientModule(node) {
10227         return ts.isModuleDeclaration(node) && ts.isStringLiteral(node.name);
10228     }
10229     ts.isNonGlobalAmbientModule = isNonGlobalAmbientModule;
10230     function isEffectiveModuleDeclaration(node) {
10231         return ts.isModuleDeclaration(node) || ts.isIdentifier(node);
10232     }
10233     ts.isEffectiveModuleDeclaration = isEffectiveModuleDeclaration;
10234     function isShorthandAmbientModuleSymbol(moduleSymbol) {
10235         return isShorthandAmbientModule(moduleSymbol.valueDeclaration);
10236     }
10237     ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol;
10238     function isShorthandAmbientModule(node) {
10239         return node && node.kind === 249 && (!node.body);
10240     }
10241     function isBlockScopedContainerTopLevel(node) {
10242         return node.kind === 290 ||
10243             node.kind === 249 ||
10244             ts.isFunctionLike(node);
10245     }
10246     ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel;
10247     function isGlobalScopeAugmentation(module) {
10248         return !!(module.flags & 1024);
10249     }
10250     ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation;
10251     function isExternalModuleAugmentation(node) {
10252         return isAmbientModule(node) && isModuleAugmentationExternal(node);
10253     }
10254     ts.isExternalModuleAugmentation = isExternalModuleAugmentation;
10255     function isModuleAugmentationExternal(node) {
10256         switch (node.parent.kind) {
10257             case 290:
10258                 return ts.isExternalModule(node.parent);
10259             case 250:
10260                 return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent);
10261         }
10262         return false;
10263     }
10264     ts.isModuleAugmentationExternal = isModuleAugmentationExternal;
10265     function getNonAugmentationDeclaration(symbol) {
10266         return ts.find(symbol.declarations, function (d) { return !isExternalModuleAugmentation(d) && !(ts.isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); });
10267     }
10268     ts.getNonAugmentationDeclaration = getNonAugmentationDeclaration;
10269     function isEffectiveExternalModule(node, compilerOptions) {
10270         return ts.isExternalModule(node) || compilerOptions.isolatedModules || ((getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS) && !!node.commonJsModuleIndicator);
10271     }
10272     ts.isEffectiveExternalModule = isEffectiveExternalModule;
10273     function isEffectiveStrictModeSourceFile(node, compilerOptions) {
10274         switch (node.scriptKind) {
10275             case 1:
10276             case 3:
10277             case 2:
10278             case 4:
10279                 break;
10280             default:
10281                 return false;
10282         }
10283         if (node.isDeclarationFile) {
10284             return false;
10285         }
10286         if (getStrictOptionValue(compilerOptions, "alwaysStrict")) {
10287             return true;
10288         }
10289         if (ts.startsWithUseStrict(node.statements)) {
10290             return true;
10291         }
10292         if (ts.isExternalModule(node) || compilerOptions.isolatedModules) {
10293             if (getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) {
10294                 return true;
10295             }
10296             return !compilerOptions.noImplicitUseStrict;
10297         }
10298         return false;
10299     }
10300     ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile;
10301     function isBlockScope(node, parentNode) {
10302         switch (node.kind) {
10303             case 290:
10304             case 251:
10305             case 280:
10306             case 249:
10307             case 230:
10308             case 231:
10309             case 232:
10310             case 162:
10311             case 161:
10312             case 163:
10313             case 164:
10314             case 244:
10315             case 201:
10316             case 202:
10317                 return true;
10318             case 223:
10319                 return !ts.isFunctionLike(parentNode);
10320         }
10321         return false;
10322     }
10323     ts.isBlockScope = isBlockScope;
10324     function isDeclarationWithTypeParameters(node) {
10325         switch (node.kind) {
10326             case 315:
10327             case 322:
10328             case 305:
10329                 return true;
10330             default:
10331                 ts.assertType(node);
10332                 return isDeclarationWithTypeParameterChildren(node);
10333         }
10334     }
10335     ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters;
10336     function isDeclarationWithTypeParameterChildren(node) {
10337         switch (node.kind) {
10338             case 165:
10339             case 166:
10340             case 160:
10341             case 167:
10342             case 170:
10343             case 171:
10344             case 300:
10345             case 245:
10346             case 214:
10347             case 246:
10348             case 247:
10349             case 321:
10350             case 244:
10351             case 161:
10352             case 162:
10353             case 163:
10354             case 164:
10355             case 201:
10356             case 202:
10357                 return true;
10358             default:
10359                 ts.assertType(node);
10360                 return false;
10361         }
10362     }
10363     ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren;
10364     function isAnyImportSyntax(node) {
10365         switch (node.kind) {
10366             case 254:
10367             case 253:
10368                 return true;
10369             default:
10370                 return false;
10371         }
10372     }
10373     ts.isAnyImportSyntax = isAnyImportSyntax;
10374     function isLateVisibilityPaintedStatement(node) {
10375         switch (node.kind) {
10376             case 254:
10377             case 253:
10378             case 225:
10379             case 245:
10380             case 244:
10381             case 249:
10382             case 247:
10383             case 246:
10384             case 248:
10385                 return true;
10386             default:
10387                 return false;
10388         }
10389     }
10390     ts.isLateVisibilityPaintedStatement = isLateVisibilityPaintedStatement;
10391     function isAnyImportOrReExport(node) {
10392         return isAnyImportSyntax(node) || ts.isExportDeclaration(node);
10393     }
10394     ts.isAnyImportOrReExport = isAnyImportOrReExport;
10395     function getEnclosingBlockScopeContainer(node) {
10396         return findAncestor(node.parent, function (current) { return isBlockScope(current, current.parent); });
10397     }
10398     ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer;
10399     function declarationNameToString(name) {
10400         return !name || getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name);
10401     }
10402     ts.declarationNameToString = declarationNameToString;
10403     function getNameFromIndexInfo(info) {
10404         return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : undefined;
10405     }
10406     ts.getNameFromIndexInfo = getNameFromIndexInfo;
10407     function isComputedNonLiteralName(name) {
10408         return name.kind === 154 && !isStringOrNumericLiteralLike(name.expression);
10409     }
10410     ts.isComputedNonLiteralName = isComputedNonLiteralName;
10411     function getTextOfPropertyName(name) {
10412         switch (name.kind) {
10413             case 75:
10414             case 76:
10415                 return name.escapedText;
10416             case 10:
10417             case 8:
10418             case 14:
10419                 return ts.escapeLeadingUnderscores(name.text);
10420             case 154:
10421                 if (isStringOrNumericLiteralLike(name.expression))
10422                     return ts.escapeLeadingUnderscores(name.expression.text);
10423                 return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames");
10424             default:
10425                 return ts.Debug.assertNever(name);
10426         }
10427     }
10428     ts.getTextOfPropertyName = getTextOfPropertyName;
10429     function entityNameToString(name) {
10430         switch (name.kind) {
10431             case 104:
10432                 return "this";
10433             case 76:
10434             case 75:
10435                 return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name);
10436             case 153:
10437                 return entityNameToString(name.left) + "." + entityNameToString(name.right);
10438             case 194:
10439                 if (ts.isIdentifier(name.name) || ts.isPrivateIdentifier(name.name)) {
10440                     return entityNameToString(name.expression) + "." + entityNameToString(name.name);
10441                 }
10442                 else {
10443                     return ts.Debug.assertNever(name.name);
10444                 }
10445             default:
10446                 return ts.Debug.assertNever(name);
10447         }
10448     }
10449     ts.entityNameToString = entityNameToString;
10450     function createDiagnosticForNode(node, message, arg0, arg1, arg2, arg3) {
10451         var sourceFile = getSourceFileOfNode(node);
10452         return createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2, arg3);
10453     }
10454     ts.createDiagnosticForNode = createDiagnosticForNode;
10455     function createDiagnosticForNodeArray(sourceFile, nodes, message, arg0, arg1, arg2, arg3) {
10456         var start = ts.skipTrivia(sourceFile.text, nodes.pos);
10457         return createFileDiagnostic(sourceFile, start, nodes.end - start, message, arg0, arg1, arg2, arg3);
10458     }
10459     ts.createDiagnosticForNodeArray = createDiagnosticForNodeArray;
10460     function createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2, arg3) {
10461         var span = getErrorSpanForNode(sourceFile, node);
10462         return createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2, arg3);
10463     }
10464     ts.createDiagnosticForNodeInSourceFile = createDiagnosticForNodeInSourceFile;
10465     function createDiagnosticForNodeFromMessageChain(node, messageChain, relatedInformation) {
10466         var sourceFile = getSourceFileOfNode(node);
10467         var span = getErrorSpanForNode(sourceFile, node);
10468         return {
10469             file: sourceFile,
10470             start: span.start,
10471             length: span.length,
10472             code: messageChain.code,
10473             category: messageChain.category,
10474             messageText: messageChain.next ? messageChain : messageChain.messageText,
10475             relatedInformation: relatedInformation
10476         };
10477     }
10478     ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain;
10479     function createDiagnosticForRange(sourceFile, range, message) {
10480         return {
10481             file: sourceFile,
10482             start: range.pos,
10483             length: range.end - range.pos,
10484             code: message.code,
10485             category: message.category,
10486             messageText: message.message,
10487         };
10488     }
10489     ts.createDiagnosticForRange = createDiagnosticForRange;
10490     function getSpanOfTokenAtPosition(sourceFile, pos) {
10491         var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos);
10492         scanner.scan();
10493         var start = scanner.getTokenPos();
10494         return ts.createTextSpanFromBounds(start, scanner.getTextPos());
10495     }
10496     ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition;
10497     function getErrorSpanForArrowFunction(sourceFile, node) {
10498         var pos = ts.skipTrivia(sourceFile.text, node.pos);
10499         if (node.body && node.body.kind === 223) {
10500             var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line;
10501             var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line;
10502             if (startLine < endLine) {
10503                 return ts.createTextSpan(pos, getEndLinePosition(startLine, sourceFile) - pos + 1);
10504             }
10505         }
10506         return ts.createTextSpanFromBounds(pos, node.end);
10507     }
10508     function getErrorSpanForNode(sourceFile, node) {
10509         var errorNode = node;
10510         switch (node.kind) {
10511             case 290:
10512                 var pos_1 = ts.skipTrivia(sourceFile.text, 0, false);
10513                 if (pos_1 === sourceFile.text.length) {
10514                     return ts.createTextSpan(0, 0);
10515                 }
10516                 return getSpanOfTokenAtPosition(sourceFile, pos_1);
10517             case 242:
10518             case 191:
10519             case 245:
10520             case 214:
10521             case 246:
10522             case 249:
10523             case 248:
10524             case 284:
10525             case 244:
10526             case 201:
10527             case 161:
10528             case 163:
10529             case 164:
10530             case 247:
10531             case 159:
10532             case 158:
10533                 errorNode = node.name;
10534                 break;
10535             case 202:
10536                 return getErrorSpanForArrowFunction(sourceFile, node);
10537             case 277:
10538             case 278:
10539                 var start = ts.skipTrivia(sourceFile.text, node.pos);
10540                 var end = node.statements.length > 0 ? node.statements[0].pos : node.end;
10541                 return ts.createTextSpanFromBounds(start, end);
10542         }
10543         if (errorNode === undefined) {
10544             return getSpanOfTokenAtPosition(sourceFile, node.pos);
10545         }
10546         ts.Debug.assert(!ts.isJSDoc(errorNode));
10547         var isMissing = nodeIsMissing(errorNode);
10548         var pos = isMissing || ts.isJsxText(node)
10549             ? errorNode.pos
10550             : ts.skipTrivia(sourceFile.text, errorNode.pos);
10551         if (isMissing) {
10552             ts.Debug.assert(pos === errorNode.pos, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
10553             ts.Debug.assert(pos === errorNode.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
10554         }
10555         else {
10556             ts.Debug.assert(pos >= errorNode.pos, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
10557             ts.Debug.assert(pos <= errorNode.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
10558         }
10559         return ts.createTextSpanFromBounds(pos, errorNode.end);
10560     }
10561     ts.getErrorSpanForNode = getErrorSpanForNode;
10562     function isExternalOrCommonJsModule(file) {
10563         return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined;
10564     }
10565     ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule;
10566     function isJsonSourceFile(file) {
10567         return file.scriptKind === 6;
10568     }
10569     ts.isJsonSourceFile = isJsonSourceFile;
10570     function isEnumConst(node) {
10571         return !!(ts.getCombinedModifierFlags(node) & 2048);
10572     }
10573     ts.isEnumConst = isEnumConst;
10574     function isDeclarationReadonly(declaration) {
10575         return !!(ts.getCombinedModifierFlags(declaration) & 64 && !ts.isParameterPropertyDeclaration(declaration, declaration.parent));
10576     }
10577     ts.isDeclarationReadonly = isDeclarationReadonly;
10578     function isVarConst(node) {
10579         return !!(ts.getCombinedNodeFlags(node) & 2);
10580     }
10581     ts.isVarConst = isVarConst;
10582     function isLet(node) {
10583         return !!(ts.getCombinedNodeFlags(node) & 1);
10584     }
10585     ts.isLet = isLet;
10586     function isSuperCall(n) {
10587         return n.kind === 196 && n.expression.kind === 102;
10588     }
10589     ts.isSuperCall = isSuperCall;
10590     function isImportCall(n) {
10591         return n.kind === 196 && n.expression.kind === 96;
10592     }
10593     ts.isImportCall = isImportCall;
10594     function isImportMeta(n) {
10595         return ts.isMetaProperty(n)
10596             && n.keywordToken === 96
10597             && n.name.escapedText === "meta";
10598     }
10599     ts.isImportMeta = isImportMeta;
10600     function isLiteralImportTypeNode(n) {
10601         return ts.isImportTypeNode(n) && ts.isLiteralTypeNode(n.argument) && ts.isStringLiteral(n.argument.literal);
10602     }
10603     ts.isLiteralImportTypeNode = isLiteralImportTypeNode;
10604     function isPrologueDirective(node) {
10605         return node.kind === 226
10606             && node.expression.kind === 10;
10607     }
10608     ts.isPrologueDirective = isPrologueDirective;
10609     function isCustomPrologue(node) {
10610         return !!(getEmitFlags(node) & 1048576);
10611     }
10612     ts.isCustomPrologue = isCustomPrologue;
10613     function isHoistedFunction(node) {
10614         return isCustomPrologue(node)
10615             && ts.isFunctionDeclaration(node);
10616     }
10617     ts.isHoistedFunction = isHoistedFunction;
10618     function isHoistedVariable(node) {
10619         return ts.isIdentifier(node.name)
10620             && !node.initializer;
10621     }
10622     function isHoistedVariableStatement(node) {
10623         return isCustomPrologue(node)
10624             && ts.isVariableStatement(node)
10625             && ts.every(node.declarationList.declarations, isHoistedVariable);
10626     }
10627     ts.isHoistedVariableStatement = isHoistedVariableStatement;
10628     function getLeadingCommentRangesOfNode(node, sourceFileOfNode) {
10629         return node.kind !== 11 ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined;
10630     }
10631     ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode;
10632     function getJSDocCommentRanges(node, text) {
10633         var commentRanges = (node.kind === 156 ||
10634             node.kind === 155 ||
10635             node.kind === 201 ||
10636             node.kind === 202 ||
10637             node.kind === 200) ?
10638             ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) :
10639             ts.getLeadingCommentRanges(text, node.pos);
10640         return ts.filter(commentRanges, function (comment) {
10641             return text.charCodeAt(comment.pos + 1) === 42 &&
10642                 text.charCodeAt(comment.pos + 2) === 42 &&
10643                 text.charCodeAt(comment.pos + 3) !== 47;
10644         });
10645     }
10646     ts.getJSDocCommentRanges = getJSDocCommentRanges;
10647     ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
10648     var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*<reference\s+types\s*=\s*)('|")(.+?)\2.*?\/>/;
10649     ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*<amd-dependency\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
10650     var defaultLibReferenceRegEx = /^(\/\/\/\s*<reference\s+no-default-lib\s*=\s*)('|")(.+?)\2\s*\/>/;
10651     function isPartOfTypeNode(node) {
10652         if (168 <= node.kind && node.kind <= 188) {
10653             return true;
10654         }
10655         switch (node.kind) {
10656             case 125:
10657             case 148:
10658             case 140:
10659             case 151:
10660             case 143:
10661             case 128:
10662             case 144:
10663             case 141:
10664             case 146:
10665             case 137:
10666                 return true;
10667             case 110:
10668                 return node.parent.kind !== 205;
10669             case 216:
10670                 return !isExpressionWithTypeArgumentsInClassExtendsClause(node);
10671             case 155:
10672                 return node.parent.kind === 186 || node.parent.kind === 181;
10673             case 75:
10674                 if (node.parent.kind === 153 && node.parent.right === node) {
10675                     node = node.parent;
10676                 }
10677                 else if (node.parent.kind === 194 && node.parent.name === node) {
10678                     node = node.parent;
10679                 }
10680                 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'.");
10681             case 153:
10682             case 194:
10683             case 104: {
10684                 var parent = node.parent;
10685                 if (parent.kind === 172) {
10686                     return false;
10687                 }
10688                 if (parent.kind === 188) {
10689                     return !parent.isTypeOf;
10690                 }
10691                 if (168 <= parent.kind && parent.kind <= 188) {
10692                     return true;
10693                 }
10694                 switch (parent.kind) {
10695                     case 216:
10696                         return !isExpressionWithTypeArgumentsInClassExtendsClause(parent);
10697                     case 155:
10698                         return node === parent.constraint;
10699                     case 321:
10700                         return node === parent.constraint;
10701                     case 159:
10702                     case 158:
10703                     case 156:
10704                     case 242:
10705                         return node === parent.type;
10706                     case 244:
10707                     case 201:
10708                     case 202:
10709                     case 162:
10710                     case 161:
10711                     case 160:
10712                     case 163:
10713                     case 164:
10714                         return node === parent.type;
10715                     case 165:
10716                     case 166:
10717                     case 167:
10718                         return node === parent.type;
10719                     case 199:
10720                         return node === parent.type;
10721                     case 196:
10722                     case 197:
10723                         return ts.contains(parent.typeArguments, node);
10724                     case 198:
10725                         return false;
10726                 }
10727             }
10728         }
10729         return false;
10730     }
10731     ts.isPartOfTypeNode = isPartOfTypeNode;
10732     function isChildOfNodeWithKind(node, kind) {
10733         while (node) {
10734             if (node.kind === kind) {
10735                 return true;
10736             }
10737             node = node.parent;
10738         }
10739         return false;
10740     }
10741     ts.isChildOfNodeWithKind = isChildOfNodeWithKind;
10742     function forEachReturnStatement(body, visitor) {
10743         return traverse(body);
10744         function traverse(node) {
10745             switch (node.kind) {
10746                 case 235:
10747                     return visitor(node);
10748                 case 251:
10749                 case 223:
10750                 case 227:
10751                 case 228:
10752                 case 229:
10753                 case 230:
10754                 case 231:
10755                 case 232:
10756                 case 236:
10757                 case 237:
10758                 case 277:
10759                 case 278:
10760                 case 238:
10761                 case 240:
10762                 case 280:
10763                     return ts.forEachChild(node, traverse);
10764             }
10765         }
10766     }
10767     ts.forEachReturnStatement = forEachReturnStatement;
10768     function forEachYieldExpression(body, visitor) {
10769         return traverse(body);
10770         function traverse(node) {
10771             switch (node.kind) {
10772                 case 212:
10773                     visitor(node);
10774                     var operand = node.expression;
10775                     if (operand) {
10776                         traverse(operand);
10777                     }
10778                     return;
10779                 case 248:
10780                 case 246:
10781                 case 249:
10782                 case 247:
10783                     return;
10784                 default:
10785                     if (ts.isFunctionLike(node)) {
10786                         if (node.name && node.name.kind === 154) {
10787                             traverse(node.name.expression);
10788                             return;
10789                         }
10790                     }
10791                     else if (!isPartOfTypeNode(node)) {
10792                         ts.forEachChild(node, traverse);
10793                     }
10794             }
10795         }
10796     }
10797     ts.forEachYieldExpression = forEachYieldExpression;
10798     function getRestParameterElementType(node) {
10799         if (node && node.kind === 174) {
10800             return node.elementType;
10801         }
10802         else if (node && node.kind === 169) {
10803             return ts.singleOrUndefined(node.typeArguments);
10804         }
10805         else {
10806             return undefined;
10807         }
10808     }
10809     ts.getRestParameterElementType = getRestParameterElementType;
10810     function getMembersOfDeclaration(node) {
10811         switch (node.kind) {
10812             case 246:
10813             case 245:
10814             case 214:
10815             case 173:
10816                 return node.members;
10817             case 193:
10818                 return node.properties;
10819         }
10820     }
10821     ts.getMembersOfDeclaration = getMembersOfDeclaration;
10822     function isVariableLike(node) {
10823         if (node) {
10824             switch (node.kind) {
10825                 case 191:
10826                 case 284:
10827                 case 156:
10828                 case 281:
10829                 case 159:
10830                 case 158:
10831                 case 282:
10832                 case 242:
10833                     return true;
10834             }
10835         }
10836         return false;
10837     }
10838     ts.isVariableLike = isVariableLike;
10839     function isVariableLikeOrAccessor(node) {
10840         return isVariableLike(node) || ts.isAccessor(node);
10841     }
10842     ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor;
10843     function isVariableDeclarationInVariableStatement(node) {
10844         return node.parent.kind === 243
10845             && node.parent.parent.kind === 225;
10846     }
10847     ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement;
10848     function isValidESSymbolDeclaration(node) {
10849         return ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) :
10850             ts.isPropertyDeclaration(node) ? hasReadonlyModifier(node) && hasStaticModifier(node) :
10851                 ts.isPropertySignature(node) && hasReadonlyModifier(node);
10852     }
10853     ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration;
10854     function introducesArgumentsExoticObject(node) {
10855         switch (node.kind) {
10856             case 161:
10857             case 160:
10858             case 162:
10859             case 163:
10860             case 164:
10861             case 244:
10862             case 201:
10863                 return true;
10864         }
10865         return false;
10866     }
10867     ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject;
10868     function unwrapInnermostStatementOfLabel(node, beforeUnwrapLabelCallback) {
10869         while (true) {
10870             if (beforeUnwrapLabelCallback) {
10871                 beforeUnwrapLabelCallback(node);
10872             }
10873             if (node.statement.kind !== 238) {
10874                 return node.statement;
10875             }
10876             node = node.statement;
10877         }
10878     }
10879     ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel;
10880     function isFunctionBlock(node) {
10881         return node && node.kind === 223 && ts.isFunctionLike(node.parent);
10882     }
10883     ts.isFunctionBlock = isFunctionBlock;
10884     function isObjectLiteralMethod(node) {
10885         return node && node.kind === 161 && node.parent.kind === 193;
10886     }
10887     ts.isObjectLiteralMethod = isObjectLiteralMethod;
10888     function isObjectLiteralOrClassExpressionMethod(node) {
10889         return node.kind === 161 &&
10890             (node.parent.kind === 193 ||
10891                 node.parent.kind === 214);
10892     }
10893     ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod;
10894     function isIdentifierTypePredicate(predicate) {
10895         return predicate && predicate.kind === 1;
10896     }
10897     ts.isIdentifierTypePredicate = isIdentifierTypePredicate;
10898     function isThisTypePredicate(predicate) {
10899         return predicate && predicate.kind === 0;
10900     }
10901     ts.isThisTypePredicate = isThisTypePredicate;
10902     function getPropertyAssignment(objectLiteral, key, key2) {
10903         return objectLiteral.properties.filter(function (property) {
10904             if (property.kind === 281) {
10905                 var propName = getTextOfPropertyName(property.name);
10906                 return key === propName || (!!key2 && key2 === propName);
10907             }
10908             return false;
10909         });
10910     }
10911     ts.getPropertyAssignment = getPropertyAssignment;
10912     function getTsConfigObjectLiteralExpression(tsConfigSourceFile) {
10913         if (tsConfigSourceFile && tsConfigSourceFile.statements.length) {
10914             var expression = tsConfigSourceFile.statements[0].expression;
10915             return ts.tryCast(expression, ts.isObjectLiteralExpression);
10916         }
10917     }
10918     ts.getTsConfigObjectLiteralExpression = getTsConfigObjectLiteralExpression;
10919     function getTsConfigPropArrayElementValue(tsConfigSourceFile, propKey, elementValue) {
10920         return ts.firstDefined(getTsConfigPropArray(tsConfigSourceFile, propKey), function (property) {
10921             return ts.isArrayLiteralExpression(property.initializer) ?
10922                 ts.find(property.initializer.elements, function (element) { return ts.isStringLiteral(element) && element.text === elementValue; }) :
10923                 undefined;
10924         });
10925     }
10926     ts.getTsConfigPropArrayElementValue = getTsConfigPropArrayElementValue;
10927     function getTsConfigPropArray(tsConfigSourceFile, propKey) {
10928         var jsonObjectLiteral = getTsConfigObjectLiteralExpression(tsConfigSourceFile);
10929         return jsonObjectLiteral ? getPropertyAssignment(jsonObjectLiteral, propKey) : ts.emptyArray;
10930     }
10931     ts.getTsConfigPropArray = getTsConfigPropArray;
10932     function getContainingFunction(node) {
10933         return findAncestor(node.parent, ts.isFunctionLike);
10934     }
10935     ts.getContainingFunction = getContainingFunction;
10936     function getContainingFunctionDeclaration(node) {
10937         return findAncestor(node.parent, ts.isFunctionLikeDeclaration);
10938     }
10939     ts.getContainingFunctionDeclaration = getContainingFunctionDeclaration;
10940     function getContainingClass(node) {
10941         return findAncestor(node.parent, ts.isClassLike);
10942     }
10943     ts.getContainingClass = getContainingClass;
10944     function getThisContainer(node, includeArrowFunctions) {
10945         ts.Debug.assert(node.kind !== 290);
10946         while (true) {
10947             node = node.parent;
10948             if (!node) {
10949                 return ts.Debug.fail();
10950             }
10951             switch (node.kind) {
10952                 case 154:
10953                     if (ts.isClassLike(node.parent.parent)) {
10954                         return node;
10955                     }
10956                     node = node.parent;
10957                     break;
10958                 case 157:
10959                     if (node.parent.kind === 156 && ts.isClassElement(node.parent.parent)) {
10960                         node = node.parent.parent;
10961                     }
10962                     else if (ts.isClassElement(node.parent)) {
10963                         node = node.parent;
10964                     }
10965                     break;
10966                 case 202:
10967                     if (!includeArrowFunctions) {
10968                         continue;
10969                     }
10970                 case 244:
10971                 case 201:
10972                 case 249:
10973                 case 159:
10974                 case 158:
10975                 case 161:
10976                 case 160:
10977                 case 162:
10978                 case 163:
10979                 case 164:
10980                 case 165:
10981                 case 166:
10982                 case 167:
10983                 case 248:
10984                 case 290:
10985                     return node;
10986             }
10987         }
10988     }
10989     ts.getThisContainer = getThisContainer;
10990     function getNewTargetContainer(node) {
10991         var container = getThisContainer(node, false);
10992         if (container) {
10993             switch (container.kind) {
10994                 case 162:
10995                 case 244:
10996                 case 201:
10997                     return container;
10998             }
10999         }
11000         return undefined;
11001     }
11002     ts.getNewTargetContainer = getNewTargetContainer;
11003     function getSuperContainer(node, stopOnFunctions) {
11004         while (true) {
11005             node = node.parent;
11006             if (!node) {
11007                 return node;
11008             }
11009             switch (node.kind) {
11010                 case 154:
11011                     node = node.parent;
11012                     break;
11013                 case 244:
11014                 case 201:
11015                 case 202:
11016                     if (!stopOnFunctions) {
11017                         continue;
11018                     }
11019                 case 159:
11020                 case 158:
11021                 case 161:
11022                 case 160:
11023                 case 162:
11024                 case 163:
11025                 case 164:
11026                     return node;
11027                 case 157:
11028                     if (node.parent.kind === 156 && ts.isClassElement(node.parent.parent)) {
11029                         node = node.parent.parent;
11030                     }
11031                     else if (ts.isClassElement(node.parent)) {
11032                         node = node.parent;
11033                     }
11034                     break;
11035             }
11036         }
11037     }
11038     ts.getSuperContainer = getSuperContainer;
11039     function getImmediatelyInvokedFunctionExpression(func) {
11040         if (func.kind === 201 || func.kind === 202) {
11041             var prev = func;
11042             var parent = func.parent;
11043             while (parent.kind === 200) {
11044                 prev = parent;
11045                 parent = parent.parent;
11046             }
11047             if (parent.kind === 196 && parent.expression === prev) {
11048                 return parent;
11049             }
11050         }
11051     }
11052     ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression;
11053     function isSuperOrSuperProperty(node) {
11054         return node.kind === 102
11055             || isSuperProperty(node);
11056     }
11057     ts.isSuperOrSuperProperty = isSuperOrSuperProperty;
11058     function isSuperProperty(node) {
11059         var kind = node.kind;
11060         return (kind === 194 || kind === 195)
11061             && node.expression.kind === 102;
11062     }
11063     ts.isSuperProperty = isSuperProperty;
11064     function isThisProperty(node) {
11065         var kind = node.kind;
11066         return (kind === 194 || kind === 195)
11067             && node.expression.kind === 104;
11068     }
11069     ts.isThisProperty = isThisProperty;
11070     function getEntityNameFromTypeNode(node) {
11071         switch (node.kind) {
11072             case 169:
11073                 return node.typeName;
11074             case 216:
11075                 return isEntityNameExpression(node.expression)
11076                     ? node.expression
11077                     : undefined;
11078             case 75:
11079             case 153:
11080                 return node;
11081         }
11082         return undefined;
11083     }
11084     ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode;
11085     function getInvokedExpression(node) {
11086         switch (node.kind) {
11087             case 198:
11088                 return node.tag;
11089             case 268:
11090             case 267:
11091                 return node.tagName;
11092             default:
11093                 return node.expression;
11094         }
11095     }
11096     ts.getInvokedExpression = getInvokedExpression;
11097     function nodeCanBeDecorated(node, parent, grandparent) {
11098         if (ts.isNamedDeclaration(node) && ts.isPrivateIdentifier(node.name)) {
11099             return false;
11100         }
11101         switch (node.kind) {
11102             case 245:
11103                 return true;
11104             case 159:
11105                 return parent.kind === 245;
11106             case 163:
11107             case 164:
11108             case 161:
11109                 return node.body !== undefined
11110                     && parent.kind === 245;
11111             case 156:
11112                 return parent.body !== undefined
11113                     && (parent.kind === 162
11114                         || parent.kind === 161
11115                         || parent.kind === 164)
11116                     && grandparent.kind === 245;
11117         }
11118         return false;
11119     }
11120     ts.nodeCanBeDecorated = nodeCanBeDecorated;
11121     function nodeIsDecorated(node, parent, grandparent) {
11122         return node.decorators !== undefined
11123             && nodeCanBeDecorated(node, parent, grandparent);
11124     }
11125     ts.nodeIsDecorated = nodeIsDecorated;
11126     function nodeOrChildIsDecorated(node, parent, grandparent) {
11127         return nodeIsDecorated(node, parent, grandparent) || childIsDecorated(node, parent);
11128     }
11129     ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated;
11130     function childIsDecorated(node, parent) {
11131         switch (node.kind) {
11132             case 245:
11133                 return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); });
11134             case 161:
11135             case 164:
11136                 return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); });
11137             default:
11138                 return false;
11139         }
11140     }
11141     ts.childIsDecorated = childIsDecorated;
11142     function isJSXTagName(node) {
11143         var parent = node.parent;
11144         if (parent.kind === 268 ||
11145             parent.kind === 267 ||
11146             parent.kind === 269) {
11147             return parent.tagName === node;
11148         }
11149         return false;
11150     }
11151     ts.isJSXTagName = isJSXTagName;
11152     function isExpressionNode(node) {
11153         switch (node.kind) {
11154             case 102:
11155             case 100:
11156             case 106:
11157             case 91:
11158             case 13:
11159             case 192:
11160             case 193:
11161             case 194:
11162             case 195:
11163             case 196:
11164             case 197:
11165             case 198:
11166             case 217:
11167             case 199:
11168             case 218:
11169             case 200:
11170             case 201:
11171             case 214:
11172             case 202:
11173             case 205:
11174             case 203:
11175             case 204:
11176             case 207:
11177             case 208:
11178             case 209:
11179             case 210:
11180             case 213:
11181             case 211:
11182             case 215:
11183             case 266:
11184             case 267:
11185             case 270:
11186             case 212:
11187             case 206:
11188             case 219:
11189                 return true;
11190             case 153:
11191                 while (node.parent.kind === 153) {
11192                     node = node.parent;
11193                 }
11194                 return node.parent.kind === 172 || isJSXTagName(node);
11195             case 75:
11196                 if (node.parent.kind === 172 || isJSXTagName(node)) {
11197                     return true;
11198                 }
11199             case 8:
11200             case 9:
11201             case 10:
11202             case 14:
11203             case 104:
11204                 return isInExpressionContext(node);
11205             default:
11206                 return false;
11207         }
11208     }
11209     ts.isExpressionNode = isExpressionNode;
11210     function isInExpressionContext(node) {
11211         var parent = node.parent;
11212         switch (parent.kind) {
11213             case 242:
11214             case 156:
11215             case 159:
11216             case 158:
11217             case 284:
11218             case 281:
11219             case 191:
11220                 return parent.initializer === node;
11221             case 226:
11222             case 227:
11223             case 228:
11224             case 229:
11225             case 235:
11226             case 236:
11227             case 237:
11228             case 277:
11229             case 239:
11230                 return parent.expression === node;
11231             case 230:
11232                 var forStatement = parent;
11233                 return (forStatement.initializer === node && forStatement.initializer.kind !== 243) ||
11234                     forStatement.condition === node ||
11235                     forStatement.incrementor === node;
11236             case 231:
11237             case 232:
11238                 var forInStatement = parent;
11239                 return (forInStatement.initializer === node && forInStatement.initializer.kind !== 243) ||
11240                     forInStatement.expression === node;
11241             case 199:
11242             case 217:
11243                 return node === parent.expression;
11244             case 221:
11245                 return node === parent.expression;
11246             case 154:
11247                 return node === parent.expression;
11248             case 157:
11249             case 276:
11250             case 275:
11251             case 283:
11252                 return true;
11253             case 216:
11254                 return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent);
11255             case 282:
11256                 return parent.objectAssignmentInitializer === node;
11257             default:
11258                 return isExpressionNode(parent);
11259         }
11260     }
11261     ts.isInExpressionContext = isInExpressionContext;
11262     function isPartOfTypeQuery(node) {
11263         while (node.kind === 153 || node.kind === 75) {
11264             node = node.parent;
11265         }
11266         return node.kind === 172;
11267     }
11268     ts.isPartOfTypeQuery = isPartOfTypeQuery;
11269     function isExternalModuleImportEqualsDeclaration(node) {
11270         return node.kind === 253 && node.moduleReference.kind === 265;
11271     }
11272     ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration;
11273     function getExternalModuleImportEqualsDeclarationExpression(node) {
11274         ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node));
11275         return node.moduleReference.expression;
11276     }
11277     ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression;
11278     function isInternalModuleImportEqualsDeclaration(node) {
11279         return node.kind === 253 && node.moduleReference.kind !== 265;
11280     }
11281     ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration;
11282     function isSourceFileJS(file) {
11283         return isInJSFile(file);
11284     }
11285     ts.isSourceFileJS = isSourceFileJS;
11286     function isSourceFileNotJS(file) {
11287         return !isInJSFile(file);
11288     }
11289     ts.isSourceFileNotJS = isSourceFileNotJS;
11290     function isInJSFile(node) {
11291         return !!node && !!(node.flags & 131072);
11292     }
11293     ts.isInJSFile = isInJSFile;
11294     function isInJsonFile(node) {
11295         return !!node && !!(node.flags & 33554432);
11296     }
11297     ts.isInJsonFile = isInJsonFile;
11298     function isSourceFileNotJson(file) {
11299         return !isJsonSourceFile(file);
11300     }
11301     ts.isSourceFileNotJson = isSourceFileNotJson;
11302     function isInJSDoc(node) {
11303         return !!node && !!(node.flags & 4194304);
11304     }
11305     ts.isInJSDoc = isInJSDoc;
11306     function isJSDocIndexSignature(node) {
11307         return ts.isTypeReferenceNode(node) &&
11308             ts.isIdentifier(node.typeName) &&
11309             node.typeName.escapedText === "Object" &&
11310             node.typeArguments && node.typeArguments.length === 2 &&
11311             (node.typeArguments[0].kind === 143 || node.typeArguments[0].kind === 140);
11312     }
11313     ts.isJSDocIndexSignature = isJSDocIndexSignature;
11314     function isRequireCall(callExpression, requireStringLiteralLikeArgument) {
11315         if (callExpression.kind !== 196) {
11316             return false;
11317         }
11318         var _a = callExpression, expression = _a.expression, args = _a.arguments;
11319         if (expression.kind !== 75 || expression.escapedText !== "require") {
11320             return false;
11321         }
11322         if (args.length !== 1) {
11323             return false;
11324         }
11325         var arg = args[0];
11326         return !requireStringLiteralLikeArgument || ts.isStringLiteralLike(arg);
11327     }
11328     ts.isRequireCall = isRequireCall;
11329     function isRequireVariableDeclaration(node, requireStringLiteralLikeArgument) {
11330         return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(node.initializer, requireStringLiteralLikeArgument);
11331     }
11332     ts.isRequireVariableDeclaration = isRequireVariableDeclaration;
11333     function isRequireVariableDeclarationStatement(node, requireStringLiteralLikeArgument) {
11334         if (requireStringLiteralLikeArgument === void 0) { requireStringLiteralLikeArgument = true; }
11335         return ts.isVariableStatement(node) && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl, requireStringLiteralLikeArgument); });
11336     }
11337     ts.isRequireVariableDeclarationStatement = isRequireVariableDeclarationStatement;
11338     function isSingleOrDoubleQuote(charCode) {
11339         return charCode === 39 || charCode === 34;
11340     }
11341     ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote;
11342     function isStringDoubleQuoted(str, sourceFile) {
11343         return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34;
11344     }
11345     ts.isStringDoubleQuoted = isStringDoubleQuoted;
11346     function getDeclarationOfExpando(node) {
11347         if (!node.parent) {
11348             return undefined;
11349         }
11350         var name;
11351         var decl;
11352         if (ts.isVariableDeclaration(node.parent) && node.parent.initializer === node) {
11353             if (!isInJSFile(node) && !isVarConst(node.parent)) {
11354                 return undefined;
11355             }
11356             name = node.parent.name;
11357             decl = node.parent;
11358         }
11359         else if (ts.isBinaryExpression(node.parent)) {
11360             var parentNode = node.parent;
11361             var parentNodeOperator = node.parent.operatorToken.kind;
11362             if (parentNodeOperator === 62 && parentNode.right === node) {
11363                 name = parentNode.left;
11364                 decl = name;
11365             }
11366             else if (parentNodeOperator === 56 || parentNodeOperator === 60) {
11367                 if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) {
11368                     name = parentNode.parent.name;
11369                     decl = parentNode.parent;
11370                 }
11371                 else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 && parentNode.parent.right === parentNode) {
11372                     name = parentNode.parent.left;
11373                     decl = name;
11374                 }
11375                 if (!name || !isBindableStaticNameExpression(name) || !isSameEntityName(name, parentNode.left)) {
11376                     return undefined;
11377                 }
11378             }
11379         }
11380         if (!name || !getExpandoInitializer(node, isPrototypeAccess(name))) {
11381             return undefined;
11382         }
11383         return decl;
11384     }
11385     ts.getDeclarationOfExpando = getDeclarationOfExpando;
11386     function isAssignmentDeclaration(decl) {
11387         return ts.isBinaryExpression(decl) || isAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl);
11388     }
11389     ts.isAssignmentDeclaration = isAssignmentDeclaration;
11390     function getEffectiveInitializer(node) {
11391         if (isInJSFile(node) && node.initializer &&
11392             ts.isBinaryExpression(node.initializer) &&
11393             (node.initializer.operatorToken.kind === 56 || node.initializer.operatorToken.kind === 60) &&
11394             node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) {
11395             return node.initializer.right;
11396         }
11397         return node.initializer;
11398     }
11399     ts.getEffectiveInitializer = getEffectiveInitializer;
11400     function getDeclaredExpandoInitializer(node) {
11401         var init = getEffectiveInitializer(node);
11402         return init && getExpandoInitializer(init, isPrototypeAccess(node.name));
11403     }
11404     ts.getDeclaredExpandoInitializer = getDeclaredExpandoInitializer;
11405     function hasExpandoValueProperty(node, isPrototypeAssignment) {
11406         return ts.forEach(node.properties, function (p) {
11407             return ts.isPropertyAssignment(p) &&
11408                 ts.isIdentifier(p.name) &&
11409                 p.name.escapedText === "value" &&
11410                 p.initializer &&
11411                 getExpandoInitializer(p.initializer, isPrototypeAssignment);
11412         });
11413     }
11414     function getAssignedExpandoInitializer(node) {
11415         if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62) {
11416             var isPrototypeAssignment = isPrototypeAccess(node.parent.left);
11417             return getExpandoInitializer(node.parent.right, isPrototypeAssignment) ||
11418                 getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment);
11419         }
11420         if (node && ts.isCallExpression(node) && isBindableObjectDefinePropertyCall(node)) {
11421             var result = hasExpandoValueProperty(node.arguments[2], node.arguments[1].text === "prototype");
11422             if (result) {
11423                 return result;
11424             }
11425         }
11426     }
11427     ts.getAssignedExpandoInitializer = getAssignedExpandoInitializer;
11428     function getExpandoInitializer(initializer, isPrototypeAssignment) {
11429         if (ts.isCallExpression(initializer)) {
11430             var e = skipParentheses(initializer.expression);
11431             return e.kind === 201 || e.kind === 202 ? initializer : undefined;
11432         }
11433         if (initializer.kind === 201 ||
11434             initializer.kind === 214 ||
11435             initializer.kind === 202) {
11436             return initializer;
11437         }
11438         if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) {
11439             return initializer;
11440         }
11441     }
11442     ts.getExpandoInitializer = getExpandoInitializer;
11443     function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) {
11444         var e = ts.isBinaryExpression(initializer)
11445             && (initializer.operatorToken.kind === 56 || initializer.operatorToken.kind === 60)
11446             && getExpandoInitializer(initializer.right, isPrototypeAssignment);
11447         if (e && isSameEntityName(name, initializer.left)) {
11448             return e;
11449         }
11450     }
11451     function isDefaultedExpandoInitializer(node) {
11452         var name = ts.isVariableDeclaration(node.parent) ? node.parent.name :
11453             ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 ? node.parent.left :
11454                 undefined;
11455         return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left);
11456     }
11457     ts.isDefaultedExpandoInitializer = isDefaultedExpandoInitializer;
11458     function getNameOfExpando(node) {
11459         if (ts.isBinaryExpression(node.parent)) {
11460             var parent = ((node.parent.operatorToken.kind === 56 || node.parent.operatorToken.kind === 60) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent;
11461             if (parent.operatorToken.kind === 62 && ts.isIdentifier(parent.left)) {
11462                 return parent.left;
11463             }
11464         }
11465         else if (ts.isVariableDeclaration(node.parent)) {
11466             return node.parent.name;
11467         }
11468     }
11469     ts.getNameOfExpando = getNameOfExpando;
11470     function isSameEntityName(name, initializer) {
11471         if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) {
11472             return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(name);
11473         }
11474         if (ts.isIdentifier(name) && isLiteralLikeAccess(initializer) &&
11475             (initializer.expression.kind === 104 ||
11476                 ts.isIdentifier(initializer.expression) &&
11477                     (initializer.expression.escapedText === "window" ||
11478                         initializer.expression.escapedText === "self" ||
11479                         initializer.expression.escapedText === "global"))) {
11480             var nameOrArgument = getNameOrArgument(initializer);
11481             if (ts.isPrivateIdentifier(nameOrArgument)) {
11482                 ts.Debug.fail("Unexpected PrivateIdentifier in name expression with literal-like access.");
11483             }
11484             return isSameEntityName(name, nameOrArgument);
11485         }
11486         if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) {
11487             return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer)
11488                 && isSameEntityName(name.expression, initializer.expression);
11489         }
11490         return false;
11491     }
11492     function getRightMostAssignedExpression(node) {
11493         while (isAssignmentExpression(node, true)) {
11494             node = node.right;
11495         }
11496         return node;
11497     }
11498     ts.getRightMostAssignedExpression = getRightMostAssignedExpression;
11499     function isExportsIdentifier(node) {
11500         return ts.isIdentifier(node) && node.escapedText === "exports";
11501     }
11502     ts.isExportsIdentifier = isExportsIdentifier;
11503     function isModuleIdentifier(node) {
11504         return ts.isIdentifier(node) && node.escapedText === "module";
11505     }
11506     ts.isModuleIdentifier = isModuleIdentifier;
11507     function isModuleExportsAccessExpression(node) {
11508         return (ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node))
11509             && isModuleIdentifier(node.expression)
11510             && getElementOrPropertyAccessName(node) === "exports";
11511     }
11512     ts.isModuleExportsAccessExpression = isModuleExportsAccessExpression;
11513     function getAssignmentDeclarationKind(expr) {
11514         var special = getAssignmentDeclarationKindWorker(expr);
11515         return special === 5 || isInJSFile(expr) ? special : 0;
11516     }
11517     ts.getAssignmentDeclarationKind = getAssignmentDeclarationKind;
11518     function isBindableObjectDefinePropertyCall(expr) {
11519         return ts.length(expr.arguments) === 3 &&
11520             ts.isPropertyAccessExpression(expr.expression) &&
11521             ts.isIdentifier(expr.expression.expression) &&
11522             ts.idText(expr.expression.expression) === "Object" &&
11523             ts.idText(expr.expression.name) === "defineProperty" &&
11524             isStringOrNumericLiteralLike(expr.arguments[1]) &&
11525             isBindableStaticNameExpression(expr.arguments[0], true);
11526     }
11527     ts.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall;
11528     function isLiteralLikeAccess(node) {
11529         return ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node);
11530     }
11531     ts.isLiteralLikeAccess = isLiteralLikeAccess;
11532     function isLiteralLikeElementAccess(node) {
11533         return ts.isElementAccessExpression(node) && (isStringOrNumericLiteralLike(node.argumentExpression) ||
11534             isWellKnownSymbolSyntactically(node.argumentExpression));
11535     }
11536     ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess;
11537     function isBindableStaticAccessExpression(node, excludeThisKeyword) {
11538         return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 104 || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, true))
11539             || isBindableStaticElementAccessExpression(node, excludeThisKeyword);
11540     }
11541     ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression;
11542     function isBindableStaticElementAccessExpression(node, excludeThisKeyword) {
11543         return isLiteralLikeElementAccess(node)
11544             && ((!excludeThisKeyword && node.expression.kind === 104) ||
11545                 isEntityNameExpression(node.expression) ||
11546                 isBindableStaticAccessExpression(node.expression, true));
11547     }
11548     ts.isBindableStaticElementAccessExpression = isBindableStaticElementAccessExpression;
11549     function isBindableStaticNameExpression(node, excludeThisKeyword) {
11550         return isEntityNameExpression(node) || isBindableStaticAccessExpression(node, excludeThisKeyword);
11551     }
11552     ts.isBindableStaticNameExpression = isBindableStaticNameExpression;
11553     function getNameOrArgument(expr) {
11554         if (ts.isPropertyAccessExpression(expr)) {
11555             return expr.name;
11556         }
11557         return expr.argumentExpression;
11558     }
11559     ts.getNameOrArgument = getNameOrArgument;
11560     function getAssignmentDeclarationKindWorker(expr) {
11561         if (ts.isCallExpression(expr)) {
11562             if (!isBindableObjectDefinePropertyCall(expr)) {
11563                 return 0;
11564             }
11565             var entityName = expr.arguments[0];
11566             if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) {
11567                 return 8;
11568             }
11569             if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") {
11570                 return 9;
11571             }
11572             return 7;
11573         }
11574         if (expr.operatorToken.kind !== 62 || !isAccessExpression(expr.left)) {
11575             return 0;
11576         }
11577         if (isBindableStaticNameExpression(expr.left.expression, true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) {
11578             return 6;
11579         }
11580         return getAssignmentDeclarationPropertyAccessKind(expr.left);
11581     }
11582     function getElementOrPropertyAccessArgumentExpressionOrName(node) {
11583         if (ts.isPropertyAccessExpression(node)) {
11584             return node.name;
11585         }
11586         var arg = skipParentheses(node.argumentExpression);
11587         if (ts.isNumericLiteral(arg) || ts.isStringLiteralLike(arg)) {
11588             return arg;
11589         }
11590         return node;
11591     }
11592     ts.getElementOrPropertyAccessArgumentExpressionOrName = getElementOrPropertyAccessArgumentExpressionOrName;
11593     function getElementOrPropertyAccessName(node) {
11594         var name = getElementOrPropertyAccessArgumentExpressionOrName(node);
11595         if (name) {
11596             if (ts.isIdentifier(name)) {
11597                 return name.escapedText;
11598             }
11599             if (ts.isStringLiteralLike(name) || ts.isNumericLiteral(name)) {
11600                 return ts.escapeLeadingUnderscores(name.text);
11601             }
11602         }
11603         if (ts.isElementAccessExpression(node) && isWellKnownSymbolSyntactically(node.argumentExpression)) {
11604             return getPropertyNameForKnownSymbolName(ts.idText(node.argumentExpression.name));
11605         }
11606         return undefined;
11607     }
11608     ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName;
11609     function getAssignmentDeclarationPropertyAccessKind(lhs) {
11610         if (lhs.expression.kind === 104) {
11611             return 4;
11612         }
11613         else if (isModuleExportsAccessExpression(lhs)) {
11614             return 2;
11615         }
11616         else if (isBindableStaticNameExpression(lhs.expression, true)) {
11617             if (isPrototypeAccess(lhs.expression)) {
11618                 return 3;
11619             }
11620             var nextToLast = lhs;
11621             while (!ts.isIdentifier(nextToLast.expression)) {
11622                 nextToLast = nextToLast.expression;
11623             }
11624             var id = nextToLast.expression;
11625             if ((id.escapedText === "exports" ||
11626                 id.escapedText === "module" && getElementOrPropertyAccessName(nextToLast) === "exports") &&
11627                 isBindableStaticAccessExpression(lhs)) {
11628                 return 1;
11629             }
11630             if (isBindableStaticNameExpression(lhs, true) || (ts.isElementAccessExpression(lhs) && isDynamicName(lhs))) {
11631                 return 5;
11632             }
11633         }
11634         return 0;
11635     }
11636     ts.getAssignmentDeclarationPropertyAccessKind = getAssignmentDeclarationPropertyAccessKind;
11637     function getInitializerOfBinaryExpression(expr) {
11638         while (ts.isBinaryExpression(expr.right)) {
11639             expr = expr.right;
11640         }
11641         return expr.right;
11642     }
11643     ts.getInitializerOfBinaryExpression = getInitializerOfBinaryExpression;
11644     function isPrototypePropertyAssignment(node) {
11645         return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3;
11646     }
11647     ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment;
11648     function isSpecialPropertyDeclaration(expr) {
11649         return isInJSFile(expr) &&
11650             expr.parent && expr.parent.kind === 226 &&
11651             (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) &&
11652             !!ts.getJSDocTypeTag(expr.parent);
11653     }
11654     ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration;
11655     function setValueDeclaration(symbol, node) {
11656         var valueDeclaration = symbol.valueDeclaration;
11657         if (!valueDeclaration ||
11658             !(node.flags & 8388608 && !(valueDeclaration.flags & 8388608)) &&
11659                 (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) ||
11660             (valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) {
11661             symbol.valueDeclaration = node;
11662         }
11663     }
11664     ts.setValueDeclaration = setValueDeclaration;
11665     function isFunctionSymbol(symbol) {
11666         if (!symbol || !symbol.valueDeclaration) {
11667             return false;
11668         }
11669         var decl = symbol.valueDeclaration;
11670         return decl.kind === 244 || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer);
11671     }
11672     ts.isFunctionSymbol = isFunctionSymbol;
11673     function importFromModuleSpecifier(node) {
11674         return tryGetImportFromModuleSpecifier(node) || ts.Debug.failBadSyntaxKind(node.parent);
11675     }
11676     ts.importFromModuleSpecifier = importFromModuleSpecifier;
11677     function tryGetImportFromModuleSpecifier(node) {
11678         switch (node.parent.kind) {
11679             case 254:
11680             case 260:
11681                 return node.parent;
11682             case 265:
11683                 return node.parent.parent;
11684             case 196:
11685                 return isImportCall(node.parent) || isRequireCall(node.parent, false) ? node.parent : undefined;
11686             case 187:
11687                 ts.Debug.assert(ts.isStringLiteral(node));
11688                 return ts.tryCast(node.parent.parent, ts.isImportTypeNode);
11689             default:
11690                 return undefined;
11691         }
11692     }
11693     ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier;
11694     function getExternalModuleName(node) {
11695         switch (node.kind) {
11696             case 254:
11697             case 260:
11698                 return node.moduleSpecifier;
11699             case 253:
11700                 return node.moduleReference.kind === 265 ? node.moduleReference.expression : undefined;
11701             case 188:
11702                 return isLiteralImportTypeNode(node) ? node.argument.literal : undefined;
11703             default:
11704                 return ts.Debug.assertNever(node);
11705         }
11706     }
11707     ts.getExternalModuleName = getExternalModuleName;
11708     function getNamespaceDeclarationNode(node) {
11709         switch (node.kind) {
11710             case 254:
11711                 return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport);
11712             case 253:
11713                 return node;
11714             case 260:
11715                 return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport);
11716             default:
11717                 return ts.Debug.assertNever(node);
11718         }
11719     }
11720     ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode;
11721     function isDefaultImport(node) {
11722         return node.kind === 254 && !!node.importClause && !!node.importClause.name;
11723     }
11724     ts.isDefaultImport = isDefaultImport;
11725     function forEachImportClauseDeclaration(node, action) {
11726         if (node.name) {
11727             var result = action(node);
11728             if (result)
11729                 return result;
11730         }
11731         if (node.namedBindings) {
11732             var result = ts.isNamespaceImport(node.namedBindings)
11733                 ? action(node.namedBindings)
11734                 : ts.forEach(node.namedBindings.elements, action);
11735             if (result)
11736                 return result;
11737         }
11738     }
11739     ts.forEachImportClauseDeclaration = forEachImportClauseDeclaration;
11740     function hasQuestionToken(node) {
11741         if (node) {
11742             switch (node.kind) {
11743                 case 156:
11744                 case 161:
11745                 case 160:
11746                 case 282:
11747                 case 281:
11748                 case 159:
11749                 case 158:
11750                     return node.questionToken !== undefined;
11751             }
11752         }
11753         return false;
11754     }
11755     ts.hasQuestionToken = hasQuestionToken;
11756     function isJSDocConstructSignature(node) {
11757         var param = ts.isJSDocFunctionType(node) ? ts.firstOrUndefined(node.parameters) : undefined;
11758         var name = ts.tryCast(param && param.name, ts.isIdentifier);
11759         return !!name && name.escapedText === "new";
11760     }
11761     ts.isJSDocConstructSignature = isJSDocConstructSignature;
11762     function isJSDocTypeAlias(node) {
11763         return node.kind === 322 || node.kind === 315 || node.kind === 316;
11764     }
11765     ts.isJSDocTypeAlias = isJSDocTypeAlias;
11766     function isTypeAlias(node) {
11767         return isJSDocTypeAlias(node) || ts.isTypeAliasDeclaration(node);
11768     }
11769     ts.isTypeAlias = isTypeAlias;
11770     function getSourceOfAssignment(node) {
11771         return ts.isExpressionStatement(node) &&
11772             ts.isBinaryExpression(node.expression) &&
11773             node.expression.operatorToken.kind === 62
11774             ? getRightMostAssignedExpression(node.expression)
11775             : undefined;
11776     }
11777     function getSourceOfDefaultedAssignment(node) {
11778         return ts.isExpressionStatement(node) &&
11779             ts.isBinaryExpression(node.expression) &&
11780             getAssignmentDeclarationKind(node.expression) !== 0 &&
11781             ts.isBinaryExpression(node.expression.right) &&
11782             (node.expression.right.operatorToken.kind === 56 || node.expression.right.operatorToken.kind === 60)
11783             ? node.expression.right.right
11784             : undefined;
11785     }
11786     function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) {
11787         switch (node.kind) {
11788             case 225:
11789                 var v = getSingleVariableOfVariableStatement(node);
11790                 return v && v.initializer;
11791             case 159:
11792                 return node.initializer;
11793             case 281:
11794                 return node.initializer;
11795         }
11796     }
11797     ts.getSingleInitializerOfVariableStatementOrPropertyDeclaration = getSingleInitializerOfVariableStatementOrPropertyDeclaration;
11798     function getSingleVariableOfVariableStatement(node) {
11799         return ts.isVariableStatement(node) ? ts.firstOrUndefined(node.declarationList.declarations) : undefined;
11800     }
11801     function getNestedModuleDeclaration(node) {
11802         return ts.isModuleDeclaration(node) &&
11803             node.body &&
11804             node.body.kind === 249
11805             ? node.body
11806             : undefined;
11807     }
11808     function getJSDocCommentsAndTags(hostNode) {
11809         var result;
11810         if (isVariableLike(hostNode) && ts.hasInitializer(hostNode) && ts.hasJSDocNodes(hostNode.initializer)) {
11811             result = ts.append(result, ts.last(hostNode.initializer.jsDoc));
11812         }
11813         var node = hostNode;
11814         while (node && node.parent) {
11815             if (ts.hasJSDocNodes(node)) {
11816                 result = ts.append(result, ts.last(node.jsDoc));
11817             }
11818             if (node.kind === 156) {
11819                 result = ts.addRange(result, ts.getJSDocParameterTags(node));
11820                 break;
11821             }
11822             if (node.kind === 155) {
11823                 result = ts.addRange(result, ts.getJSDocTypeParameterTags(node));
11824                 break;
11825             }
11826             node = getNextJSDocCommentLocation(node);
11827         }
11828         return result || ts.emptyArray;
11829     }
11830     ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags;
11831     function getNextJSDocCommentLocation(node) {
11832         var parent = node.parent;
11833         if (parent.kind === 281 ||
11834             parent.kind === 259 ||
11835             parent.kind === 159 ||
11836             parent.kind === 226 && node.kind === 194 ||
11837             getNestedModuleDeclaration(parent) ||
11838             ts.isBinaryExpression(node) && node.operatorToken.kind === 62) {
11839             return parent;
11840         }
11841         else if (parent.parent &&
11842             (getSingleVariableOfVariableStatement(parent.parent) === node ||
11843                 ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62)) {
11844             return parent.parent;
11845         }
11846         else if (parent.parent && parent.parent.parent &&
11847             (getSingleVariableOfVariableStatement(parent.parent.parent) ||
11848                 getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node ||
11849                 getSourceOfDefaultedAssignment(parent.parent.parent))) {
11850             return parent.parent.parent;
11851         }
11852     }
11853     function getParameterSymbolFromJSDoc(node) {
11854         if (node.symbol) {
11855             return node.symbol;
11856         }
11857         if (!ts.isIdentifier(node.name)) {
11858             return undefined;
11859         }
11860         var name = node.name.escapedText;
11861         var decl = getHostSignatureFromJSDoc(node);
11862         if (!decl) {
11863             return undefined;
11864         }
11865         var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 75 && p.name.escapedText === name; });
11866         return parameter && parameter.symbol;
11867     }
11868     ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc;
11869     function getHostSignatureFromJSDoc(node) {
11870         var host = getEffectiveJSDocHost(node);
11871         return host && ts.isFunctionLike(host) ? host : undefined;
11872     }
11873     ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc;
11874     function getEffectiveJSDocHost(node) {
11875         var host = getJSDocHost(node);
11876         var decl = getSourceOfDefaultedAssignment(host) ||
11877             getSourceOfAssignment(host) ||
11878             getSingleInitializerOfVariableStatementOrPropertyDeclaration(host) ||
11879             getSingleVariableOfVariableStatement(host) ||
11880             getNestedModuleDeclaration(host) ||
11881             host;
11882         return decl;
11883     }
11884     ts.getEffectiveJSDocHost = getEffectiveJSDocHost;
11885     function getJSDocHost(node) {
11886         return ts.Debug.checkDefined(findAncestor(node.parent, ts.isJSDoc)).parent;
11887     }
11888     ts.getJSDocHost = getJSDocHost;
11889     function getTypeParameterFromJsDoc(node) {
11890         var name = node.name.escapedText;
11891         var typeParameters = node.parent.parent.parent.typeParameters;
11892         return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; });
11893     }
11894     ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc;
11895     function hasRestParameter(s) {
11896         var last = ts.lastOrUndefined(s.parameters);
11897         return !!last && isRestParameter(last);
11898     }
11899     ts.hasRestParameter = hasRestParameter;
11900     function isRestParameter(node) {
11901         var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type;
11902         return node.dotDotDotToken !== undefined || !!type && type.kind === 301;
11903     }
11904     ts.isRestParameter = isRestParameter;
11905     function hasTypeArguments(node) {
11906         return !!node.typeArguments;
11907     }
11908     ts.hasTypeArguments = hasTypeArguments;
11909     function getAssignmentTargetKind(node) {
11910         var parent = node.parent;
11911         while (true) {
11912             switch (parent.kind) {
11913                 case 209:
11914                     var binaryOperator = parent.operatorToken.kind;
11915                     return isAssignmentOperator(binaryOperator) && parent.left === node ?
11916                         binaryOperator === 62 ? 1 : 2 :
11917                         0;
11918                 case 207:
11919                 case 208:
11920                     var unaryOperator = parent.operator;
11921                     return unaryOperator === 45 || unaryOperator === 46 ? 2 : 0;
11922                 case 231:
11923                 case 232:
11924                     return parent.initializer === node ? 1 : 0;
11925                 case 200:
11926                 case 192:
11927                 case 213:
11928                 case 218:
11929                     node = parent;
11930                     break;
11931                 case 282:
11932                     if (parent.name !== node) {
11933                         return 0;
11934                     }
11935                     node = parent.parent;
11936                     break;
11937                 case 281:
11938                     if (parent.name === node) {
11939                         return 0;
11940                     }
11941                     node = parent.parent;
11942                     break;
11943                 default:
11944                     return 0;
11945             }
11946             parent = node.parent;
11947         }
11948     }
11949     ts.getAssignmentTargetKind = getAssignmentTargetKind;
11950     function isAssignmentTarget(node) {
11951         return getAssignmentTargetKind(node) !== 0;
11952     }
11953     ts.isAssignmentTarget = isAssignmentTarget;
11954     function isNodeWithPossibleHoistedDeclaration(node) {
11955         switch (node.kind) {
11956             case 223:
11957             case 225:
11958             case 236:
11959             case 227:
11960             case 237:
11961             case 251:
11962             case 277:
11963             case 278:
11964             case 238:
11965             case 230:
11966             case 231:
11967             case 232:
11968             case 228:
11969             case 229:
11970             case 240:
11971             case 280:
11972                 return true;
11973         }
11974         return false;
11975     }
11976     ts.isNodeWithPossibleHoistedDeclaration = isNodeWithPossibleHoistedDeclaration;
11977     function isValueSignatureDeclaration(node) {
11978         return ts.isFunctionExpression(node) || ts.isArrowFunction(node) || ts.isMethodOrAccessor(node) || ts.isFunctionDeclaration(node) || ts.isConstructorDeclaration(node);
11979     }
11980     ts.isValueSignatureDeclaration = isValueSignatureDeclaration;
11981     function walkUp(node, kind) {
11982         while (node && node.kind === kind) {
11983             node = node.parent;
11984         }
11985         return node;
11986     }
11987     function walkUpParenthesizedTypes(node) {
11988         return walkUp(node, 182);
11989     }
11990     ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes;
11991     function walkUpParenthesizedExpressions(node) {
11992         return walkUp(node, 200);
11993     }
11994     ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions;
11995     function skipParentheses(node) {
11996         return ts.skipOuterExpressions(node, 1);
11997     }
11998     ts.skipParentheses = skipParentheses;
11999     function skipParenthesesUp(node) {
12000         while (node.kind === 200) {
12001             node = node.parent;
12002         }
12003         return node;
12004     }
12005     function isDeleteTarget(node) {
12006         if (node.kind !== 194 && node.kind !== 195) {
12007             return false;
12008         }
12009         node = walkUpParenthesizedExpressions(node.parent);
12010         return node && node.kind === 203;
12011     }
12012     ts.isDeleteTarget = isDeleteTarget;
12013     function isNodeDescendantOf(node, ancestor) {
12014         while (node) {
12015             if (node === ancestor)
12016                 return true;
12017             node = node.parent;
12018         }
12019         return false;
12020     }
12021     ts.isNodeDescendantOf = isNodeDescendantOf;
12022     function isDeclarationName(name) {
12023         return !ts.isSourceFile(name) && !ts.isBindingPattern(name) && ts.isDeclaration(name.parent) && name.parent.name === name;
12024     }
12025     ts.isDeclarationName = isDeclarationName;
12026     function getDeclarationFromName(name) {
12027         var parent = name.parent;
12028         switch (name.kind) {
12029             case 10:
12030             case 14:
12031             case 8:
12032                 if (ts.isComputedPropertyName(parent))
12033                     return parent.parent;
12034             case 75:
12035                 if (ts.isDeclaration(parent)) {
12036                     return parent.name === name ? parent : undefined;
12037                 }
12038                 else if (ts.isQualifiedName(parent)) {
12039                     var tag = parent.parent;
12040                     return ts.isJSDocParameterTag(tag) && tag.name === parent ? tag : undefined;
12041                 }
12042                 else {
12043                     var binExp = parent.parent;
12044                     return ts.isBinaryExpression(binExp) &&
12045                         getAssignmentDeclarationKind(binExp) !== 0 &&
12046                         (binExp.left.symbol || binExp.symbol) &&
12047                         ts.getNameOfDeclaration(binExp) === name
12048                         ? binExp
12049                         : undefined;
12050                 }
12051             case 76:
12052                 return ts.isDeclaration(parent) && parent.name === name ? parent : undefined;
12053             default:
12054                 return undefined;
12055         }
12056     }
12057     ts.getDeclarationFromName = getDeclarationFromName;
12058     function isLiteralComputedPropertyDeclarationName(node) {
12059         return isStringOrNumericLiteralLike(node) &&
12060             node.parent.kind === 154 &&
12061             ts.isDeclaration(node.parent.parent);
12062     }
12063     ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName;
12064     function isIdentifierName(node) {
12065         var parent = node.parent;
12066         switch (parent.kind) {
12067             case 159:
12068             case 158:
12069             case 161:
12070             case 160:
12071             case 163:
12072             case 164:
12073             case 284:
12074             case 281:
12075             case 194:
12076                 return parent.name === node;
12077             case 153:
12078                 if (parent.right === node) {
12079                     while (parent.kind === 153) {
12080                         parent = parent.parent;
12081                     }
12082                     return parent.kind === 172 || parent.kind === 169;
12083                 }
12084                 return false;
12085             case 191:
12086             case 258:
12087                 return parent.propertyName === node;
12088             case 263:
12089             case 273:
12090                 return true;
12091         }
12092         return false;
12093     }
12094     ts.isIdentifierName = isIdentifierName;
12095     function isAliasSymbolDeclaration(node) {
12096         return node.kind === 253 ||
12097             node.kind === 252 ||
12098             node.kind === 255 && !!node.name ||
12099             node.kind === 256 ||
12100             node.kind === 262 ||
12101             node.kind === 258 ||
12102             node.kind === 263 ||
12103             node.kind === 259 && exportAssignmentIsAlias(node) ||
12104             ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 && exportAssignmentIsAlias(node) ||
12105             ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 && isAliasableExpression(node.parent.right) ||
12106             node.kind === 282 ||
12107             node.kind === 281 && isAliasableExpression(node.initializer);
12108     }
12109     ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration;
12110     function getAliasDeclarationFromName(node) {
12111         switch (node.parent.kind) {
12112             case 255:
12113             case 258:
12114             case 256:
12115             case 263:
12116             case 259:
12117             case 253:
12118                 return node.parent;
12119             case 153:
12120                 do {
12121                     node = node.parent;
12122                 } while (node.parent.kind === 153);
12123                 return getAliasDeclarationFromName(node);
12124         }
12125     }
12126     ts.getAliasDeclarationFromName = getAliasDeclarationFromName;
12127     function isAliasableExpression(e) {
12128         return isEntityNameExpression(e) || ts.isClassExpression(e);
12129     }
12130     ts.isAliasableExpression = isAliasableExpression;
12131     function exportAssignmentIsAlias(node) {
12132         var e = getExportAssignmentExpression(node);
12133         return isAliasableExpression(e);
12134     }
12135     ts.exportAssignmentIsAlias = exportAssignmentIsAlias;
12136     function getExportAssignmentExpression(node) {
12137         return ts.isExportAssignment(node) ? node.expression : node.right;
12138     }
12139     ts.getExportAssignmentExpression = getExportAssignmentExpression;
12140     function getPropertyAssignmentAliasLikeExpression(node) {
12141         return node.kind === 282 ? node.name : node.kind === 281 ? node.initializer :
12142             node.parent.right;
12143     }
12144     ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression;
12145     function getEffectiveBaseTypeNode(node) {
12146         var baseType = getClassExtendsHeritageElement(node);
12147         if (baseType && isInJSFile(node)) {
12148             var tag = ts.getJSDocAugmentsTag(node);
12149             if (tag) {
12150                 return tag.class;
12151             }
12152         }
12153         return baseType;
12154     }
12155     ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode;
12156     function getClassExtendsHeritageElement(node) {
12157         var heritageClause = getHeritageClause(node.heritageClauses, 90);
12158         return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined;
12159     }
12160     ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement;
12161     function getEffectiveImplementsTypeNodes(node) {
12162         if (isInJSFile(node)) {
12163             return ts.getJSDocImplementsTags(node).map(function (n) { return n.class; });
12164         }
12165         else {
12166             var heritageClause = getHeritageClause(node.heritageClauses, 113);
12167             return heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.types;
12168         }
12169     }
12170     ts.getEffectiveImplementsTypeNodes = getEffectiveImplementsTypeNodes;
12171     function getAllSuperTypeNodes(node) {
12172         return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray :
12173             ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getEffectiveImplementsTypeNodes(node)) || ts.emptyArray :
12174                 ts.emptyArray;
12175     }
12176     ts.getAllSuperTypeNodes = getAllSuperTypeNodes;
12177     function getInterfaceBaseTypeNodes(node) {
12178         var heritageClause = getHeritageClause(node.heritageClauses, 90);
12179         return heritageClause ? heritageClause.types : undefined;
12180     }
12181     ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes;
12182     function getHeritageClause(clauses, kind) {
12183         if (clauses) {
12184             for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) {
12185                 var clause = clauses_1[_i];
12186                 if (clause.token === kind) {
12187                     return clause;
12188                 }
12189             }
12190         }
12191         return undefined;
12192     }
12193     ts.getHeritageClause = getHeritageClause;
12194     function getAncestor(node, kind) {
12195         while (node) {
12196             if (node.kind === kind) {
12197                 return node;
12198             }
12199             node = node.parent;
12200         }
12201         return undefined;
12202     }
12203     ts.getAncestor = getAncestor;
12204     function isKeyword(token) {
12205         return 77 <= token && token <= 152;
12206     }
12207     ts.isKeyword = isKeyword;
12208     function isContextualKeyword(token) {
12209         return 122 <= token && token <= 152;
12210     }
12211     ts.isContextualKeyword = isContextualKeyword;
12212     function isNonContextualKeyword(token) {
12213         return isKeyword(token) && !isContextualKeyword(token);
12214     }
12215     ts.isNonContextualKeyword = isNonContextualKeyword;
12216     function isFutureReservedKeyword(token) {
12217         return 113 <= token && token <= 121;
12218     }
12219     ts.isFutureReservedKeyword = isFutureReservedKeyword;
12220     function isStringANonContextualKeyword(name) {
12221         var token = ts.stringToToken(name);
12222         return token !== undefined && isNonContextualKeyword(token);
12223     }
12224     ts.isStringANonContextualKeyword = isStringANonContextualKeyword;
12225     function isStringAKeyword(name) {
12226         var token = ts.stringToToken(name);
12227         return token !== undefined && isKeyword(token);
12228     }
12229     ts.isStringAKeyword = isStringAKeyword;
12230     function isIdentifierANonContextualKeyword(_a) {
12231         var originalKeywordKind = _a.originalKeywordKind;
12232         return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind);
12233     }
12234     ts.isIdentifierANonContextualKeyword = isIdentifierANonContextualKeyword;
12235     function isTrivia(token) {
12236         return 2 <= token && token <= 7;
12237     }
12238     ts.isTrivia = isTrivia;
12239     function getFunctionFlags(node) {
12240         if (!node) {
12241             return 4;
12242         }
12243         var flags = 0;
12244         switch (node.kind) {
12245             case 244:
12246             case 201:
12247             case 161:
12248                 if (node.asteriskToken) {
12249                     flags |= 1;
12250                 }
12251             case 202:
12252                 if (hasModifier(node, 256)) {
12253                     flags |= 2;
12254                 }
12255                 break;
12256         }
12257         if (!node.body) {
12258             flags |= 4;
12259         }
12260         return flags;
12261     }
12262     ts.getFunctionFlags = getFunctionFlags;
12263     function isAsyncFunction(node) {
12264         switch (node.kind) {
12265             case 244:
12266             case 201:
12267             case 202:
12268             case 161:
12269                 return node.body !== undefined
12270                     && node.asteriskToken === undefined
12271                     && hasModifier(node, 256);
12272         }
12273         return false;
12274     }
12275     ts.isAsyncFunction = isAsyncFunction;
12276     function isStringOrNumericLiteralLike(node) {
12277         return ts.isStringLiteralLike(node) || ts.isNumericLiteral(node);
12278     }
12279     ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike;
12280     function isSignedNumericLiteral(node) {
12281         return ts.isPrefixUnaryExpression(node) && (node.operator === 39 || node.operator === 40) && ts.isNumericLiteral(node.operand);
12282     }
12283     ts.isSignedNumericLiteral = isSignedNumericLiteral;
12284     function hasDynamicName(declaration) {
12285         var name = ts.getNameOfDeclaration(declaration);
12286         return !!name && isDynamicName(name);
12287     }
12288     ts.hasDynamicName = hasDynamicName;
12289     function isDynamicName(name) {
12290         if (!(name.kind === 154 || name.kind === 195)) {
12291             return false;
12292         }
12293         var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression;
12294         return !isStringOrNumericLiteralLike(expr) &&
12295             !isSignedNumericLiteral(expr) &&
12296             !isWellKnownSymbolSyntactically(expr);
12297     }
12298     ts.isDynamicName = isDynamicName;
12299     function isWellKnownSymbolSyntactically(node) {
12300         return ts.isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression);
12301     }
12302     ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically;
12303     function getPropertyNameForPropertyNameNode(name) {
12304         switch (name.kind) {
12305             case 75:
12306             case 76:
12307                 return name.escapedText;
12308             case 10:
12309             case 8:
12310                 return ts.escapeLeadingUnderscores(name.text);
12311             case 154:
12312                 var nameExpression = name.expression;
12313                 if (isWellKnownSymbolSyntactically(nameExpression)) {
12314                     return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name));
12315                 }
12316                 else if (isStringOrNumericLiteralLike(nameExpression)) {
12317                     return ts.escapeLeadingUnderscores(nameExpression.text);
12318                 }
12319                 return undefined;
12320             default:
12321                 return ts.Debug.assertNever(name);
12322         }
12323     }
12324     ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode;
12325     function isPropertyNameLiteral(node) {
12326         switch (node.kind) {
12327             case 75:
12328             case 10:
12329             case 14:
12330             case 8:
12331                 return true;
12332             default:
12333                 return false;
12334         }
12335     }
12336     ts.isPropertyNameLiteral = isPropertyNameLiteral;
12337     function getTextOfIdentifierOrLiteral(node) {
12338         return ts.isIdentifierOrPrivateIdentifier(node) ? ts.idText(node) : node.text;
12339     }
12340     ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral;
12341     function getEscapedTextOfIdentifierOrLiteral(node) {
12342         return ts.isIdentifierOrPrivateIdentifier(node) ? node.escapedText : ts.escapeLeadingUnderscores(node.text);
12343     }
12344     ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral;
12345     function getPropertyNameForUniqueESSymbol(symbol) {
12346         return "__@" + ts.getSymbolId(symbol) + "@" + symbol.escapedName;
12347     }
12348     ts.getPropertyNameForUniqueESSymbol = getPropertyNameForUniqueESSymbol;
12349     function getPropertyNameForKnownSymbolName(symbolName) {
12350         return "__@" + symbolName;
12351     }
12352     ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName;
12353     function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) {
12354         return "__#" + ts.getSymbolId(containingClassSymbol) + "@" + description;
12355     }
12356     ts.getSymbolNameForPrivateIdentifier = getSymbolNameForPrivateIdentifier;
12357     function isKnownSymbol(symbol) {
12358         return ts.startsWith(symbol.escapedName, "__@");
12359     }
12360     ts.isKnownSymbol = isKnownSymbol;
12361     function isESSymbolIdentifier(node) {
12362         return node.kind === 75 && node.escapedText === "Symbol";
12363     }
12364     ts.isESSymbolIdentifier = isESSymbolIdentifier;
12365     function isPushOrUnshiftIdentifier(node) {
12366         return node.escapedText === "push" || node.escapedText === "unshift";
12367     }
12368     ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier;
12369     function isParameterDeclaration(node) {
12370         var root = getRootDeclaration(node);
12371         return root.kind === 156;
12372     }
12373     ts.isParameterDeclaration = isParameterDeclaration;
12374     function getRootDeclaration(node) {
12375         while (node.kind === 191) {
12376             node = node.parent.parent;
12377         }
12378         return node;
12379     }
12380     ts.getRootDeclaration = getRootDeclaration;
12381     function nodeStartsNewLexicalEnvironment(node) {
12382         var kind = node.kind;
12383         return kind === 162
12384             || kind === 201
12385             || kind === 244
12386             || kind === 202
12387             || kind === 161
12388             || kind === 163
12389             || kind === 164
12390             || kind === 249
12391             || kind === 290;
12392     }
12393     ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment;
12394     function nodeIsSynthesized(range) {
12395         return positionIsSynthesized(range.pos)
12396             || positionIsSynthesized(range.end);
12397     }
12398     ts.nodeIsSynthesized = nodeIsSynthesized;
12399     function getOriginalSourceFile(sourceFile) {
12400         return ts.getParseTreeNode(sourceFile, ts.isSourceFile) || sourceFile;
12401     }
12402     ts.getOriginalSourceFile = getOriginalSourceFile;
12403     function getExpressionAssociativity(expression) {
12404         var operator = getOperator(expression);
12405         var hasArguments = expression.kind === 197 && expression.arguments !== undefined;
12406         return getOperatorAssociativity(expression.kind, operator, hasArguments);
12407     }
12408     ts.getExpressionAssociativity = getExpressionAssociativity;
12409     function getOperatorAssociativity(kind, operator, hasArguments) {
12410         switch (kind) {
12411             case 197:
12412                 return hasArguments ? 0 : 1;
12413             case 207:
12414             case 204:
12415             case 205:
12416             case 203:
12417             case 206:
12418             case 210:
12419             case 212:
12420                 return 1;
12421             case 209:
12422                 switch (operator) {
12423                     case 42:
12424                     case 62:
12425                     case 63:
12426                     case 64:
12427                     case 66:
12428                     case 65:
12429                     case 67:
12430                     case 68:
12431                     case 69:
12432                     case 70:
12433                     case 71:
12434                     case 72:
12435                     case 74:
12436                     case 73:
12437                         return 1;
12438                 }
12439         }
12440         return 0;
12441     }
12442     ts.getOperatorAssociativity = getOperatorAssociativity;
12443     function getExpressionPrecedence(expression) {
12444         var operator = getOperator(expression);
12445         var hasArguments = expression.kind === 197 && expression.arguments !== undefined;
12446         return getOperatorPrecedence(expression.kind, operator, hasArguments);
12447     }
12448     ts.getExpressionPrecedence = getExpressionPrecedence;
12449     function getOperator(expression) {
12450         if (expression.kind === 209) {
12451             return expression.operatorToken.kind;
12452         }
12453         else if (expression.kind === 207 || expression.kind === 208) {
12454             return expression.operator;
12455         }
12456         else {
12457             return expression.kind;
12458         }
12459     }
12460     ts.getOperator = getOperator;
12461     function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) {
12462         switch (nodeKind) {
12463             case 327:
12464                 return 0;
12465             case 213:
12466                 return 1;
12467             case 212:
12468                 return 2;
12469             case 210:
12470                 return 4;
12471             case 209:
12472                 switch (operatorKind) {
12473                     case 27:
12474                         return 0;
12475                     case 62:
12476                     case 63:
12477                     case 64:
12478                     case 66:
12479                     case 65:
12480                     case 67:
12481                     case 68:
12482                     case 69:
12483                     case 70:
12484                     case 71:
12485                     case 72:
12486                     case 74:
12487                     case 73:
12488                         return 3;
12489                     default:
12490                         return getBinaryOperatorPrecedence(operatorKind);
12491                 }
12492             case 207:
12493             case 204:
12494             case 205:
12495             case 203:
12496             case 206:
12497                 return 16;
12498             case 208:
12499                 return 17;
12500             case 196:
12501                 return 18;
12502             case 197:
12503                 return hasArguments ? 19 : 18;
12504             case 198:
12505             case 194:
12506             case 195:
12507                 return 19;
12508             case 104:
12509             case 102:
12510             case 75:
12511             case 100:
12512             case 106:
12513             case 91:
12514             case 8:
12515             case 9:
12516             case 10:
12517             case 192:
12518             case 193:
12519             case 201:
12520             case 202:
12521             case 214:
12522             case 266:
12523             case 267:
12524             case 270:
12525             case 13:
12526             case 14:
12527             case 211:
12528             case 200:
12529             case 215:
12530                 return 20;
12531             default:
12532                 return -1;
12533         }
12534     }
12535     ts.getOperatorPrecedence = getOperatorPrecedence;
12536     function getBinaryOperatorPrecedence(kind) {
12537         switch (kind) {
12538             case 60:
12539                 return 4;
12540             case 56:
12541                 return 5;
12542             case 55:
12543                 return 6;
12544             case 51:
12545                 return 7;
12546             case 52:
12547                 return 8;
12548             case 50:
12549                 return 9;
12550             case 34:
12551             case 35:
12552             case 36:
12553             case 37:
12554                 return 10;
12555             case 29:
12556             case 31:
12557             case 32:
12558             case 33:
12559             case 98:
12560             case 97:
12561             case 123:
12562                 return 11;
12563             case 47:
12564             case 48:
12565             case 49:
12566                 return 12;
12567             case 39:
12568             case 40:
12569                 return 13;
12570             case 41:
12571             case 43:
12572             case 44:
12573                 return 14;
12574             case 42:
12575                 return 15;
12576         }
12577         return -1;
12578     }
12579     ts.getBinaryOperatorPrecedence = getBinaryOperatorPrecedence;
12580     function createDiagnosticCollection() {
12581         var nonFileDiagnostics = [];
12582         var filesWithDiagnostics = [];
12583         var fileDiagnostics = ts.createMap();
12584         var hasReadNonFileDiagnostics = false;
12585         return {
12586             add: add,
12587             lookup: lookup,
12588             getGlobalDiagnostics: getGlobalDiagnostics,
12589             getDiagnostics: getDiagnostics,
12590             reattachFileDiagnostics: reattachFileDiagnostics
12591         };
12592         function reattachFileDiagnostics(newFile) {
12593             ts.forEach(fileDiagnostics.get(newFile.fileName), function (diagnostic) { return diagnostic.file = newFile; });
12594         }
12595         function lookup(diagnostic) {
12596             var diagnostics;
12597             if (diagnostic.file) {
12598                 diagnostics = fileDiagnostics.get(diagnostic.file.fileName);
12599             }
12600             else {
12601                 diagnostics = nonFileDiagnostics;
12602             }
12603             if (!diagnostics) {
12604                 return undefined;
12605             }
12606             var result = ts.binarySearch(diagnostics, diagnostic, ts.identity, compareDiagnosticsSkipRelatedInformation);
12607             if (result >= 0) {
12608                 return diagnostics[result];
12609             }
12610             return undefined;
12611         }
12612         function add(diagnostic) {
12613             var diagnostics;
12614             if (diagnostic.file) {
12615                 diagnostics = fileDiagnostics.get(diagnostic.file.fileName);
12616                 if (!diagnostics) {
12617                     diagnostics = [];
12618                     fileDiagnostics.set(diagnostic.file.fileName, diagnostics);
12619                     ts.insertSorted(filesWithDiagnostics, diagnostic.file.fileName, ts.compareStringsCaseSensitive);
12620                 }
12621             }
12622             else {
12623                 if (hasReadNonFileDiagnostics) {
12624                     hasReadNonFileDiagnostics = false;
12625                     nonFileDiagnostics = nonFileDiagnostics.slice();
12626                 }
12627                 diagnostics = nonFileDiagnostics;
12628             }
12629             ts.insertSorted(diagnostics, diagnostic, compareDiagnostics);
12630         }
12631         function getGlobalDiagnostics() {
12632             hasReadNonFileDiagnostics = true;
12633             return nonFileDiagnostics;
12634         }
12635         function getDiagnostics(fileName) {
12636             if (fileName) {
12637                 return fileDiagnostics.get(fileName) || [];
12638             }
12639             var fileDiags = ts.flatMapToMutable(filesWithDiagnostics, function (f) { return fileDiagnostics.get(f); });
12640             if (!nonFileDiagnostics.length) {
12641                 return fileDiags;
12642             }
12643             fileDiags.unshift.apply(fileDiags, nonFileDiagnostics);
12644             return fileDiags;
12645         }
12646     }
12647     ts.createDiagnosticCollection = createDiagnosticCollection;
12648     var templateSubstitutionRegExp = /\$\{/g;
12649     function escapeTemplateSubstitution(str) {
12650         return str.replace(templateSubstitutionRegExp, "\\${");
12651     }
12652     function hasInvalidEscape(template) {
12653         return template && !!(ts.isNoSubstitutionTemplateLiteral(template)
12654             ? template.templateFlags
12655             : (template.head.templateFlags || ts.some(template.templateSpans, function (span) { return !!span.literal.templateFlags; })));
12656     }
12657     ts.hasInvalidEscape = hasInvalidEscape;
12658     var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
12659     var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
12660     var backtickQuoteEscapedCharsRegExp = /[\\`]/g;
12661     var escapedCharsMap = ts.createMapFromTemplate({
12662         "\t": "\\t",
12663         "\v": "\\v",
12664         "\f": "\\f",
12665         "\b": "\\b",
12666         "\r": "\\r",
12667         "\n": "\\n",
12668         "\\": "\\\\",
12669         "\"": "\\\"",
12670         "\'": "\\\'",
12671         "\`": "\\\`",
12672         "\u2028": "\\u2028",
12673         "\u2029": "\\u2029",
12674         "\u0085": "\\u0085"
12675     });
12676     function encodeUtf16EscapeSequence(charCode) {
12677         var hexCharCode = charCode.toString(16).toUpperCase();
12678         var paddedHexCode = ("0000" + hexCharCode).slice(-4);
12679         return "\\u" + paddedHexCode;
12680     }
12681     function getReplacement(c, offset, input) {
12682         if (c.charCodeAt(0) === 0) {
12683             var lookAhead = input.charCodeAt(offset + c.length);
12684             if (lookAhead >= 48 && lookAhead <= 57) {
12685                 return "\\x00";
12686             }
12687             return "\\0";
12688         }
12689         return escapedCharsMap.get(c) || encodeUtf16EscapeSequence(c.charCodeAt(0));
12690     }
12691     function escapeString(s, quoteChar) {
12692         var escapedCharsRegExp = quoteChar === 96 ? backtickQuoteEscapedCharsRegExp :
12693             quoteChar === 39 ? singleQuoteEscapedCharsRegExp :
12694                 doubleQuoteEscapedCharsRegExp;
12695         return s.replace(escapedCharsRegExp, getReplacement);
12696     }
12697     ts.escapeString = escapeString;
12698     var nonAsciiCharacters = /[^\u0000-\u007F]/g;
12699     function escapeNonAsciiString(s, quoteChar) {
12700         s = escapeString(s, quoteChar);
12701         return nonAsciiCharacters.test(s) ?
12702             s.replace(nonAsciiCharacters, function (c) { return encodeUtf16EscapeSequence(c.charCodeAt(0)); }) :
12703             s;
12704     }
12705     ts.escapeNonAsciiString = escapeNonAsciiString;
12706     var jsxDoubleQuoteEscapedCharsRegExp = /[\"\u0000-\u001f\u2028\u2029\u0085]/g;
12707     var jsxSingleQuoteEscapedCharsRegExp = /[\'\u0000-\u001f\u2028\u2029\u0085]/g;
12708     var jsxEscapedCharsMap = ts.createMapFromTemplate({
12709         "\"": "&quot;",
12710         "\'": "&apos;"
12711     });
12712     function encodeJsxCharacterEntity(charCode) {
12713         var hexCharCode = charCode.toString(16).toUpperCase();
12714         return "&#x" + hexCharCode + ";";
12715     }
12716     function getJsxAttributeStringReplacement(c) {
12717         if (c.charCodeAt(0) === 0) {
12718             return "&#0;";
12719         }
12720         return jsxEscapedCharsMap.get(c) || encodeJsxCharacterEntity(c.charCodeAt(0));
12721     }
12722     function escapeJsxAttributeString(s, quoteChar) {
12723         var escapedCharsRegExp = quoteChar === 39 ? jsxSingleQuoteEscapedCharsRegExp :
12724             jsxDoubleQuoteEscapedCharsRegExp;
12725         return s.replace(escapedCharsRegExp, getJsxAttributeStringReplacement);
12726     }
12727     ts.escapeJsxAttributeString = escapeJsxAttributeString;
12728     function stripQuotes(name) {
12729         var length = name.length;
12730         if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && isQuoteOrBacktick(name.charCodeAt(0))) {
12731             return name.substring(1, length - 1);
12732         }
12733         return name;
12734     }
12735     ts.stripQuotes = stripQuotes;
12736     function isQuoteOrBacktick(charCode) {
12737         return charCode === 39 ||
12738             charCode === 34 ||
12739             charCode === 96;
12740     }
12741     function isIntrinsicJsxName(name) {
12742         var ch = name.charCodeAt(0);
12743         return (ch >= 97 && ch <= 122) || ts.stringContains(name, "-");
12744     }
12745     ts.isIntrinsicJsxName = isIntrinsicJsxName;
12746     var indentStrings = ["", "    "];
12747     function getIndentString(level) {
12748         if (indentStrings[level] === undefined) {
12749             indentStrings[level] = getIndentString(level - 1) + indentStrings[1];
12750         }
12751         return indentStrings[level];
12752     }
12753     ts.getIndentString = getIndentString;
12754     function getIndentSize() {
12755         return indentStrings[1].length;
12756     }
12757     ts.getIndentSize = getIndentSize;
12758     function createTextWriter(newLine) {
12759         var output;
12760         var indent;
12761         var lineStart;
12762         var lineCount;
12763         var linePos;
12764         var hasTrailingComment = false;
12765         function updateLineCountAndPosFor(s) {
12766             var lineStartsOfS = ts.computeLineStarts(s);
12767             if (lineStartsOfS.length > 1) {
12768                 lineCount = lineCount + lineStartsOfS.length - 1;
12769                 linePos = output.length - s.length + ts.last(lineStartsOfS);
12770                 lineStart = (linePos - output.length) === 0;
12771             }
12772             else {
12773                 lineStart = false;
12774             }
12775         }
12776         function writeText(s) {
12777             if (s && s.length) {
12778                 if (lineStart) {
12779                     s = getIndentString(indent) + s;
12780                     lineStart = false;
12781                 }
12782                 output += s;
12783                 updateLineCountAndPosFor(s);
12784             }
12785         }
12786         function write(s) {
12787             if (s)
12788                 hasTrailingComment = false;
12789             writeText(s);
12790         }
12791         function writeComment(s) {
12792             if (s)
12793                 hasTrailingComment = true;
12794             writeText(s);
12795         }
12796         function reset() {
12797             output = "";
12798             indent = 0;
12799             lineStart = true;
12800             lineCount = 0;
12801             linePos = 0;
12802             hasTrailingComment = false;
12803         }
12804         function rawWrite(s) {
12805             if (s !== undefined) {
12806                 output += s;
12807                 updateLineCountAndPosFor(s);
12808                 hasTrailingComment = false;
12809             }
12810         }
12811         function writeLiteral(s) {
12812             if (s && s.length) {
12813                 write(s);
12814             }
12815         }
12816         function writeLine(force) {
12817             if (!lineStart || force) {
12818                 output += newLine;
12819                 lineCount++;
12820                 linePos = output.length;
12821                 lineStart = true;
12822                 hasTrailingComment = false;
12823             }
12824         }
12825         function getTextPosWithWriteLine() {
12826             return lineStart ? output.length : (output.length + newLine.length);
12827         }
12828         reset();
12829         return {
12830             write: write,
12831             rawWrite: rawWrite,
12832             writeLiteral: writeLiteral,
12833             writeLine: writeLine,
12834             increaseIndent: function () { indent++; },
12835             decreaseIndent: function () { indent--; },
12836             getIndent: function () { return indent; },
12837             getTextPos: function () { return output.length; },
12838             getLine: function () { return lineCount; },
12839             getColumn: function () { return lineStart ? indent * getIndentSize() : output.length - linePos; },
12840             getText: function () { return output; },
12841             isAtStartOfLine: function () { return lineStart; },
12842             hasTrailingComment: function () { return hasTrailingComment; },
12843             hasTrailingWhitespace: function () { return !!output.length && ts.isWhiteSpaceLike(output.charCodeAt(output.length - 1)); },
12844             clear: reset,
12845             reportInaccessibleThisError: ts.noop,
12846             reportPrivateInBaseOfClassExpression: ts.noop,
12847             reportInaccessibleUniqueSymbolError: ts.noop,
12848             trackSymbol: ts.noop,
12849             writeKeyword: write,
12850             writeOperator: write,
12851             writeParameter: write,
12852             writeProperty: write,
12853             writePunctuation: write,
12854             writeSpace: write,
12855             writeStringLiteral: write,
12856             writeSymbol: function (s, _) { return write(s); },
12857             writeTrailingSemicolon: write,
12858             writeComment: writeComment,
12859             getTextPosWithWriteLine: getTextPosWithWriteLine
12860         };
12861     }
12862     ts.createTextWriter = createTextWriter;
12863     function getTrailingSemicolonDeferringWriter(writer) {
12864         var pendingTrailingSemicolon = false;
12865         function commitPendingTrailingSemicolon() {
12866             if (pendingTrailingSemicolon) {
12867                 writer.writeTrailingSemicolon(";");
12868                 pendingTrailingSemicolon = false;
12869             }
12870         }
12871         return __assign(__assign({}, writer), { writeTrailingSemicolon: function () {
12872                 pendingTrailingSemicolon = true;
12873             },
12874             writeLiteral: function (s) {
12875                 commitPendingTrailingSemicolon();
12876                 writer.writeLiteral(s);
12877             },
12878             writeStringLiteral: function (s) {
12879                 commitPendingTrailingSemicolon();
12880                 writer.writeStringLiteral(s);
12881             },
12882             writeSymbol: function (s, sym) {
12883                 commitPendingTrailingSemicolon();
12884                 writer.writeSymbol(s, sym);
12885             },
12886             writePunctuation: function (s) {
12887                 commitPendingTrailingSemicolon();
12888                 writer.writePunctuation(s);
12889             },
12890             writeKeyword: function (s) {
12891                 commitPendingTrailingSemicolon();
12892                 writer.writeKeyword(s);
12893             },
12894             writeOperator: function (s) {
12895                 commitPendingTrailingSemicolon();
12896                 writer.writeOperator(s);
12897             },
12898             writeParameter: function (s) {
12899                 commitPendingTrailingSemicolon();
12900                 writer.writeParameter(s);
12901             },
12902             writeSpace: function (s) {
12903                 commitPendingTrailingSemicolon();
12904                 writer.writeSpace(s);
12905             },
12906             writeProperty: function (s) {
12907                 commitPendingTrailingSemicolon();
12908                 writer.writeProperty(s);
12909             },
12910             writeComment: function (s) {
12911                 commitPendingTrailingSemicolon();
12912                 writer.writeComment(s);
12913             },
12914             writeLine: function () {
12915                 commitPendingTrailingSemicolon();
12916                 writer.writeLine();
12917             },
12918             increaseIndent: function () {
12919                 commitPendingTrailingSemicolon();
12920                 writer.increaseIndent();
12921             },
12922             decreaseIndent: function () {
12923                 commitPendingTrailingSemicolon();
12924                 writer.decreaseIndent();
12925             } });
12926     }
12927     ts.getTrailingSemicolonDeferringWriter = getTrailingSemicolonDeferringWriter;
12928     function hostUsesCaseSensitiveFileNames(host) {
12929         return host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : false;
12930     }
12931     ts.hostUsesCaseSensitiveFileNames = hostUsesCaseSensitiveFileNames;
12932     function hostGetCanonicalFileName(host) {
12933         return ts.createGetCanonicalFileName(hostUsesCaseSensitiveFileNames(host));
12934     }
12935     ts.hostGetCanonicalFileName = hostGetCanonicalFileName;
12936     function getResolvedExternalModuleName(host, file, referenceFile) {
12937         return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName);
12938     }
12939     ts.getResolvedExternalModuleName = getResolvedExternalModuleName;
12940     function getExternalModuleNameFromDeclaration(host, resolver, declaration) {
12941         var file = resolver.getExternalModuleFileFromDeclaration(declaration);
12942         if (!file || file.isDeclarationFile) {
12943             return undefined;
12944         }
12945         return getResolvedExternalModuleName(host, file);
12946     }
12947     ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration;
12948     function getExternalModuleNameFromPath(host, fileName, referencePath) {
12949         var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); };
12950         var dir = ts.toPath(referencePath ? ts.getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName);
12951         var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
12952         var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, false);
12953         var extensionless = removeFileExtension(relativePath);
12954         return referencePath ? ts.ensurePathIsNonModuleName(extensionless) : extensionless;
12955     }
12956     ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath;
12957     function getOwnEmitOutputFilePath(fileName, host, extension) {
12958         var compilerOptions = host.getCompilerOptions();
12959         var emitOutputFilePathWithoutExtension;
12960         if (compilerOptions.outDir) {
12961             emitOutputFilePathWithoutExtension = removeFileExtension(getSourceFilePathInNewDir(fileName, host, compilerOptions.outDir));
12962         }
12963         else {
12964             emitOutputFilePathWithoutExtension = removeFileExtension(fileName);
12965         }
12966         return emitOutputFilePathWithoutExtension + extension;
12967     }
12968     ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath;
12969     function getDeclarationEmitOutputFilePath(fileName, host) {
12970         return getDeclarationEmitOutputFilePathWorker(fileName, host.getCompilerOptions(), host.getCurrentDirectory(), host.getCommonSourceDirectory(), function (f) { return host.getCanonicalFileName(f); });
12971     }
12972     ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath;
12973     function getDeclarationEmitOutputFilePathWorker(fileName, options, currentDirectory, commonSourceDirectory, getCanonicalFileName) {
12974         var outputDir = options.declarationDir || options.outDir;
12975         var path = outputDir
12976             ? getSourceFilePathInNewDirWorker(fileName, outputDir, currentDirectory, commonSourceDirectory, getCanonicalFileName)
12977             : fileName;
12978         return removeFileExtension(path) + ".d.ts";
12979     }
12980     ts.getDeclarationEmitOutputFilePathWorker = getDeclarationEmitOutputFilePathWorker;
12981     function getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit) {
12982         var options = host.getCompilerOptions();
12983         if (options.outFile || options.out) {
12984             var moduleKind = getEmitModuleKind(options);
12985             var moduleEmitEnabled_1 = options.emitDeclarationOnly || moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System;
12986             return ts.filter(host.getSourceFiles(), function (sourceFile) {
12987                 return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) &&
12988                     sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit);
12989             });
12990         }
12991         else {
12992             var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile];
12993             return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit); });
12994         }
12995     }
12996     ts.getSourceFilesToEmit = getSourceFilesToEmit;
12997     function sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit) {
12998         var options = host.getCompilerOptions();
12999         return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) &&
13000             !sourceFile.isDeclarationFile &&
13001             !host.isSourceFileFromExternalLibrary(sourceFile) &&
13002             !(isJsonSourceFile(sourceFile) && host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) &&
13003             (forceDtsEmit || !host.isSourceOfProjectReferenceRedirect(sourceFile.fileName));
13004     }
13005     ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted;
13006     function getSourceFilePathInNewDir(fileName, host, newDirPath) {
13007         return getSourceFilePathInNewDirWorker(fileName, newDirPath, host.getCurrentDirectory(), host.getCommonSourceDirectory(), function (f) { return host.getCanonicalFileName(f); });
13008     }
13009     ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir;
13010     function getSourceFilePathInNewDirWorker(fileName, newDirPath, currentDirectory, commonSourceDirectory, getCanonicalFileName) {
13011         var sourceFilePath = ts.getNormalizedAbsolutePath(fileName, currentDirectory);
13012         var isSourceFileInCommonSourceDirectory = getCanonicalFileName(sourceFilePath).indexOf(getCanonicalFileName(commonSourceDirectory)) === 0;
13013         sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath;
13014         return ts.combinePaths(newDirPath, sourceFilePath);
13015     }
13016     ts.getSourceFilePathInNewDirWorker = getSourceFilePathInNewDirWorker;
13017     function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) {
13018         host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) {
13019             diagnostics.add(createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage));
13020         }, sourceFiles);
13021     }
13022     ts.writeFile = writeFile;
13023     function ensureDirectoriesExist(directoryPath, createDirectory, directoryExists) {
13024         if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) {
13025             var parentDirectory = ts.getDirectoryPath(directoryPath);
13026             ensureDirectoriesExist(parentDirectory, createDirectory, directoryExists);
13027             createDirectory(directoryPath);
13028         }
13029     }
13030     function writeFileEnsuringDirectories(path, data, writeByteOrderMark, writeFile, createDirectory, directoryExists) {
13031         try {
13032             writeFile(path, data, writeByteOrderMark);
13033         }
13034         catch (_a) {
13035             ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(path)), createDirectory, directoryExists);
13036             writeFile(path, data, writeByteOrderMark);
13037         }
13038     }
13039     ts.writeFileEnsuringDirectories = writeFileEnsuringDirectories;
13040     function getLineOfLocalPosition(sourceFile, pos) {
13041         var lineStarts = ts.getLineStarts(sourceFile);
13042         return ts.computeLineOfPosition(lineStarts, pos);
13043     }
13044     ts.getLineOfLocalPosition = getLineOfLocalPosition;
13045     function getLineOfLocalPositionFromLineMap(lineMap, pos) {
13046         return ts.computeLineOfPosition(lineMap, pos);
13047     }
13048     ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap;
13049     function getFirstConstructorWithBody(node) {
13050         return ts.find(node.members, function (member) { return ts.isConstructorDeclaration(member) && nodeIsPresent(member.body); });
13051     }
13052     ts.getFirstConstructorWithBody = getFirstConstructorWithBody;
13053     function getSetAccessorValueParameter(accessor) {
13054         if (accessor && accessor.parameters.length > 0) {
13055             var hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]);
13056             return accessor.parameters[hasThis ? 1 : 0];
13057         }
13058     }
13059     ts.getSetAccessorValueParameter = getSetAccessorValueParameter;
13060     function getSetAccessorTypeAnnotationNode(accessor) {
13061         var parameter = getSetAccessorValueParameter(accessor);
13062         return parameter && parameter.type;
13063     }
13064     ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode;
13065     function getThisParameter(signature) {
13066         if (signature.parameters.length && !ts.isJSDocSignature(signature)) {
13067             var thisParameter = signature.parameters[0];
13068             if (parameterIsThisKeyword(thisParameter)) {
13069                 return thisParameter;
13070             }
13071         }
13072     }
13073     ts.getThisParameter = getThisParameter;
13074     function parameterIsThisKeyword(parameter) {
13075         return isThisIdentifier(parameter.name);
13076     }
13077     ts.parameterIsThisKeyword = parameterIsThisKeyword;
13078     function isThisIdentifier(node) {
13079         return !!node && node.kind === 75 && identifierIsThisKeyword(node);
13080     }
13081     ts.isThisIdentifier = isThisIdentifier;
13082     function identifierIsThisKeyword(id) {
13083         return id.originalKeywordKind === 104;
13084     }
13085     ts.identifierIsThisKeyword = identifierIsThisKeyword;
13086     function getAllAccessorDeclarations(declarations, accessor) {
13087         var firstAccessor;
13088         var secondAccessor;
13089         var getAccessor;
13090         var setAccessor;
13091         if (hasDynamicName(accessor)) {
13092             firstAccessor = accessor;
13093             if (accessor.kind === 163) {
13094                 getAccessor = accessor;
13095             }
13096             else if (accessor.kind === 164) {
13097                 setAccessor = accessor;
13098             }
13099             else {
13100                 ts.Debug.fail("Accessor has wrong kind");
13101             }
13102         }
13103         else {
13104             ts.forEach(declarations, function (member) {
13105                 if (ts.isAccessor(member)
13106                     && hasModifier(member, 32) === hasModifier(accessor, 32)) {
13107                     var memberName = getPropertyNameForPropertyNameNode(member.name);
13108                     var accessorName = getPropertyNameForPropertyNameNode(accessor.name);
13109                     if (memberName === accessorName) {
13110                         if (!firstAccessor) {
13111                             firstAccessor = member;
13112                         }
13113                         else if (!secondAccessor) {
13114                             secondAccessor = member;
13115                         }
13116                         if (member.kind === 163 && !getAccessor) {
13117                             getAccessor = member;
13118                         }
13119                         if (member.kind === 164 && !setAccessor) {
13120                             setAccessor = member;
13121                         }
13122                     }
13123                 }
13124             });
13125         }
13126         return {
13127             firstAccessor: firstAccessor,
13128             secondAccessor: secondAccessor,
13129             getAccessor: getAccessor,
13130             setAccessor: setAccessor
13131         };
13132     }
13133     ts.getAllAccessorDeclarations = getAllAccessorDeclarations;
13134     function getEffectiveTypeAnnotationNode(node) {
13135         if (!isInJSFile(node) && ts.isFunctionDeclaration(node))
13136             return undefined;
13137         var type = node.type;
13138         if (type || !isInJSFile(node))
13139             return type;
13140         return ts.isJSDocPropertyLikeTag(node) ? node.typeExpression && node.typeExpression.type : ts.getJSDocType(node);
13141     }
13142     ts.getEffectiveTypeAnnotationNode = getEffectiveTypeAnnotationNode;
13143     function getTypeAnnotationNode(node) {
13144         return node.type;
13145     }
13146     ts.getTypeAnnotationNode = getTypeAnnotationNode;
13147     function getEffectiveReturnTypeNode(node) {
13148         return ts.isJSDocSignature(node) ?
13149             node.type && node.type.typeExpression && node.type.typeExpression.type :
13150             node.type || (isInJSFile(node) ? ts.getJSDocReturnType(node) : undefined);
13151     }
13152     ts.getEffectiveReturnTypeNode = getEffectiveReturnTypeNode;
13153     function getJSDocTypeParameterDeclarations(node) {
13154         return ts.flatMap(ts.getJSDocTags(node), function (tag) { return isNonTypeAliasTemplate(tag) ? tag.typeParameters : undefined; });
13155     }
13156     ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations;
13157     function isNonTypeAliasTemplate(tag) {
13158         return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 303 && tag.parent.tags.some(isJSDocTypeAlias));
13159     }
13160     function getEffectiveSetAccessorTypeAnnotationNode(node) {
13161         var parameter = getSetAccessorValueParameter(node);
13162         return parameter && getEffectiveTypeAnnotationNode(parameter);
13163     }
13164     ts.getEffectiveSetAccessorTypeAnnotationNode = getEffectiveSetAccessorTypeAnnotationNode;
13165     function emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments) {
13166         emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, node.pos, leadingComments);
13167     }
13168     ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments;
13169     function emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, pos, leadingComments) {
13170         if (leadingComments && leadingComments.length && pos !== leadingComments[0].pos &&
13171             getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, leadingComments[0].pos)) {
13172             writer.writeLine();
13173         }
13174     }
13175     ts.emitNewLineBeforeLeadingCommentsOfPosition = emitNewLineBeforeLeadingCommentsOfPosition;
13176     function emitNewLineBeforeLeadingCommentOfPosition(lineMap, writer, pos, commentPos) {
13177         if (pos !== commentPos &&
13178             getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, commentPos)) {
13179             writer.writeLine();
13180         }
13181     }
13182     ts.emitNewLineBeforeLeadingCommentOfPosition = emitNewLineBeforeLeadingCommentOfPosition;
13183     function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) {
13184         if (comments && comments.length > 0) {
13185             if (leadingSeparator) {
13186                 writer.writeSpace(" ");
13187             }
13188             var emitInterveningSeparator = false;
13189             for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) {
13190                 var comment = comments_1[_i];
13191                 if (emitInterveningSeparator) {
13192                     writer.writeSpace(" ");
13193                     emitInterveningSeparator = false;
13194                 }
13195                 writeComment(text, lineMap, writer, comment.pos, comment.end, newLine);
13196                 if (comment.hasTrailingNewLine) {
13197                     writer.writeLine();
13198                 }
13199                 else {
13200                     emitInterveningSeparator = true;
13201                 }
13202             }
13203             if (emitInterveningSeparator && trailingSeparator) {
13204                 writer.writeSpace(" ");
13205             }
13206         }
13207     }
13208     ts.emitComments = emitComments;
13209     function emitDetachedComments(text, lineMap, writer, writeComment, node, newLine, removeComments) {
13210         var leadingComments;
13211         var currentDetachedCommentInfo;
13212         if (removeComments) {
13213             if (node.pos === 0) {
13214                 leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedCommentLocal);
13215             }
13216         }
13217         else {
13218             leadingComments = ts.getLeadingCommentRanges(text, node.pos);
13219         }
13220         if (leadingComments) {
13221             var detachedComments = [];
13222             var lastComment = void 0;
13223             for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) {
13224                 var comment = leadingComments_1[_i];
13225                 if (lastComment) {
13226                     var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastComment.end);
13227                     var commentLine = getLineOfLocalPositionFromLineMap(lineMap, comment.pos);
13228                     if (commentLine >= lastCommentLine + 2) {
13229                         break;
13230                     }
13231                 }
13232                 detachedComments.push(comment);
13233                 lastComment = comment;
13234             }
13235             if (detachedComments.length) {
13236                 var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.last(detachedComments).end);
13237                 var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos));
13238                 if (nodeLine >= lastCommentLine + 2) {
13239                     emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments);
13240                     emitComments(text, lineMap, writer, detachedComments, false, true, newLine, writeComment);
13241                     currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.last(detachedComments).end };
13242                 }
13243             }
13244         }
13245         return currentDetachedCommentInfo;
13246         function isPinnedCommentLocal(comment) {
13247             return isPinnedComment(text, comment.pos);
13248         }
13249     }
13250     ts.emitDetachedComments = emitDetachedComments;
13251     function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) {
13252         if (text.charCodeAt(commentPos + 1) === 42) {
13253             var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos);
13254             var lineCount = lineMap.length;
13255             var firstCommentLineIndent = void 0;
13256             for (var pos = commentPos, currentLine = firstCommentLineAndCharacter.line; pos < commentEnd; currentLine++) {
13257                 var nextLineStart = (currentLine + 1) === lineCount
13258                     ? text.length + 1
13259                     : lineMap[currentLine + 1];
13260                 if (pos !== commentPos) {
13261                     if (firstCommentLineIndent === undefined) {
13262                         firstCommentLineIndent = calculateIndent(text, lineMap[firstCommentLineAndCharacter.line], commentPos);
13263                     }
13264                     var currentWriterIndentSpacing = writer.getIndent() * getIndentSize();
13265                     var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(text, pos, nextLineStart);
13266                     if (spacesToEmit > 0) {
13267                         var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize();
13268                         var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize());
13269                         writer.rawWrite(indentSizeSpaceString);
13270                         while (numberOfSingleSpacesToEmit) {
13271                             writer.rawWrite(" ");
13272                             numberOfSingleSpacesToEmit--;
13273                         }
13274                     }
13275                     else {
13276                         writer.rawWrite("");
13277                     }
13278                 }
13279                 writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart);
13280                 pos = nextLineStart;
13281             }
13282         }
13283         else {
13284             writer.writeComment(text.substring(commentPos, commentEnd));
13285         }
13286     }
13287     ts.writeCommentRange = writeCommentRange;
13288     function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) {
13289         var end = Math.min(commentEnd, nextLineStart - 1);
13290         var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, "");
13291         if (currentLineText) {
13292             writer.writeComment(currentLineText);
13293             if (end !== commentEnd) {
13294                 writer.writeLine();
13295             }
13296         }
13297         else {
13298             writer.rawWrite(newLine);
13299         }
13300     }
13301     function calculateIndent(text, pos, end) {
13302         var currentLineIndent = 0;
13303         for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) {
13304             if (text.charCodeAt(pos) === 9) {
13305                 currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize());
13306             }
13307             else {
13308                 currentLineIndent++;
13309             }
13310         }
13311         return currentLineIndent;
13312     }
13313     function hasModifiers(node) {
13314         return getModifierFlags(node) !== 0;
13315     }
13316     ts.hasModifiers = hasModifiers;
13317     function hasModifier(node, flags) {
13318         return !!getSelectedModifierFlags(node, flags);
13319     }
13320     ts.hasModifier = hasModifier;
13321     function hasStaticModifier(node) {
13322         return hasModifier(node, 32);
13323     }
13324     ts.hasStaticModifier = hasStaticModifier;
13325     function hasReadonlyModifier(node) {
13326         return hasModifier(node, 64);
13327     }
13328     ts.hasReadonlyModifier = hasReadonlyModifier;
13329     function getSelectedModifierFlags(node, flags) {
13330         return getModifierFlags(node) & flags;
13331     }
13332     ts.getSelectedModifierFlags = getSelectedModifierFlags;
13333     function getModifierFlags(node) {
13334         if (node.kind >= 0 && node.kind <= 152) {
13335             return 0;
13336         }
13337         if (node.modifierFlagsCache & 536870912) {
13338             return node.modifierFlagsCache & ~536870912;
13339         }
13340         var flags = getModifierFlagsNoCache(node);
13341         node.modifierFlagsCache = flags | 536870912;
13342         return flags;
13343     }
13344     ts.getModifierFlags = getModifierFlags;
13345     function getModifierFlagsNoCache(node) {
13346         var flags = 0;
13347         if (node.modifiers) {
13348             for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
13349                 var modifier = _a[_i];
13350                 flags |= modifierToFlag(modifier.kind);
13351             }
13352         }
13353         if (isInJSFile(node) && !!node.parent) {
13354             var tags = (ts.getJSDocPublicTag(node) ? 4 : 0)
13355                 | (ts.getJSDocPrivateTag(node) ? 8 : 0)
13356                 | (ts.getJSDocProtectedTag(node) ? 16 : 0)
13357                 | (ts.getJSDocReadonlyTag(node) ? 64 : 0);
13358             flags |= tags;
13359         }
13360         if (node.flags & 4 || (node.kind === 75 && node.isInJSDocNamespace)) {
13361             flags |= 1;
13362         }
13363         return flags;
13364     }
13365     ts.getModifierFlagsNoCache = getModifierFlagsNoCache;
13366     function modifierToFlag(token) {
13367         switch (token) {
13368             case 120: return 32;
13369             case 119: return 4;
13370             case 118: return 16;
13371             case 117: return 8;
13372             case 122: return 128;
13373             case 89: return 1;
13374             case 130: return 2;
13375             case 81: return 2048;
13376             case 84: return 512;
13377             case 126: return 256;
13378             case 138: return 64;
13379         }
13380         return 0;
13381     }
13382     ts.modifierToFlag = modifierToFlag;
13383     function isLogicalOperator(token) {
13384         return token === 56
13385             || token === 55
13386             || token === 53;
13387     }
13388     ts.isLogicalOperator = isLogicalOperator;
13389     function isAssignmentOperator(token) {
13390         return token >= 62 && token <= 74;
13391     }
13392     ts.isAssignmentOperator = isAssignmentOperator;
13393     function tryGetClassExtendingExpressionWithTypeArguments(node) {
13394         var cls = tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node);
13395         return cls && !cls.isImplements ? cls.class : undefined;
13396     }
13397     ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments;
13398     function tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node) {
13399         return ts.isExpressionWithTypeArguments(node)
13400             && ts.isHeritageClause(node.parent)
13401             && ts.isClassLike(node.parent.parent)
13402             ? { class: node.parent.parent, isImplements: node.parent.token === 113 }
13403             : undefined;
13404     }
13405     ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments;
13406     function isAssignmentExpression(node, excludeCompoundAssignment) {
13407         return ts.isBinaryExpression(node)
13408             && (excludeCompoundAssignment
13409                 ? node.operatorToken.kind === 62
13410                 : isAssignmentOperator(node.operatorToken.kind))
13411             && ts.isLeftHandSideExpression(node.left);
13412     }
13413     ts.isAssignmentExpression = isAssignmentExpression;
13414     function isDestructuringAssignment(node) {
13415         if (isAssignmentExpression(node, true)) {
13416             var kind = node.left.kind;
13417             return kind === 193
13418                 || kind === 192;
13419         }
13420         return false;
13421     }
13422     ts.isDestructuringAssignment = isDestructuringAssignment;
13423     function isExpressionWithTypeArgumentsInClassExtendsClause(node) {
13424         return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined;
13425     }
13426     ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause;
13427     function isEntityNameExpression(node) {
13428         return node.kind === 75 || isPropertyAccessEntityNameExpression(node);
13429     }
13430     ts.isEntityNameExpression = isEntityNameExpression;
13431     function getFirstIdentifier(node) {
13432         switch (node.kind) {
13433             case 75:
13434                 return node;
13435             case 153:
13436                 do {
13437                     node = node.left;
13438                 } while (node.kind !== 75);
13439                 return node;
13440             case 194:
13441                 do {
13442                     node = node.expression;
13443                 } while (node.kind !== 75);
13444                 return node;
13445         }
13446     }
13447     ts.getFirstIdentifier = getFirstIdentifier;
13448     function isDottedName(node) {
13449         return node.kind === 75 || node.kind === 104 || node.kind === 102 ||
13450             node.kind === 194 && isDottedName(node.expression) ||
13451             node.kind === 200 && isDottedName(node.expression);
13452     }
13453     ts.isDottedName = isDottedName;
13454     function isPropertyAccessEntityNameExpression(node) {
13455         return ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.name) && isEntityNameExpression(node.expression);
13456     }
13457     ts.isPropertyAccessEntityNameExpression = isPropertyAccessEntityNameExpression;
13458     function tryGetPropertyAccessOrIdentifierToString(expr) {
13459         if (ts.isPropertyAccessExpression(expr)) {
13460             var baseStr = tryGetPropertyAccessOrIdentifierToString(expr.expression);
13461             if (baseStr !== undefined) {
13462                 return baseStr + "." + expr.name;
13463             }
13464         }
13465         else if (ts.isIdentifier(expr)) {
13466             return ts.unescapeLeadingUnderscores(expr.escapedText);
13467         }
13468         return undefined;
13469     }
13470     ts.tryGetPropertyAccessOrIdentifierToString = tryGetPropertyAccessOrIdentifierToString;
13471     function isPrototypeAccess(node) {
13472         return isBindableStaticAccessExpression(node) && getElementOrPropertyAccessName(node) === "prototype";
13473     }
13474     ts.isPrototypeAccess = isPrototypeAccess;
13475     function isRightSideOfQualifiedNameOrPropertyAccess(node) {
13476         return (node.parent.kind === 153 && node.parent.right === node) ||
13477             (node.parent.kind === 194 && node.parent.name === node);
13478     }
13479     ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess;
13480     function isEmptyObjectLiteral(expression) {
13481         return expression.kind === 193 &&
13482             expression.properties.length === 0;
13483     }
13484     ts.isEmptyObjectLiteral = isEmptyObjectLiteral;
13485     function isEmptyArrayLiteral(expression) {
13486         return expression.kind === 192 &&
13487             expression.elements.length === 0;
13488     }
13489     ts.isEmptyArrayLiteral = isEmptyArrayLiteral;
13490     function getLocalSymbolForExportDefault(symbol) {
13491         return isExportDefaultSymbol(symbol) ? symbol.declarations[0].localSymbol : undefined;
13492     }
13493     ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault;
13494     function isExportDefaultSymbol(symbol) {
13495         return symbol && ts.length(symbol.declarations) > 0 && hasModifier(symbol.declarations[0], 512);
13496     }
13497     function tryExtractTSExtension(fileName) {
13498         return ts.find(ts.supportedTSExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); });
13499     }
13500     ts.tryExtractTSExtension = tryExtractTSExtension;
13501     function getExpandedCharCodes(input) {
13502         var output = [];
13503         var length = input.length;
13504         for (var i = 0; i < length; i++) {
13505             var charCode = input.charCodeAt(i);
13506             if (charCode < 0x80) {
13507                 output.push(charCode);
13508             }
13509             else if (charCode < 0x800) {
13510                 output.push((charCode >> 6) | 192);
13511                 output.push((charCode & 63) | 128);
13512             }
13513             else if (charCode < 0x10000) {
13514                 output.push((charCode >> 12) | 224);
13515                 output.push(((charCode >> 6) & 63) | 128);
13516                 output.push((charCode & 63) | 128);
13517             }
13518             else if (charCode < 0x20000) {
13519                 output.push((charCode >> 18) | 240);
13520                 output.push(((charCode >> 12) & 63) | 128);
13521                 output.push(((charCode >> 6) & 63) | 128);
13522                 output.push((charCode & 63) | 128);
13523             }
13524             else {
13525                 ts.Debug.assert(false, "Unexpected code point");
13526             }
13527         }
13528         return output;
13529     }
13530     var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
13531     function convertToBase64(input) {
13532         var result = "";
13533         var charCodes = getExpandedCharCodes(input);
13534         var i = 0;
13535         var length = charCodes.length;
13536         var byte1, byte2, byte3, byte4;
13537         while (i < length) {
13538             byte1 = charCodes[i] >> 2;
13539             byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4;
13540             byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6;
13541             byte4 = charCodes[i + 2] & 63;
13542             if (i + 1 >= length) {
13543                 byte3 = byte4 = 64;
13544             }
13545             else if (i + 2 >= length) {
13546                 byte4 = 64;
13547             }
13548             result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4);
13549             i += 3;
13550         }
13551         return result;
13552     }
13553     ts.convertToBase64 = convertToBase64;
13554     function getStringFromExpandedCharCodes(codes) {
13555         var output = "";
13556         var i = 0;
13557         var length = codes.length;
13558         while (i < length) {
13559             var charCode = codes[i];
13560             if (charCode < 0x80) {
13561                 output += String.fromCharCode(charCode);
13562                 i++;
13563             }
13564             else if ((charCode & 192) === 192) {
13565                 var value = charCode & 63;
13566                 i++;
13567                 var nextCode = codes[i];
13568                 while ((nextCode & 192) === 128) {
13569                     value = (value << 6) | (nextCode & 63);
13570                     i++;
13571                     nextCode = codes[i];
13572                 }
13573                 output += String.fromCharCode(value);
13574             }
13575             else {
13576                 output += String.fromCharCode(charCode);
13577                 i++;
13578             }
13579         }
13580         return output;
13581     }
13582     function base64encode(host, input) {
13583         if (host && host.base64encode) {
13584             return host.base64encode(input);
13585         }
13586         return convertToBase64(input);
13587     }
13588     ts.base64encode = base64encode;
13589     function base64decode(host, input) {
13590         if (host && host.base64decode) {
13591             return host.base64decode(input);
13592         }
13593         var length = input.length;
13594         var expandedCharCodes = [];
13595         var i = 0;
13596         while (i < length) {
13597             if (input.charCodeAt(i) === base64Digits.charCodeAt(64)) {
13598                 break;
13599             }
13600             var ch1 = base64Digits.indexOf(input[i]);
13601             var ch2 = base64Digits.indexOf(input[i + 1]);
13602             var ch3 = base64Digits.indexOf(input[i + 2]);
13603             var ch4 = base64Digits.indexOf(input[i + 3]);
13604             var code1 = ((ch1 & 63) << 2) | ((ch2 >> 4) & 3);
13605             var code2 = ((ch2 & 15) << 4) | ((ch3 >> 2) & 15);
13606             var code3 = ((ch3 & 3) << 6) | (ch4 & 63);
13607             if (code2 === 0 && ch3 !== 0) {
13608                 expandedCharCodes.push(code1);
13609             }
13610             else if (code3 === 0 && ch4 !== 0) {
13611                 expandedCharCodes.push(code1, code2);
13612             }
13613             else {
13614                 expandedCharCodes.push(code1, code2, code3);
13615             }
13616             i += 4;
13617         }
13618         return getStringFromExpandedCharCodes(expandedCharCodes);
13619     }
13620     ts.base64decode = base64decode;
13621     function readJson(path, host) {
13622         try {
13623             var jsonText = host.readFile(path);
13624             if (!jsonText)
13625                 return {};
13626             var result = ts.parseConfigFileTextToJson(path, jsonText);
13627             if (result.error) {
13628                 return {};
13629             }
13630             return result.config;
13631         }
13632         catch (e) {
13633             return {};
13634         }
13635     }
13636     ts.readJson = readJson;
13637     function directoryProbablyExists(directoryName, host) {
13638         return !host.directoryExists || host.directoryExists(directoryName);
13639     }
13640     ts.directoryProbablyExists = directoryProbablyExists;
13641     var carriageReturnLineFeed = "\r\n";
13642     var lineFeed = "\n";
13643     function getNewLineCharacter(options, getNewLine) {
13644         switch (options.newLine) {
13645             case 0:
13646                 return carriageReturnLineFeed;
13647             case 1:
13648                 return lineFeed;
13649         }
13650         return getNewLine ? getNewLine() : ts.sys ? ts.sys.newLine : carriageReturnLineFeed;
13651     }
13652     ts.getNewLineCharacter = getNewLineCharacter;
13653     function createRange(pos, end) {
13654         if (end === void 0) { end = pos; }
13655         ts.Debug.assert(end >= pos || end === -1);
13656         return { pos: pos, end: end };
13657     }
13658     ts.createRange = createRange;
13659     function moveRangeEnd(range, end) {
13660         return createRange(range.pos, end);
13661     }
13662     ts.moveRangeEnd = moveRangeEnd;
13663     function moveRangePos(range, pos) {
13664         return createRange(pos, range.end);
13665     }
13666     ts.moveRangePos = moveRangePos;
13667     function moveRangePastDecorators(node) {
13668         return node.decorators && node.decorators.length > 0
13669             ? moveRangePos(node, node.decorators.end)
13670             : node;
13671     }
13672     ts.moveRangePastDecorators = moveRangePastDecorators;
13673     function moveRangePastModifiers(node) {
13674         return node.modifiers && node.modifiers.length > 0
13675             ? moveRangePos(node, node.modifiers.end)
13676             : moveRangePastDecorators(node);
13677     }
13678     ts.moveRangePastModifiers = moveRangePastModifiers;
13679     function isCollapsedRange(range) {
13680         return range.pos === range.end;
13681     }
13682     ts.isCollapsedRange = isCollapsedRange;
13683     function createTokenRange(pos, token) {
13684         return createRange(pos, pos + ts.tokenToString(token).length);
13685     }
13686     ts.createTokenRange = createTokenRange;
13687     function rangeIsOnSingleLine(range, sourceFile) {
13688         return rangeStartIsOnSameLineAsRangeEnd(range, range, sourceFile);
13689     }
13690     ts.rangeIsOnSingleLine = rangeIsOnSingleLine;
13691     function rangeStartPositionsAreOnSameLine(range1, range2, sourceFile) {
13692         return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile, false), getStartPositionOfRange(range2, sourceFile, false), sourceFile);
13693     }
13694     ts.rangeStartPositionsAreOnSameLine = rangeStartPositionsAreOnSameLine;
13695     function rangeEndPositionsAreOnSameLine(range1, range2, sourceFile) {
13696         return positionsAreOnSameLine(range1.end, range2.end, sourceFile);
13697     }
13698     ts.rangeEndPositionsAreOnSameLine = rangeEndPositionsAreOnSameLine;
13699     function rangeStartIsOnSameLineAsRangeEnd(range1, range2, sourceFile) {
13700         return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile, false), range2.end, sourceFile);
13701     }
13702     ts.rangeStartIsOnSameLineAsRangeEnd = rangeStartIsOnSameLineAsRangeEnd;
13703     function rangeEndIsOnSameLineAsRangeStart(range1, range2, sourceFile) {
13704         return positionsAreOnSameLine(range1.end, getStartPositionOfRange(range2, sourceFile, false), sourceFile);
13705     }
13706     ts.rangeEndIsOnSameLineAsRangeStart = rangeEndIsOnSameLineAsRangeStart;
13707     function getLinesBetweenRangeEndAndRangeStart(range1, range2, sourceFile, includeSecondRangeComments) {
13708         var range2Start = getStartPositionOfRange(range2, sourceFile, includeSecondRangeComments);
13709         return ts.getLinesBetweenPositions(sourceFile, range1.end, range2Start);
13710     }
13711     ts.getLinesBetweenRangeEndAndRangeStart = getLinesBetweenRangeEndAndRangeStart;
13712     function getLinesBetweenRangeEndPositions(range1, range2, sourceFile) {
13713         return ts.getLinesBetweenPositions(sourceFile, range1.end, range2.end);
13714     }
13715     ts.getLinesBetweenRangeEndPositions = getLinesBetweenRangeEndPositions;
13716     function isNodeArrayMultiLine(list, sourceFile) {
13717         return !positionsAreOnSameLine(list.pos, list.end, sourceFile);
13718     }
13719     ts.isNodeArrayMultiLine = isNodeArrayMultiLine;
13720     function positionsAreOnSameLine(pos1, pos2, sourceFile) {
13721         return ts.getLinesBetweenPositions(sourceFile, pos1, pos2) === 0;
13722     }
13723     ts.positionsAreOnSameLine = positionsAreOnSameLine;
13724     function getStartPositionOfRange(range, sourceFile, includeComments) {
13725         return positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos, false, includeComments);
13726     }
13727     ts.getStartPositionOfRange = getStartPositionOfRange;
13728     function getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(pos, stopPos, sourceFile, includeComments) {
13729         var startPos = ts.skipTrivia(sourceFile.text, pos, false, includeComments);
13730         var prevPos = getPreviousNonWhitespacePosition(startPos, stopPos, sourceFile);
13731         return ts.getLinesBetweenPositions(sourceFile, prevPos !== null && prevPos !== void 0 ? prevPos : stopPos, startPos);
13732     }
13733     ts.getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter = getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter;
13734     function getLinesBetweenPositionAndNextNonWhitespaceCharacter(pos, stopPos, sourceFile, includeComments) {
13735         var nextPos = ts.skipTrivia(sourceFile.text, pos, false, includeComments);
13736         return ts.getLinesBetweenPositions(sourceFile, pos, Math.min(stopPos, nextPos));
13737     }
13738     ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter = getLinesBetweenPositionAndNextNonWhitespaceCharacter;
13739     function getPreviousNonWhitespacePosition(pos, stopPos, sourceFile) {
13740         if (stopPos === void 0) { stopPos = 0; }
13741         while (pos-- > stopPos) {
13742             if (!ts.isWhiteSpaceLike(sourceFile.text.charCodeAt(pos))) {
13743                 return pos;
13744             }
13745         }
13746     }
13747     function isDeclarationNameOfEnumOrNamespace(node) {
13748         var parseNode = ts.getParseTreeNode(node);
13749         if (parseNode) {
13750             switch (parseNode.parent.kind) {
13751                 case 248:
13752                 case 249:
13753                     return parseNode === parseNode.parent.name;
13754             }
13755         }
13756         return false;
13757     }
13758     ts.isDeclarationNameOfEnumOrNamespace = isDeclarationNameOfEnumOrNamespace;
13759     function getInitializedVariables(node) {
13760         return ts.filter(node.declarations, isInitializedVariable);
13761     }
13762     ts.getInitializedVariables = getInitializedVariables;
13763     function isInitializedVariable(node) {
13764         return node.initializer !== undefined;
13765     }
13766     function isWatchSet(options) {
13767         return options.watch && options.hasOwnProperty("watch");
13768     }
13769     ts.isWatchSet = isWatchSet;
13770     function closeFileWatcher(watcher) {
13771         watcher.close();
13772     }
13773     ts.closeFileWatcher = closeFileWatcher;
13774     function getCheckFlags(symbol) {
13775         return symbol.flags & 33554432 ? symbol.checkFlags : 0;
13776     }
13777     ts.getCheckFlags = getCheckFlags;
13778     function getDeclarationModifierFlagsFromSymbol(s) {
13779         if (s.valueDeclaration) {
13780             var flags = ts.getCombinedModifierFlags(s.valueDeclaration);
13781             return s.parent && s.parent.flags & 32 ? flags : flags & ~28;
13782         }
13783         if (getCheckFlags(s) & 6) {
13784             var checkFlags = s.checkFlags;
13785             var accessModifier = checkFlags & 1024 ? 8 :
13786                 checkFlags & 256 ? 4 :
13787                     16;
13788             var staticModifier = checkFlags & 2048 ? 32 : 0;
13789             return accessModifier | staticModifier;
13790         }
13791         if (s.flags & 4194304) {
13792             return 4 | 32;
13793         }
13794         return 0;
13795     }
13796     ts.getDeclarationModifierFlagsFromSymbol = getDeclarationModifierFlagsFromSymbol;
13797     function skipAlias(symbol, checker) {
13798         return symbol.flags & 2097152 ? checker.getAliasedSymbol(symbol) : symbol;
13799     }
13800     ts.skipAlias = skipAlias;
13801     function getCombinedLocalAndExportSymbolFlags(symbol) {
13802         return symbol.exportSymbol ? symbol.exportSymbol.flags | symbol.flags : symbol.flags;
13803     }
13804     ts.getCombinedLocalAndExportSymbolFlags = getCombinedLocalAndExportSymbolFlags;
13805     function isWriteOnlyAccess(node) {
13806         return accessKind(node) === 1;
13807     }
13808     ts.isWriteOnlyAccess = isWriteOnlyAccess;
13809     function isWriteAccess(node) {
13810         return accessKind(node) !== 0;
13811     }
13812     ts.isWriteAccess = isWriteAccess;
13813     function accessKind(node) {
13814         var parent = node.parent;
13815         if (!parent)
13816             return 0;
13817         switch (parent.kind) {
13818             case 200:
13819                 return accessKind(parent);
13820             case 208:
13821             case 207:
13822                 var operator = parent.operator;
13823                 return operator === 45 || operator === 46 ? writeOrReadWrite() : 0;
13824             case 209:
13825                 var _a = parent, left = _a.left, operatorToken = _a.operatorToken;
13826                 return left === node && isAssignmentOperator(operatorToken.kind) ?
13827                     operatorToken.kind === 62 ? 1 : writeOrReadWrite()
13828                     : 0;
13829             case 194:
13830                 return parent.name !== node ? 0 : accessKind(parent);
13831             case 281: {
13832                 var parentAccess = accessKind(parent.parent);
13833                 return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess;
13834             }
13835             case 282:
13836                 return node === parent.objectAssignmentInitializer ? 0 : accessKind(parent.parent);
13837             case 192:
13838                 return accessKind(parent);
13839             default:
13840                 return 0;
13841         }
13842         function writeOrReadWrite() {
13843             return parent.parent && skipParenthesesUp(parent.parent).kind === 226 ? 1 : 2;
13844         }
13845     }
13846     function reverseAccessKind(a) {
13847         switch (a) {
13848             case 0:
13849                 return 1;
13850             case 1:
13851                 return 0;
13852             case 2:
13853                 return 2;
13854             default:
13855                 return ts.Debug.assertNever(a);
13856         }
13857     }
13858     function compareDataObjects(dst, src) {
13859         if (!dst || !src || Object.keys(dst).length !== Object.keys(src).length) {
13860             return false;
13861         }
13862         for (var e in dst) {
13863             if (typeof dst[e] === "object") {
13864                 if (!compareDataObjects(dst[e], src[e])) {
13865                     return false;
13866                 }
13867             }
13868             else if (typeof dst[e] !== "function") {
13869                 if (dst[e] !== src[e]) {
13870                     return false;
13871                 }
13872             }
13873         }
13874         return true;
13875     }
13876     ts.compareDataObjects = compareDataObjects;
13877     function clearMap(map, onDeleteValue) {
13878         map.forEach(onDeleteValue);
13879         map.clear();
13880     }
13881     ts.clearMap = clearMap;
13882     function mutateMapSkippingNewValues(map, newMap, options) {
13883         var onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue;
13884         map.forEach(function (existingValue, key) {
13885             var valueInNewMap = newMap.get(key);
13886             if (valueInNewMap === undefined) {
13887                 map.delete(key);
13888                 onDeleteValue(existingValue, key);
13889             }
13890             else if (onExistingValue) {
13891                 onExistingValue(existingValue, valueInNewMap, key);
13892             }
13893         });
13894     }
13895     ts.mutateMapSkippingNewValues = mutateMapSkippingNewValues;
13896     function mutateMap(map, newMap, options) {
13897         mutateMapSkippingNewValues(map, newMap, options);
13898         var createNewValue = options.createNewValue;
13899         newMap.forEach(function (valueInNewMap, key) {
13900             if (!map.has(key)) {
13901                 map.set(key, createNewValue(key, valueInNewMap));
13902             }
13903         });
13904     }
13905     ts.mutateMap = mutateMap;
13906     function isAbstractConstructorType(type) {
13907         return !!(getObjectFlags(type) & 16) && !!type.symbol && isAbstractConstructorSymbol(type.symbol);
13908     }
13909     ts.isAbstractConstructorType = isAbstractConstructorType;
13910     function isAbstractConstructorSymbol(symbol) {
13911         if (symbol.flags & 32) {
13912             var declaration = getClassLikeDeclarationOfSymbol(symbol);
13913             return !!declaration && hasModifier(declaration, 128);
13914         }
13915         return false;
13916     }
13917     ts.isAbstractConstructorSymbol = isAbstractConstructorSymbol;
13918     function getClassLikeDeclarationOfSymbol(symbol) {
13919         return ts.find(symbol.declarations, ts.isClassLike);
13920     }
13921     ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol;
13922     function getObjectFlags(type) {
13923         return type.flags & 3899393 ? type.objectFlags : 0;
13924     }
13925     ts.getObjectFlags = getObjectFlags;
13926     function typeHasCallOrConstructSignatures(type, checker) {
13927         return checker.getSignaturesOfType(type, 0).length !== 0 || checker.getSignaturesOfType(type, 1).length !== 0;
13928     }
13929     ts.typeHasCallOrConstructSignatures = typeHasCallOrConstructSignatures;
13930     function forSomeAncestorDirectory(directory, callback) {
13931         return !!ts.forEachAncestorDirectory(directory, function (d) { return callback(d) ? true : undefined; });
13932     }
13933     ts.forSomeAncestorDirectory = forSomeAncestorDirectory;
13934     function isUMDExportSymbol(symbol) {
13935         return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]);
13936     }
13937     ts.isUMDExportSymbol = isUMDExportSymbol;
13938     function showModuleSpecifier(_a) {
13939         var moduleSpecifier = _a.moduleSpecifier;
13940         return ts.isStringLiteral(moduleSpecifier) ? moduleSpecifier.text : getTextOfNode(moduleSpecifier);
13941     }
13942     ts.showModuleSpecifier = showModuleSpecifier;
13943     function getLastChild(node) {
13944         var lastChild;
13945         ts.forEachChild(node, function (child) {
13946             if (nodeIsPresent(child))
13947                 lastChild = child;
13948         }, function (children) {
13949             for (var i = children.length - 1; i >= 0; i--) {
13950                 if (nodeIsPresent(children[i])) {
13951                     lastChild = children[i];
13952                     break;
13953                 }
13954             }
13955         });
13956         return lastChild;
13957     }
13958     ts.getLastChild = getLastChild;
13959     function addToSeen(seen, key, value) {
13960         if (value === void 0) { value = true; }
13961         key = String(key);
13962         if (seen.has(key)) {
13963             return false;
13964         }
13965         seen.set(key, value);
13966         return true;
13967     }
13968     ts.addToSeen = addToSeen;
13969     function isObjectTypeDeclaration(node) {
13970         return ts.isClassLike(node) || ts.isInterfaceDeclaration(node) || ts.isTypeLiteralNode(node);
13971     }
13972     ts.isObjectTypeDeclaration = isObjectTypeDeclaration;
13973     function isTypeNodeKind(kind) {
13974         return (kind >= 168 && kind <= 188)
13975             || kind === 125
13976             || kind === 148
13977             || kind === 140
13978             || kind === 151
13979             || kind === 141
13980             || kind === 128
13981             || kind === 143
13982             || kind === 144
13983             || kind === 104
13984             || kind === 110
13985             || kind === 146
13986             || kind === 100
13987             || kind === 137
13988             || kind === 216
13989             || kind === 295
13990             || kind === 296
13991             || kind === 297
13992             || kind === 298
13993             || kind === 299
13994             || kind === 300
13995             || kind === 301;
13996     }
13997     ts.isTypeNodeKind = isTypeNodeKind;
13998     function isAccessExpression(node) {
13999         return node.kind === 194 || node.kind === 195;
14000     }
14001     ts.isAccessExpression = isAccessExpression;
14002     function getNameOfAccessExpression(node) {
14003         if (node.kind === 194) {
14004             return node.name;
14005         }
14006         ts.Debug.assert(node.kind === 195);
14007         return node.argumentExpression;
14008     }
14009     ts.getNameOfAccessExpression = getNameOfAccessExpression;
14010     function isBundleFileTextLike(section) {
14011         switch (section.kind) {
14012             case "text":
14013             case "internal":
14014                 return true;
14015             default:
14016                 return false;
14017         }
14018     }
14019     ts.isBundleFileTextLike = isBundleFileTextLike;
14020     function isNamedImportsOrExports(node) {
14021         return node.kind === 257 || node.kind === 261;
14022     }
14023     ts.isNamedImportsOrExports = isNamedImportsOrExports;
14024     function Symbol(flags, name) {
14025         this.flags = flags;
14026         this.escapedName = name;
14027         this.declarations = undefined;
14028         this.valueDeclaration = undefined;
14029         this.id = undefined;
14030         this.mergeId = undefined;
14031         this.parent = undefined;
14032     }
14033     function Type(checker, flags) {
14034         this.flags = flags;
14035         if (ts.Debug.isDebugging) {
14036             this.checker = checker;
14037         }
14038     }
14039     function Signature(checker, flags) {
14040         this.flags = flags;
14041         if (ts.Debug.isDebugging) {
14042             this.checker = checker;
14043         }
14044     }
14045     function Node(kind, pos, end) {
14046         this.pos = pos;
14047         this.end = end;
14048         this.kind = kind;
14049         this.id = 0;
14050         this.flags = 0;
14051         this.modifierFlagsCache = 0;
14052         this.transformFlags = 0;
14053         this.parent = undefined;
14054         this.original = undefined;
14055     }
14056     function Token(kind, pos, end) {
14057         this.pos = pos;
14058         this.end = end;
14059         this.kind = kind;
14060         this.id = 0;
14061         this.flags = 0;
14062         this.transformFlags = 0;
14063         this.parent = undefined;
14064     }
14065     function Identifier(kind, pos, end) {
14066         this.pos = pos;
14067         this.end = end;
14068         this.kind = kind;
14069         this.id = 0;
14070         this.flags = 0;
14071         this.transformFlags = 0;
14072         this.parent = undefined;
14073         this.original = undefined;
14074         this.flowNode = undefined;
14075     }
14076     function SourceMapSource(fileName, text, skipTrivia) {
14077         this.fileName = fileName;
14078         this.text = text;
14079         this.skipTrivia = skipTrivia || (function (pos) { return pos; });
14080     }
14081     ts.objectAllocator = {
14082         getNodeConstructor: function () { return Node; },
14083         getTokenConstructor: function () { return Token; },
14084         getIdentifierConstructor: function () { return Identifier; },
14085         getPrivateIdentifierConstructor: function () { return Node; },
14086         getSourceFileConstructor: function () { return Node; },
14087         getSymbolConstructor: function () { return Symbol; },
14088         getTypeConstructor: function () { return Type; },
14089         getSignatureConstructor: function () { return Signature; },
14090         getSourceMapSourceConstructor: function () { return SourceMapSource; },
14091     };
14092     function setObjectAllocator(alloc) {
14093         ts.objectAllocator = alloc;
14094     }
14095     ts.setObjectAllocator = setObjectAllocator;
14096     function formatStringFromArgs(text, args, baseIndex) {
14097         if (baseIndex === void 0) { baseIndex = 0; }
14098         return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.checkDefined(args[+index + baseIndex]); });
14099     }
14100     ts.formatStringFromArgs = formatStringFromArgs;
14101     function setLocalizedDiagnosticMessages(messages) {
14102         ts.localizedDiagnosticMessages = messages;
14103     }
14104     ts.setLocalizedDiagnosticMessages = setLocalizedDiagnosticMessages;
14105     function getLocaleSpecificMessage(message) {
14106         return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message;
14107     }
14108     ts.getLocaleSpecificMessage = getLocaleSpecificMessage;
14109     function createFileDiagnostic(file, start, length, message) {
14110         ts.Debug.assertGreaterThanOrEqual(start, 0);
14111         ts.Debug.assertGreaterThanOrEqual(length, 0);
14112         if (file) {
14113             ts.Debug.assertLessThanOrEqual(start, file.text.length);
14114             ts.Debug.assertLessThanOrEqual(start + length, file.text.length);
14115         }
14116         var text = getLocaleSpecificMessage(message);
14117         if (arguments.length > 4) {
14118             text = formatStringFromArgs(text, arguments, 4);
14119         }
14120         return {
14121             file: file,
14122             start: start,
14123             length: length,
14124             messageText: text,
14125             category: message.category,
14126             code: message.code,
14127             reportsUnnecessary: message.reportsUnnecessary,
14128         };
14129     }
14130     ts.createFileDiagnostic = createFileDiagnostic;
14131     function formatMessage(_dummy, message) {
14132         var text = getLocaleSpecificMessage(message);
14133         if (arguments.length > 2) {
14134             text = formatStringFromArgs(text, arguments, 2);
14135         }
14136         return text;
14137     }
14138     ts.formatMessage = formatMessage;
14139     function createCompilerDiagnostic(message) {
14140         var text = getLocaleSpecificMessage(message);
14141         if (arguments.length > 1) {
14142             text = formatStringFromArgs(text, arguments, 1);
14143         }
14144         return {
14145             file: undefined,
14146             start: undefined,
14147             length: undefined,
14148             messageText: text,
14149             category: message.category,
14150             code: message.code,
14151             reportsUnnecessary: message.reportsUnnecessary,
14152         };
14153     }
14154     ts.createCompilerDiagnostic = createCompilerDiagnostic;
14155     function createCompilerDiagnosticFromMessageChain(chain) {
14156         return {
14157             file: undefined,
14158             start: undefined,
14159             length: undefined,
14160             code: chain.code,
14161             category: chain.category,
14162             messageText: chain.next ? chain : chain.messageText,
14163         };
14164     }
14165     ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain;
14166     function chainDiagnosticMessages(details, message) {
14167         var text = getLocaleSpecificMessage(message);
14168         if (arguments.length > 2) {
14169             text = formatStringFromArgs(text, arguments, 2);
14170         }
14171         return {
14172             messageText: text,
14173             category: message.category,
14174             code: message.code,
14175             next: details === undefined || Array.isArray(details) ? details : [details]
14176         };
14177     }
14178     ts.chainDiagnosticMessages = chainDiagnosticMessages;
14179     function concatenateDiagnosticMessageChains(headChain, tailChain) {
14180         var lastChain = headChain;
14181         while (lastChain.next) {
14182             lastChain = lastChain.next[0];
14183         }
14184         lastChain.next = [tailChain];
14185     }
14186     ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains;
14187     function getDiagnosticFilePath(diagnostic) {
14188         return diagnostic.file ? diagnostic.file.path : undefined;
14189     }
14190     function compareDiagnostics(d1, d2) {
14191         return compareDiagnosticsSkipRelatedInformation(d1, d2) ||
14192             compareRelatedInformation(d1, d2) ||
14193             0;
14194     }
14195     ts.compareDiagnostics = compareDiagnostics;
14196     function compareDiagnosticsSkipRelatedInformation(d1, d2) {
14197         return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) ||
14198             ts.compareValues(d1.start, d2.start) ||
14199             ts.compareValues(d1.length, d2.length) ||
14200             ts.compareValues(d1.code, d2.code) ||
14201             compareMessageText(d1.messageText, d2.messageText) ||
14202             0;
14203     }
14204     ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation;
14205     function compareRelatedInformation(d1, d2) {
14206         if (!d1.relatedInformation && !d2.relatedInformation) {
14207             return 0;
14208         }
14209         if (d1.relatedInformation && d2.relatedInformation) {
14210             return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) {
14211                 var d2i = d2.relatedInformation[index];
14212                 return compareDiagnostics(d1i, d2i);
14213             }) || 0;
14214         }
14215         return d1.relatedInformation ? -1 : 1;
14216     }
14217     function compareMessageText(t1, t2) {
14218         if (typeof t1 === "string" && typeof t2 === "string") {
14219             return ts.compareStringsCaseSensitive(t1, t2);
14220         }
14221         else if (typeof t1 === "string") {
14222             return -1;
14223         }
14224         else if (typeof t2 === "string") {
14225             return 1;
14226         }
14227         var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText);
14228         if (res) {
14229             return res;
14230         }
14231         if (!t1.next && !t2.next) {
14232             return 0;
14233         }
14234         if (!t1.next) {
14235             return -1;
14236         }
14237         if (!t2.next) {
14238             return 1;
14239         }
14240         var len = Math.min(t1.next.length, t2.next.length);
14241         for (var i = 0; i < len; i++) {
14242             res = compareMessageText(t1.next[i], t2.next[i]);
14243             if (res) {
14244                 return res;
14245             }
14246         }
14247         if (t1.next.length < t2.next.length) {
14248             return -1;
14249         }
14250         else if (t1.next.length > t2.next.length) {
14251             return 1;
14252         }
14253         return 0;
14254     }
14255     function getEmitScriptTarget(compilerOptions) {
14256         return compilerOptions.target || 0;
14257     }
14258     ts.getEmitScriptTarget = getEmitScriptTarget;
14259     function getEmitModuleKind(compilerOptions) {
14260         return typeof compilerOptions.module === "number" ?
14261             compilerOptions.module :
14262             getEmitScriptTarget(compilerOptions) >= 2 ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS;
14263     }
14264     ts.getEmitModuleKind = getEmitModuleKind;
14265     function getEmitModuleResolutionKind(compilerOptions) {
14266         var moduleResolution = compilerOptions.moduleResolution;
14267         if (moduleResolution === undefined) {
14268             moduleResolution = getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic;
14269         }
14270         return moduleResolution;
14271     }
14272     ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
14273     function hasJsonModuleEmitEnabled(options) {
14274         switch (getEmitModuleKind(options)) {
14275             case ts.ModuleKind.CommonJS:
14276             case ts.ModuleKind.AMD:
14277             case ts.ModuleKind.ES2015:
14278             case ts.ModuleKind.ES2020:
14279             case ts.ModuleKind.ESNext:
14280                 return true;
14281             default:
14282                 return false;
14283         }
14284     }
14285     ts.hasJsonModuleEmitEnabled = hasJsonModuleEmitEnabled;
14286     function unreachableCodeIsError(options) {
14287         return options.allowUnreachableCode === false;
14288     }
14289     ts.unreachableCodeIsError = unreachableCodeIsError;
14290     function unusedLabelIsError(options) {
14291         return options.allowUnusedLabels === false;
14292     }
14293     ts.unusedLabelIsError = unusedLabelIsError;
14294     function getAreDeclarationMapsEnabled(options) {
14295         return !!(getEmitDeclarations(options) && options.declarationMap);
14296     }
14297     ts.getAreDeclarationMapsEnabled = getAreDeclarationMapsEnabled;
14298     function getAllowSyntheticDefaultImports(compilerOptions) {
14299         var moduleKind = getEmitModuleKind(compilerOptions);
14300         return compilerOptions.allowSyntheticDefaultImports !== undefined
14301             ? compilerOptions.allowSyntheticDefaultImports
14302             : compilerOptions.esModuleInterop ||
14303                 moduleKind === ts.ModuleKind.System;
14304     }
14305     ts.getAllowSyntheticDefaultImports = getAllowSyntheticDefaultImports;
14306     function getEmitDeclarations(compilerOptions) {
14307         return !!(compilerOptions.declaration || compilerOptions.composite);
14308     }
14309     ts.getEmitDeclarations = getEmitDeclarations;
14310     function isIncrementalCompilation(options) {
14311         return !!(options.incremental || options.composite);
14312     }
14313     ts.isIncrementalCompilation = isIncrementalCompilation;
14314     function getStrictOptionValue(compilerOptions, flag) {
14315         return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag];
14316     }
14317     ts.getStrictOptionValue = getStrictOptionValue;
14318     function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) {
14319         return oldOptions !== newOptions &&
14320             ts.semanticDiagnosticsOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); });
14321     }
14322     ts.compilerOptionsAffectSemanticDiagnostics = compilerOptionsAffectSemanticDiagnostics;
14323     function compilerOptionsAffectEmit(newOptions, oldOptions) {
14324         return oldOptions !== newOptions &&
14325             ts.affectsEmitOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); });
14326     }
14327     ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit;
14328     function getCompilerOptionValue(options, option) {
14329         return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name];
14330     }
14331     ts.getCompilerOptionValue = getCompilerOptionValue;
14332     function hasZeroOrOneAsteriskCharacter(str) {
14333         var seenAsterisk = false;
14334         for (var i = 0; i < str.length; i++) {
14335             if (str.charCodeAt(i) === 42) {
14336                 if (!seenAsterisk) {
14337                     seenAsterisk = true;
14338                 }
14339                 else {
14340                     return false;
14341                 }
14342             }
14343         }
14344         return true;
14345     }
14346     ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter;
14347     function discoverProbableSymlinks(files, getCanonicalFileName, cwd) {
14348         var result = ts.createMap();
14349         var symlinks = ts.flatten(ts.mapDefined(files, function (sf) {
14350             return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) {
14351                 return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined;
14352             })));
14353         }));
14354         for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) {
14355             var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1];
14356             var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1];
14357             result.set(commonOriginal, commonResolved);
14358         }
14359         return result;
14360     }
14361     ts.discoverProbableSymlinks = discoverProbableSymlinks;
14362     function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) {
14363         var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName));
14364         var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName));
14365         while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) &&
14366             !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) &&
14367             getCanonicalFileName(aParts[aParts.length - 1]) === getCanonicalFileName(bParts[bParts.length - 1])) {
14368             aParts.pop();
14369             bParts.pop();
14370         }
14371         return [ts.getPathFromPathComponents(aParts), ts.getPathFromPathComponents(bParts)];
14372     }
14373     function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) {
14374         return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@");
14375     }
14376     function stripLeadingDirectorySeparator(s) {
14377         return ts.isAnyDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined;
14378     }
14379     function tryRemoveDirectoryPrefix(path, dirPath, getCanonicalFileName) {
14380         var withoutPrefix = ts.tryRemovePrefix(path, dirPath, getCanonicalFileName);
14381         return withoutPrefix === undefined ? undefined : stripLeadingDirectorySeparator(withoutPrefix);
14382     }
14383     ts.tryRemoveDirectoryPrefix = tryRemoveDirectoryPrefix;
14384     var reservedCharacterPattern = /[^\w\s\/]/g;
14385     function regExpEscape(text) {
14386         return text.replace(reservedCharacterPattern, escapeRegExpCharacter);
14387     }
14388     ts.regExpEscape = regExpEscape;
14389     function escapeRegExpCharacter(match) {
14390         return "\\" + match;
14391     }
14392     var wildcardCharCodes = [42, 63];
14393     ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"];
14394     var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))";
14395     var filesMatcher = {
14396         singleAsteriskRegexFragment: "([^./]|(\\.(?!min\\.js$))?)*",
14397         doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?",
14398         replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment); }
14399     };
14400     var directoriesMatcher = {
14401         singleAsteriskRegexFragment: "[^/]*",
14402         doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?",
14403         replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment); }
14404     };
14405     var excludeMatcher = {
14406         singleAsteriskRegexFragment: "[^/]*",
14407         doubleAsteriskRegexFragment: "(/.+?)?",
14408         replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, excludeMatcher.singleAsteriskRegexFragment); }
14409     };
14410     var wildcardMatchers = {
14411         files: filesMatcher,
14412         directories: directoriesMatcher,
14413         exclude: excludeMatcher
14414     };
14415     function getRegularExpressionForWildcard(specs, basePath, usage) {
14416         var patterns = getRegularExpressionsForWildcards(specs, basePath, usage);
14417         if (!patterns || !patterns.length) {
14418             return undefined;
14419         }
14420         var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|");
14421         var terminator = usage === "exclude" ? "($|/)" : "$";
14422         return "^(" + pattern + ")" + terminator;
14423     }
14424     ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard;
14425     function getRegularExpressionsForWildcards(specs, basePath, usage) {
14426         if (specs === undefined || specs.length === 0) {
14427             return undefined;
14428         }
14429         return ts.flatMap(specs, function (spec) {
14430             return spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]);
14431         });
14432     }
14433     ts.getRegularExpressionsForWildcards = getRegularExpressionsForWildcards;
14434     function isImplicitGlob(lastPathComponent) {
14435         return !/[.*?]/.test(lastPathComponent);
14436     }
14437     ts.isImplicitGlob = isImplicitGlob;
14438     function getSubPatternFromSpec(spec, basePath, usage, _a) {
14439         var singleAsteriskRegexFragment = _a.singleAsteriskRegexFragment, doubleAsteriskRegexFragment = _a.doubleAsteriskRegexFragment, replaceWildcardCharacter = _a.replaceWildcardCharacter;
14440         var subpattern = "";
14441         var hasWrittenComponent = false;
14442         var components = ts.getNormalizedPathComponents(spec, basePath);
14443         var lastComponent = ts.last(components);
14444         if (usage !== "exclude" && lastComponent === "**") {
14445             return undefined;
14446         }
14447         components[0] = ts.removeTrailingDirectorySeparator(components[0]);
14448         if (isImplicitGlob(lastComponent)) {
14449             components.push("**", "*");
14450         }
14451         var optionalCount = 0;
14452         for (var _i = 0, components_1 = components; _i < components_1.length; _i++) {
14453             var component = components_1[_i];
14454             if (component === "**") {
14455                 subpattern += doubleAsteriskRegexFragment;
14456             }
14457             else {
14458                 if (usage === "directories") {
14459                     subpattern += "(";
14460                     optionalCount++;
14461                 }
14462                 if (hasWrittenComponent) {
14463                     subpattern += ts.directorySeparator;
14464                 }
14465                 if (usage !== "exclude") {
14466                     var componentPattern = "";
14467                     if (component.charCodeAt(0) === 42) {
14468                         componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?";
14469                         component = component.substr(1);
14470                     }
14471                     else if (component.charCodeAt(0) === 63) {
14472                         componentPattern += "[^./]";
14473                         component = component.substr(1);
14474                     }
14475                     componentPattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter);
14476                     if (componentPattern !== component) {
14477                         subpattern += implicitExcludePathRegexPattern;
14478                     }
14479                     subpattern += componentPattern;
14480                 }
14481                 else {
14482                     subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter);
14483                 }
14484             }
14485             hasWrittenComponent = true;
14486         }
14487         while (optionalCount > 0) {
14488             subpattern += ")?";
14489             optionalCount--;
14490         }
14491         return subpattern;
14492     }
14493     function replaceWildcardCharacter(match, singleAsteriskRegexFragment) {
14494         return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match;
14495     }
14496     function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) {
14497         path = ts.normalizePath(path);
14498         currentDirectory = ts.normalizePath(currentDirectory);
14499         var absolutePath = ts.combinePaths(currentDirectory, path);
14500         return {
14501             includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }),
14502             includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"),
14503             includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"),
14504             excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"),
14505             basePaths: getBasePaths(path, includes, useCaseSensitiveFileNames)
14506         };
14507     }
14508     ts.getFileMatcherPatterns = getFileMatcherPatterns;
14509     function getRegexFromPattern(pattern, useCaseSensitiveFileNames) {
14510         return new RegExp(pattern, useCaseSensitiveFileNames ? "" : "i");
14511     }
14512     ts.getRegexFromPattern = getRegexFromPattern;
14513     function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath) {
14514         path = ts.normalizePath(path);
14515         currentDirectory = ts.normalizePath(currentDirectory);
14516         var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory);
14517         var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return getRegexFromPattern(pattern, useCaseSensitiveFileNames); });
14518         var includeDirectoryRegex = patterns.includeDirectoryPattern && getRegexFromPattern(patterns.includeDirectoryPattern, useCaseSensitiveFileNames);
14519         var excludeRegex = patterns.excludePattern && getRegexFromPattern(patterns.excludePattern, useCaseSensitiveFileNames);
14520         var results = includeFileRegexes ? includeFileRegexes.map(function () { return []; }) : [[]];
14521         var visited = ts.createMap();
14522         var toCanonical = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
14523         for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) {
14524             var basePath = _a[_i];
14525             visitDirectory(basePath, ts.combinePaths(currentDirectory, basePath), depth);
14526         }
14527         return ts.flatten(results);
14528         function visitDirectory(path, absolutePath, depth) {
14529             var canonicalPath = toCanonical(realpath(absolutePath));
14530             if (visited.has(canonicalPath))
14531                 return;
14532             visited.set(canonicalPath, true);
14533             var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories;
14534             var _loop_1 = function (current) {
14535                 var name = ts.combinePaths(path, current);
14536                 var absoluteName = ts.combinePaths(absolutePath, current);
14537                 if (extensions && !ts.fileExtensionIsOneOf(name, extensions))
14538                     return "continue";
14539                 if (excludeRegex && excludeRegex.test(absoluteName))
14540                     return "continue";
14541                 if (!includeFileRegexes) {
14542                     results[0].push(name);
14543                 }
14544                 else {
14545                     var includeIndex = ts.findIndex(includeFileRegexes, function (re) { return re.test(absoluteName); });
14546                     if (includeIndex !== -1) {
14547                         results[includeIndex].push(name);
14548                     }
14549                 }
14550             };
14551             for (var _i = 0, _b = ts.sort(files, ts.compareStringsCaseSensitive); _i < _b.length; _i++) {
14552                 var current = _b[_i];
14553                 _loop_1(current);
14554             }
14555             if (depth !== undefined) {
14556                 depth--;
14557                 if (depth === 0) {
14558                     return;
14559                 }
14560             }
14561             for (var _c = 0, _d = ts.sort(directories, ts.compareStringsCaseSensitive); _c < _d.length; _c++) {
14562                 var current = _d[_c];
14563                 var name = ts.combinePaths(path, current);
14564                 var absoluteName = ts.combinePaths(absolutePath, current);
14565                 if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) &&
14566                     (!excludeRegex || !excludeRegex.test(absoluteName))) {
14567                     visitDirectory(name, absoluteName, depth);
14568                 }
14569             }
14570         }
14571     }
14572     ts.matchFiles = matchFiles;
14573     function getBasePaths(path, includes, useCaseSensitiveFileNames) {
14574         var basePaths = [path];
14575         if (includes) {
14576             var includeBasePaths = [];
14577             for (var _i = 0, includes_1 = includes; _i < includes_1.length; _i++) {
14578                 var include = includes_1[_i];
14579                 var absolute = ts.isRootedDiskPath(include) ? include : ts.normalizePath(ts.combinePaths(path, include));
14580                 includeBasePaths.push(getIncludeBasePath(absolute));
14581             }
14582             includeBasePaths.sort(ts.getStringComparer(!useCaseSensitiveFileNames));
14583             var _loop_2 = function (includeBasePath) {
14584                 if (ts.every(basePaths, function (basePath) { return !ts.containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) {
14585                     basePaths.push(includeBasePath);
14586                 }
14587             };
14588             for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) {
14589                 var includeBasePath = includeBasePaths_1[_a];
14590                 _loop_2(includeBasePath);
14591             }
14592         }
14593         return basePaths;
14594     }
14595     function getIncludeBasePath(absolute) {
14596         var wildcardOffset = ts.indexOfAnyCharCode(absolute, wildcardCharCodes);
14597         if (wildcardOffset < 0) {
14598             return !ts.hasExtension(absolute)
14599                 ? absolute
14600                 : ts.removeTrailingDirectorySeparator(ts.getDirectoryPath(absolute));
14601         }
14602         return absolute.substring(0, absolute.lastIndexOf(ts.directorySeparator, wildcardOffset));
14603     }
14604     function ensureScriptKind(fileName, scriptKind) {
14605         return scriptKind || getScriptKindFromFileName(fileName) || 3;
14606     }
14607     ts.ensureScriptKind = ensureScriptKind;
14608     function getScriptKindFromFileName(fileName) {
14609         var ext = fileName.substr(fileName.lastIndexOf("."));
14610         switch (ext.toLowerCase()) {
14611             case ".js":
14612                 return 1;
14613             case ".jsx":
14614                 return 2;
14615             case ".ts":
14616                 return 3;
14617             case ".tsx":
14618                 return 4;
14619             case ".json":
14620                 return 6;
14621             default:
14622                 return 0;
14623         }
14624     }
14625     ts.getScriptKindFromFileName = getScriptKindFromFileName;
14626     ts.supportedTSExtensions = [".ts", ".tsx", ".d.ts"];
14627     ts.supportedTSExtensionsWithJson = [".ts", ".tsx", ".d.ts", ".json"];
14628     ts.supportedTSExtensionsForExtractExtension = [".d.ts", ".ts", ".tsx"];
14629     ts.supportedJSExtensions = [".js", ".jsx"];
14630     ts.supportedJSAndJsonExtensions = [".js", ".jsx", ".json"];
14631     var allSupportedExtensions = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions);
14632     var allSupportedExtensionsWithJson = __spreadArrays(ts.supportedTSExtensions, ts.supportedJSExtensions, [".json"]);
14633     function getSupportedExtensions(options, extraFileExtensions) {
14634         var needJsExtensions = options && options.allowJs;
14635         if (!extraFileExtensions || extraFileExtensions.length === 0) {
14636             return needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions;
14637         }
14638         var extensions = __spreadArrays(needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions, ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; }));
14639         return ts.deduplicate(extensions, ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive);
14640     }
14641     ts.getSupportedExtensions = getSupportedExtensions;
14642     function getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions) {
14643         if (!options || !options.resolveJsonModule) {
14644             return supportedExtensions;
14645         }
14646         if (supportedExtensions === allSupportedExtensions) {
14647             return allSupportedExtensionsWithJson;
14648         }
14649         if (supportedExtensions === ts.supportedTSExtensions) {
14650             return ts.supportedTSExtensionsWithJson;
14651         }
14652         return __spreadArrays(supportedExtensions, [".json"]);
14653     }
14654     ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule;
14655     function isJSLike(scriptKind) {
14656         return scriptKind === 1 || scriptKind === 2;
14657     }
14658     function hasJSFileExtension(fileName) {
14659         return ts.some(ts.supportedJSExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); });
14660     }
14661     ts.hasJSFileExtension = hasJSFileExtension;
14662     function hasTSFileExtension(fileName) {
14663         return ts.some(ts.supportedTSExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); });
14664     }
14665     ts.hasTSFileExtension = hasTSFileExtension;
14666     function isSupportedSourceFileName(fileName, compilerOptions, extraFileExtensions) {
14667         if (!fileName) {
14668             return false;
14669         }
14670         var supportedExtensions = getSupportedExtensions(compilerOptions, extraFileExtensions);
14671         for (var _i = 0, _a = getSuppoertedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions); _i < _a.length; _i++) {
14672             var extension = _a[_i];
14673             if (ts.fileExtensionIs(fileName, extension)) {
14674                 return true;
14675             }
14676         }
14677         return false;
14678     }
14679     ts.isSupportedSourceFileName = isSupportedSourceFileName;
14680     function getExtensionPriority(path, supportedExtensions) {
14681         for (var i = supportedExtensions.length - 1; i >= 0; i--) {
14682             if (ts.fileExtensionIs(path, supportedExtensions[i])) {
14683                 return adjustExtensionPriority(i, supportedExtensions);
14684             }
14685         }
14686         return 0;
14687     }
14688     ts.getExtensionPriority = getExtensionPriority;
14689     function adjustExtensionPriority(extensionPriority, supportedExtensions) {
14690         if (extensionPriority < 2) {
14691             return 0;
14692         }
14693         else if (extensionPriority < supportedExtensions.length) {
14694             return 2;
14695         }
14696         else {
14697             return supportedExtensions.length;
14698         }
14699     }
14700     ts.adjustExtensionPriority = adjustExtensionPriority;
14701     function getNextLowestExtensionPriority(extensionPriority, supportedExtensions) {
14702         if (extensionPriority < 2) {
14703             return 2;
14704         }
14705         else {
14706             return supportedExtensions.length;
14707         }
14708     }
14709     ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority;
14710     var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx", ".json"];
14711     function removeFileExtension(path) {
14712         for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) {
14713             var ext = extensionsToRemove_1[_i];
14714             var extensionless = tryRemoveExtension(path, ext);
14715             if (extensionless !== undefined) {
14716                 return extensionless;
14717             }
14718         }
14719         return path;
14720     }
14721     ts.removeFileExtension = removeFileExtension;
14722     function tryRemoveExtension(path, extension) {
14723         return ts.fileExtensionIs(path, extension) ? removeExtension(path, extension) : undefined;
14724     }
14725     ts.tryRemoveExtension = tryRemoveExtension;
14726     function removeExtension(path, extension) {
14727         return path.substring(0, path.length - extension.length);
14728     }
14729     ts.removeExtension = removeExtension;
14730     function changeExtension(path, newExtension) {
14731         return ts.changeAnyExtension(path, newExtension, extensionsToRemove, false);
14732     }
14733     ts.changeExtension = changeExtension;
14734     function tryParsePattern(pattern) {
14735         ts.Debug.assert(hasZeroOrOneAsteriskCharacter(pattern));
14736         var indexOfStar = pattern.indexOf("*");
14737         return indexOfStar === -1 ? undefined : {
14738             prefix: pattern.substr(0, indexOfStar),
14739             suffix: pattern.substr(indexOfStar + 1)
14740         };
14741     }
14742     ts.tryParsePattern = tryParsePattern;
14743     function positionIsSynthesized(pos) {
14744         return !(pos >= 0);
14745     }
14746     ts.positionIsSynthesized = positionIsSynthesized;
14747     function extensionIsTS(ext) {
14748         return ext === ".ts" || ext === ".tsx" || ext === ".d.ts";
14749     }
14750     ts.extensionIsTS = extensionIsTS;
14751     function resolutionExtensionIsTSOrJson(ext) {
14752         return extensionIsTS(ext) || ext === ".json";
14753     }
14754     ts.resolutionExtensionIsTSOrJson = resolutionExtensionIsTSOrJson;
14755     function extensionFromPath(path) {
14756         var ext = tryGetExtensionFromPath(path);
14757         return ext !== undefined ? ext : ts.Debug.fail("File " + path + " has unknown extension.");
14758     }
14759     ts.extensionFromPath = extensionFromPath;
14760     function isAnySupportedFileExtension(path) {
14761         return tryGetExtensionFromPath(path) !== undefined;
14762     }
14763     ts.isAnySupportedFileExtension = isAnySupportedFileExtension;
14764     function tryGetExtensionFromPath(path) {
14765         return ts.find(extensionsToRemove, function (e) { return ts.fileExtensionIs(path, e); });
14766     }
14767     ts.tryGetExtensionFromPath = tryGetExtensionFromPath;
14768     function isCheckJsEnabledForFile(sourceFile, compilerOptions) {
14769         return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs;
14770     }
14771     ts.isCheckJsEnabledForFile = isCheckJsEnabledForFile;
14772     ts.emptyFileSystemEntries = {
14773         files: ts.emptyArray,
14774         directories: ts.emptyArray
14775     };
14776     function matchPatternOrExact(patternStrings, candidate) {
14777         var patterns = [];
14778         for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) {
14779             var patternString = patternStrings_1[_i];
14780             if (!hasZeroOrOneAsteriskCharacter(patternString))
14781                 continue;
14782             var pattern = tryParsePattern(patternString);
14783             if (pattern) {
14784                 patterns.push(pattern);
14785             }
14786             else if (patternString === candidate) {
14787                 return patternString;
14788             }
14789         }
14790         return ts.findBestPatternMatch(patterns, function (_) { return _; }, candidate);
14791     }
14792     ts.matchPatternOrExact = matchPatternOrExact;
14793     function sliceAfter(arr, value) {
14794         var index = arr.indexOf(value);
14795         ts.Debug.assert(index !== -1);
14796         return arr.slice(index);
14797     }
14798     ts.sliceAfter = sliceAfter;
14799     function addRelatedInfo(diagnostic) {
14800         var _a;
14801         var relatedInformation = [];
14802         for (var _i = 1; _i < arguments.length; _i++) {
14803             relatedInformation[_i - 1] = arguments[_i];
14804         }
14805         if (!relatedInformation.length) {
14806             return diagnostic;
14807         }
14808         if (!diagnostic.relatedInformation) {
14809             diagnostic.relatedInformation = [];
14810         }
14811         (_a = diagnostic.relatedInformation).push.apply(_a, relatedInformation);
14812         return diagnostic;
14813     }
14814     ts.addRelatedInfo = addRelatedInfo;
14815     function minAndMax(arr, getValue) {
14816         ts.Debug.assert(arr.length !== 0);
14817         var min = getValue(arr[0]);
14818         var max = min;
14819         for (var i = 1; i < arr.length; i++) {
14820             var value = getValue(arr[i]);
14821             if (value < min) {
14822                 min = value;
14823             }
14824             else if (value > max) {
14825                 max = value;
14826             }
14827         }
14828         return { min: min, max: max };
14829     }
14830     ts.minAndMax = minAndMax;
14831     var NodeSet = (function () {
14832         function NodeSet() {
14833             this.map = ts.createMap();
14834         }
14835         NodeSet.prototype.add = function (node) {
14836             this.map.set(String(ts.getNodeId(node)), node);
14837         };
14838         NodeSet.prototype.tryAdd = function (node) {
14839             if (this.has(node))
14840                 return false;
14841             this.add(node);
14842             return true;
14843         };
14844         NodeSet.prototype.has = function (node) {
14845             return this.map.has(String(ts.getNodeId(node)));
14846         };
14847         NodeSet.prototype.forEach = function (cb) {
14848             this.map.forEach(cb);
14849         };
14850         NodeSet.prototype.some = function (pred) {
14851             return forEachEntry(this.map, pred) || false;
14852         };
14853         return NodeSet;
14854     }());
14855     ts.NodeSet = NodeSet;
14856     var NodeMap = (function () {
14857         function NodeMap() {
14858             this.map = ts.createMap();
14859         }
14860         NodeMap.prototype.get = function (node) {
14861             var res = this.map.get(String(ts.getNodeId(node)));
14862             return res && res.value;
14863         };
14864         NodeMap.prototype.getOrUpdate = function (node, setValue) {
14865             var res = this.get(node);
14866             if (res)
14867                 return res;
14868             var value = setValue();
14869             this.set(node, value);
14870             return value;
14871         };
14872         NodeMap.prototype.set = function (node, value) {
14873             this.map.set(String(ts.getNodeId(node)), { node: node, value: value });
14874         };
14875         NodeMap.prototype.has = function (node) {
14876             return this.map.has(String(ts.getNodeId(node)));
14877         };
14878         NodeMap.prototype.forEach = function (cb) {
14879             this.map.forEach(function (_a) {
14880                 var node = _a.node, value = _a.value;
14881                 return cb(value, node);
14882             });
14883         };
14884         return NodeMap;
14885     }());
14886     ts.NodeMap = NodeMap;
14887     function rangeOfNode(node) {
14888         return { pos: getTokenPosOfNode(node), end: node.end };
14889     }
14890     ts.rangeOfNode = rangeOfNode;
14891     function rangeOfTypeParameters(typeParameters) {
14892         return { pos: typeParameters.pos - 1, end: typeParameters.end + 1 };
14893     }
14894     ts.rangeOfTypeParameters = rangeOfTypeParameters;
14895     function skipTypeChecking(sourceFile, options, host) {
14896         return (options.skipLibCheck && sourceFile.isDeclarationFile ||
14897             options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) ||
14898             host.isSourceOfProjectReferenceRedirect(sourceFile.fileName);
14899     }
14900     ts.skipTypeChecking = skipTypeChecking;
14901     function isJsonEqual(a, b) {
14902         return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && ts.equalOwnProperties(a, b, isJsonEqual);
14903     }
14904     ts.isJsonEqual = isJsonEqual;
14905     function getOrUpdate(map, key, getDefault) {
14906         var got = map.get(key);
14907         if (got === undefined) {
14908             var value = getDefault();
14909             map.set(key, value);
14910             return value;
14911         }
14912         else {
14913             return got;
14914         }
14915     }
14916     ts.getOrUpdate = getOrUpdate;
14917     function parsePseudoBigInt(stringValue) {
14918         var log2Base;
14919         switch (stringValue.charCodeAt(1)) {
14920             case 98:
14921             case 66:
14922                 log2Base = 1;
14923                 break;
14924             case 111:
14925             case 79:
14926                 log2Base = 3;
14927                 break;
14928             case 120:
14929             case 88:
14930                 log2Base = 4;
14931                 break;
14932             default:
14933                 var nIndex = stringValue.length - 1;
14934                 var nonZeroStart = 0;
14935                 while (stringValue.charCodeAt(nonZeroStart) === 48) {
14936                     nonZeroStart++;
14937                 }
14938                 return stringValue.slice(nonZeroStart, nIndex) || "0";
14939         }
14940         var startIndex = 2, endIndex = stringValue.length - 1;
14941         var bitsNeeded = (endIndex - startIndex) * log2Base;
14942         var segments = new Uint16Array((bitsNeeded >>> 4) + (bitsNeeded & 15 ? 1 : 0));
14943         for (var i = endIndex - 1, bitOffset = 0; i >= startIndex; i--, bitOffset += log2Base) {
14944             var segment = bitOffset >>> 4;
14945             var digitChar = stringValue.charCodeAt(i);
14946             var digit = digitChar <= 57
14947                 ? digitChar - 48
14948                 : 10 + digitChar -
14949                     (digitChar <= 70 ? 65 : 97);
14950             var shiftedDigit = digit << (bitOffset & 15);
14951             segments[segment] |= shiftedDigit;
14952             var residual = shiftedDigit >>> 16;
14953             if (residual)
14954                 segments[segment + 1] |= residual;
14955         }
14956         var base10Value = "";
14957         var firstNonzeroSegment = segments.length - 1;
14958         var segmentsRemaining = true;
14959         while (segmentsRemaining) {
14960             var mod10 = 0;
14961             segmentsRemaining = false;
14962             for (var segment = firstNonzeroSegment; segment >= 0; segment--) {
14963                 var newSegment = mod10 << 16 | segments[segment];
14964                 var segmentValue = (newSegment / 10) | 0;
14965                 segments[segment] = segmentValue;
14966                 mod10 = newSegment - segmentValue * 10;
14967                 if (segmentValue && !segmentsRemaining) {
14968                     firstNonzeroSegment = segment;
14969                     segmentsRemaining = true;
14970                 }
14971             }
14972             base10Value = mod10 + base10Value;
14973         }
14974         return base10Value;
14975     }
14976     ts.parsePseudoBigInt = parsePseudoBigInt;
14977     function pseudoBigIntToString(_a) {
14978         var negative = _a.negative, base10Value = _a.base10Value;
14979         return (negative && base10Value !== "0" ? "-" : "") + base10Value;
14980     }
14981     ts.pseudoBigIntToString = pseudoBigIntToString;
14982     function isValidTypeOnlyAliasUseSite(useSite) {
14983         return !!(useSite.flags & 8388608)
14984             || isPartOfTypeQuery(useSite)
14985             || isIdentifierInNonEmittingHeritageClause(useSite)
14986             || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite)
14987             || !isExpressionNode(useSite);
14988     }
14989     ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite;
14990     function typeOnlyDeclarationIsExport(typeOnlyDeclaration) {
14991         return typeOnlyDeclaration.kind === 263;
14992     }
14993     ts.typeOnlyDeclarationIsExport = typeOnlyDeclarationIsExport;
14994     function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) {
14995         while (node.kind === 75 || node.kind === 194) {
14996             node = node.parent;
14997         }
14998         if (node.kind !== 154) {
14999             return false;
15000         }
15001         if (hasModifier(node.parent, 128)) {
15002             return true;
15003         }
15004         var containerKind = node.parent.parent.kind;
15005         return containerKind === 246 || containerKind === 173;
15006     }
15007     function isIdentifierInNonEmittingHeritageClause(node) {
15008         if (node.kind !== 75)
15009             return false;
15010         var heritageClause = findAncestor(node.parent, function (parent) {
15011             switch (parent.kind) {
15012                 case 279:
15013                     return true;
15014                 case 194:
15015                 case 216:
15016                     return false;
15017                 default:
15018                     return "quit";
15019             }
15020         });
15021         return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 113 || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 246;
15022     }
15023     function isIdentifierTypeReference(node) {
15024         return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName);
15025     }
15026     ts.isIdentifierTypeReference = isIdentifierTypeReference;
15027     function arrayIsHomogeneous(array, comparer) {
15028         if (comparer === void 0) { comparer = ts.equateValues; }
15029         if (array.length < 2)
15030             return true;
15031         var first = array[0];
15032         for (var i = 1, length_1 = array.length; i < length_1; i++) {
15033             var target = array[i];
15034             if (!comparer(first, target))
15035                 return false;
15036         }
15037         return true;
15038     }
15039     ts.arrayIsHomogeneous = arrayIsHomogeneous;
15040 })(ts || (ts = {}));
15041 var ts;
15042 (function (ts) {
15043     var NodeConstructor;
15044     var TokenConstructor;
15045     var IdentifierConstructor;
15046     var PrivateIdentifierConstructor;
15047     var SourceFileConstructor;
15048     function createNode(kind, pos, end) {
15049         if (kind === 290) {
15050             return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end);
15051         }
15052         else if (kind === 75) {
15053             return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end);
15054         }
15055         else if (kind === 76) {
15056             return new (PrivateIdentifierConstructor || (PrivateIdentifierConstructor = ts.objectAllocator.getPrivateIdentifierConstructor()))(kind, pos, end);
15057         }
15058         else if (!ts.isNodeKind(kind)) {
15059             return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end);
15060         }
15061         else {
15062             return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, pos, end);
15063         }
15064     }
15065     ts.createNode = createNode;
15066     function visitNode(cbNode, node) {
15067         return node && cbNode(node);
15068     }
15069     function visitNodes(cbNode, cbNodes, nodes) {
15070         if (nodes) {
15071             if (cbNodes) {
15072                 return cbNodes(nodes);
15073             }
15074             for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
15075                 var node = nodes_1[_i];
15076                 var result = cbNode(node);
15077                 if (result) {
15078                     return result;
15079                 }
15080             }
15081         }
15082     }
15083     function isJSDocLikeText(text, start) {
15084         return text.charCodeAt(start + 1) === 42 &&
15085             text.charCodeAt(start + 2) === 42 &&
15086             text.charCodeAt(start + 3) !== 47;
15087     }
15088     ts.isJSDocLikeText = isJSDocLikeText;
15089     function forEachChild(node, cbNode, cbNodes) {
15090         if (!node || node.kind <= 152) {
15091             return;
15092         }
15093         switch (node.kind) {
15094             case 153:
15095                 return visitNode(cbNode, node.left) ||
15096                     visitNode(cbNode, node.right);
15097             case 155:
15098                 return visitNode(cbNode, node.name) ||
15099                     visitNode(cbNode, node.constraint) ||
15100                     visitNode(cbNode, node.default) ||
15101                     visitNode(cbNode, node.expression);
15102             case 282:
15103                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15104                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15105                     visitNode(cbNode, node.name) ||
15106                     visitNode(cbNode, node.questionToken) ||
15107                     visitNode(cbNode, node.exclamationToken) ||
15108                     visitNode(cbNode, node.equalsToken) ||
15109                     visitNode(cbNode, node.objectAssignmentInitializer);
15110             case 283:
15111                 return visitNode(cbNode, node.expression);
15112             case 156:
15113                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15114                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15115                     visitNode(cbNode, node.dotDotDotToken) ||
15116                     visitNode(cbNode, node.name) ||
15117                     visitNode(cbNode, node.questionToken) ||
15118                     visitNode(cbNode, node.type) ||
15119                     visitNode(cbNode, node.initializer);
15120             case 159:
15121                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15122                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15123                     visitNode(cbNode, node.name) ||
15124                     visitNode(cbNode, node.questionToken) ||
15125                     visitNode(cbNode, node.exclamationToken) ||
15126                     visitNode(cbNode, node.type) ||
15127                     visitNode(cbNode, node.initializer);
15128             case 158:
15129                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15130                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15131                     visitNode(cbNode, node.name) ||
15132                     visitNode(cbNode, node.questionToken) ||
15133                     visitNode(cbNode, node.type) ||
15134                     visitNode(cbNode, node.initializer);
15135             case 281:
15136                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15137                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15138                     visitNode(cbNode, node.name) ||
15139                     visitNode(cbNode, node.questionToken) ||
15140                     visitNode(cbNode, node.initializer);
15141             case 242:
15142                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15143                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15144                     visitNode(cbNode, node.name) ||
15145                     visitNode(cbNode, node.exclamationToken) ||
15146                     visitNode(cbNode, node.type) ||
15147                     visitNode(cbNode, node.initializer);
15148             case 191:
15149                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15150                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15151                     visitNode(cbNode, node.dotDotDotToken) ||
15152                     visitNode(cbNode, node.propertyName) ||
15153                     visitNode(cbNode, node.name) ||
15154                     visitNode(cbNode, node.initializer);
15155             case 170:
15156             case 171:
15157             case 165:
15158             case 166:
15159             case 167:
15160                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15161                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15162                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
15163                     visitNodes(cbNode, cbNodes, node.parameters) ||
15164                     visitNode(cbNode, node.type);
15165             case 161:
15166             case 160:
15167             case 162:
15168             case 163:
15169             case 164:
15170             case 201:
15171             case 244:
15172             case 202:
15173                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15174                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15175                     visitNode(cbNode, node.asteriskToken) ||
15176                     visitNode(cbNode, node.name) ||
15177                     visitNode(cbNode, node.questionToken) ||
15178                     visitNode(cbNode, node.exclamationToken) ||
15179                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
15180                     visitNodes(cbNode, cbNodes, node.parameters) ||
15181                     visitNode(cbNode, node.type) ||
15182                     visitNode(cbNode, node.equalsGreaterThanToken) ||
15183                     visitNode(cbNode, node.body);
15184             case 169:
15185                 return visitNode(cbNode, node.typeName) ||
15186                     visitNodes(cbNode, cbNodes, node.typeArguments);
15187             case 168:
15188                 return visitNode(cbNode, node.assertsModifier) ||
15189                     visitNode(cbNode, node.parameterName) ||
15190                     visitNode(cbNode, node.type);
15191             case 172:
15192                 return visitNode(cbNode, node.exprName);
15193             case 173:
15194                 return visitNodes(cbNode, cbNodes, node.members);
15195             case 174:
15196                 return visitNode(cbNode, node.elementType);
15197             case 175:
15198                 return visitNodes(cbNode, cbNodes, node.elementTypes);
15199             case 178:
15200             case 179:
15201                 return visitNodes(cbNode, cbNodes, node.types);
15202             case 180:
15203                 return visitNode(cbNode, node.checkType) ||
15204                     visitNode(cbNode, node.extendsType) ||
15205                     visitNode(cbNode, node.trueType) ||
15206                     visitNode(cbNode, node.falseType);
15207             case 181:
15208                 return visitNode(cbNode, node.typeParameter);
15209             case 188:
15210                 return visitNode(cbNode, node.argument) ||
15211                     visitNode(cbNode, node.qualifier) ||
15212                     visitNodes(cbNode, cbNodes, node.typeArguments);
15213             case 182:
15214             case 184:
15215                 return visitNode(cbNode, node.type);
15216             case 185:
15217                 return visitNode(cbNode, node.objectType) ||
15218                     visitNode(cbNode, node.indexType);
15219             case 186:
15220                 return visitNode(cbNode, node.readonlyToken) ||
15221                     visitNode(cbNode, node.typeParameter) ||
15222                     visitNode(cbNode, node.questionToken) ||
15223                     visitNode(cbNode, node.type);
15224             case 187:
15225                 return visitNode(cbNode, node.literal);
15226             case 189:
15227             case 190:
15228                 return visitNodes(cbNode, cbNodes, node.elements);
15229             case 192:
15230                 return visitNodes(cbNode, cbNodes, node.elements);
15231             case 193:
15232                 return visitNodes(cbNode, cbNodes, node.properties);
15233             case 194:
15234                 return visitNode(cbNode, node.expression) ||
15235                     visitNode(cbNode, node.questionDotToken) ||
15236                     visitNode(cbNode, node.name);
15237             case 195:
15238                 return visitNode(cbNode, node.expression) ||
15239                     visitNode(cbNode, node.questionDotToken) ||
15240                     visitNode(cbNode, node.argumentExpression);
15241             case 196:
15242             case 197:
15243                 return visitNode(cbNode, node.expression) ||
15244                     visitNode(cbNode, node.questionDotToken) ||
15245                     visitNodes(cbNode, cbNodes, node.typeArguments) ||
15246                     visitNodes(cbNode, cbNodes, node.arguments);
15247             case 198:
15248                 return visitNode(cbNode, node.tag) ||
15249                     visitNode(cbNode, node.questionDotToken) ||
15250                     visitNodes(cbNode, cbNodes, node.typeArguments) ||
15251                     visitNode(cbNode, node.template);
15252             case 199:
15253                 return visitNode(cbNode, node.type) ||
15254                     visitNode(cbNode, node.expression);
15255             case 200:
15256                 return visitNode(cbNode, node.expression);
15257             case 203:
15258                 return visitNode(cbNode, node.expression);
15259             case 204:
15260                 return visitNode(cbNode, node.expression);
15261             case 205:
15262                 return visitNode(cbNode, node.expression);
15263             case 207:
15264                 return visitNode(cbNode, node.operand);
15265             case 212:
15266                 return visitNode(cbNode, node.asteriskToken) ||
15267                     visitNode(cbNode, node.expression);
15268             case 206:
15269                 return visitNode(cbNode, node.expression);
15270             case 208:
15271                 return visitNode(cbNode, node.operand);
15272             case 209:
15273                 return visitNode(cbNode, node.left) ||
15274                     visitNode(cbNode, node.operatorToken) ||
15275                     visitNode(cbNode, node.right);
15276             case 217:
15277                 return visitNode(cbNode, node.expression) ||
15278                     visitNode(cbNode, node.type);
15279             case 218:
15280                 return visitNode(cbNode, node.expression);
15281             case 219:
15282                 return visitNode(cbNode, node.name);
15283             case 210:
15284                 return visitNode(cbNode, node.condition) ||
15285                     visitNode(cbNode, node.questionToken) ||
15286                     visitNode(cbNode, node.whenTrue) ||
15287                     visitNode(cbNode, node.colonToken) ||
15288                     visitNode(cbNode, node.whenFalse);
15289             case 213:
15290                 return visitNode(cbNode, node.expression);
15291             case 223:
15292             case 250:
15293                 return visitNodes(cbNode, cbNodes, node.statements);
15294             case 290:
15295                 return visitNodes(cbNode, cbNodes, node.statements) ||
15296                     visitNode(cbNode, node.endOfFileToken);
15297             case 225:
15298                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15299                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15300                     visitNode(cbNode, node.declarationList);
15301             case 243:
15302                 return visitNodes(cbNode, cbNodes, node.declarations);
15303             case 226:
15304                 return visitNode(cbNode, node.expression);
15305             case 227:
15306                 return visitNode(cbNode, node.expression) ||
15307                     visitNode(cbNode, node.thenStatement) ||
15308                     visitNode(cbNode, node.elseStatement);
15309             case 228:
15310                 return visitNode(cbNode, node.statement) ||
15311                     visitNode(cbNode, node.expression);
15312             case 229:
15313                 return visitNode(cbNode, node.expression) ||
15314                     visitNode(cbNode, node.statement);
15315             case 230:
15316                 return visitNode(cbNode, node.initializer) ||
15317                     visitNode(cbNode, node.condition) ||
15318                     visitNode(cbNode, node.incrementor) ||
15319                     visitNode(cbNode, node.statement);
15320             case 231:
15321                 return visitNode(cbNode, node.initializer) ||
15322                     visitNode(cbNode, node.expression) ||
15323                     visitNode(cbNode, node.statement);
15324             case 232:
15325                 return visitNode(cbNode, node.awaitModifier) ||
15326                     visitNode(cbNode, node.initializer) ||
15327                     visitNode(cbNode, node.expression) ||
15328                     visitNode(cbNode, node.statement);
15329             case 233:
15330             case 234:
15331                 return visitNode(cbNode, node.label);
15332             case 235:
15333                 return visitNode(cbNode, node.expression);
15334             case 236:
15335                 return visitNode(cbNode, node.expression) ||
15336                     visitNode(cbNode, node.statement);
15337             case 237:
15338                 return visitNode(cbNode, node.expression) ||
15339                     visitNode(cbNode, node.caseBlock);
15340             case 251:
15341                 return visitNodes(cbNode, cbNodes, node.clauses);
15342             case 277:
15343                 return visitNode(cbNode, node.expression) ||
15344                     visitNodes(cbNode, cbNodes, node.statements);
15345             case 278:
15346                 return visitNodes(cbNode, cbNodes, node.statements);
15347             case 238:
15348                 return visitNode(cbNode, node.label) ||
15349                     visitNode(cbNode, node.statement);
15350             case 239:
15351                 return visitNode(cbNode, node.expression);
15352             case 240:
15353                 return visitNode(cbNode, node.tryBlock) ||
15354                     visitNode(cbNode, node.catchClause) ||
15355                     visitNode(cbNode, node.finallyBlock);
15356             case 280:
15357                 return visitNode(cbNode, node.variableDeclaration) ||
15358                     visitNode(cbNode, node.block);
15359             case 157:
15360                 return visitNode(cbNode, node.expression);
15361             case 245:
15362             case 214:
15363                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15364                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15365                     visitNode(cbNode, node.name) ||
15366                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
15367                     visitNodes(cbNode, cbNodes, node.heritageClauses) ||
15368                     visitNodes(cbNode, cbNodes, node.members);
15369             case 246:
15370                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15371                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15372                     visitNode(cbNode, node.name) ||
15373                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
15374                     visitNodes(cbNode, cbNodes, node.heritageClauses) ||
15375                     visitNodes(cbNode, cbNodes, node.members);
15376             case 247:
15377                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15378                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15379                     visitNode(cbNode, node.name) ||
15380                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
15381                     visitNode(cbNode, node.type);
15382             case 248:
15383                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15384                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15385                     visitNode(cbNode, node.name) ||
15386                     visitNodes(cbNode, cbNodes, node.members);
15387             case 284:
15388                 return visitNode(cbNode, node.name) ||
15389                     visitNode(cbNode, node.initializer);
15390             case 249:
15391                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15392                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15393                     visitNode(cbNode, node.name) ||
15394                     visitNode(cbNode, node.body);
15395             case 253:
15396                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15397                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15398                     visitNode(cbNode, node.name) ||
15399                     visitNode(cbNode, node.moduleReference);
15400             case 254:
15401                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15402                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15403                     visitNode(cbNode, node.importClause) ||
15404                     visitNode(cbNode, node.moduleSpecifier);
15405             case 255:
15406                 return visitNode(cbNode, node.name) ||
15407                     visitNode(cbNode, node.namedBindings);
15408             case 252:
15409                 return visitNode(cbNode, node.name);
15410             case 256:
15411                 return visitNode(cbNode, node.name);
15412             case 262:
15413                 return visitNode(cbNode, node.name);
15414             case 257:
15415             case 261:
15416                 return visitNodes(cbNode, cbNodes, node.elements);
15417             case 260:
15418                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15419                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15420                     visitNode(cbNode, node.exportClause) ||
15421                     visitNode(cbNode, node.moduleSpecifier);
15422             case 258:
15423             case 263:
15424                 return visitNode(cbNode, node.propertyName) ||
15425                     visitNode(cbNode, node.name);
15426             case 259:
15427                 return visitNodes(cbNode, cbNodes, node.decorators) ||
15428                     visitNodes(cbNode, cbNodes, node.modifiers) ||
15429                     visitNode(cbNode, node.expression);
15430             case 211:
15431                 return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans);
15432             case 221:
15433                 return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal);
15434             case 154:
15435                 return visitNode(cbNode, node.expression);
15436             case 279:
15437                 return visitNodes(cbNode, cbNodes, node.types);
15438             case 216:
15439                 return visitNode(cbNode, node.expression) ||
15440                     visitNodes(cbNode, cbNodes, node.typeArguments);
15441             case 265:
15442                 return visitNode(cbNode, node.expression);
15443             case 264:
15444                 return visitNodes(cbNode, cbNodes, node.decorators);
15445             case 327:
15446                 return visitNodes(cbNode, cbNodes, node.elements);
15447             case 266:
15448                 return visitNode(cbNode, node.openingElement) ||
15449                     visitNodes(cbNode, cbNodes, node.children) ||
15450                     visitNode(cbNode, node.closingElement);
15451             case 270:
15452                 return visitNode(cbNode, node.openingFragment) ||
15453                     visitNodes(cbNode, cbNodes, node.children) ||
15454                     visitNode(cbNode, node.closingFragment);
15455             case 267:
15456             case 268:
15457                 return visitNode(cbNode, node.tagName) ||
15458                     visitNodes(cbNode, cbNodes, node.typeArguments) ||
15459                     visitNode(cbNode, node.attributes);
15460             case 274:
15461                 return visitNodes(cbNode, cbNodes, node.properties);
15462             case 273:
15463                 return visitNode(cbNode, node.name) ||
15464                     visitNode(cbNode, node.initializer);
15465             case 275:
15466                 return visitNode(cbNode, node.expression);
15467             case 276:
15468                 return visitNode(cbNode, node.dotDotDotToken) ||
15469                     visitNode(cbNode, node.expression);
15470             case 269:
15471                 return visitNode(cbNode, node.tagName);
15472             case 176:
15473             case 177:
15474             case 294:
15475             case 298:
15476             case 297:
15477             case 299:
15478             case 301:
15479                 return visitNode(cbNode, node.type);
15480             case 300:
15481                 return visitNodes(cbNode, cbNodes, node.parameters) ||
15482                     visitNode(cbNode, node.type);
15483             case 303:
15484                 return visitNodes(cbNode, cbNodes, node.tags);
15485             case 317:
15486             case 323:
15487                 return visitNode(cbNode, node.tagName) ||
15488                     (node.isNameFirst
15489                         ? visitNode(cbNode, node.name) ||
15490                             visitNode(cbNode, node.typeExpression)
15491                         : visitNode(cbNode, node.typeExpression) ||
15492                             visitNode(cbNode, node.name));
15493             case 309:
15494                 return visitNode(cbNode, node.tagName);
15495             case 308:
15496                 return visitNode(cbNode, node.tagName) ||
15497                     visitNode(cbNode, node.class);
15498             case 307:
15499                 return visitNode(cbNode, node.tagName) ||
15500                     visitNode(cbNode, node.class);
15501             case 321:
15502                 return visitNode(cbNode, node.tagName) ||
15503                     visitNode(cbNode, node.constraint) ||
15504                     visitNodes(cbNode, cbNodes, node.typeParameters);
15505             case 322:
15506                 return visitNode(cbNode, node.tagName) ||
15507                     (node.typeExpression &&
15508                         node.typeExpression.kind === 294
15509                         ? visitNode(cbNode, node.typeExpression) ||
15510                             visitNode(cbNode, node.fullName)
15511                         : visitNode(cbNode, node.fullName) ||
15512                             visitNode(cbNode, node.typeExpression));
15513             case 315:
15514                 return visitNode(cbNode, node.tagName) ||
15515                     visitNode(cbNode, node.fullName) ||
15516                     visitNode(cbNode, node.typeExpression);
15517             case 318:
15518             case 320:
15519             case 319:
15520             case 316:
15521                 return visitNode(cbNode, node.tagName) ||
15522                     visitNode(cbNode, node.typeExpression);
15523             case 305:
15524                 return ts.forEach(node.typeParameters, cbNode) ||
15525                     ts.forEach(node.parameters, cbNode) ||
15526                     visitNode(cbNode, node.type);
15527             case 304:
15528                 return ts.forEach(node.jsDocPropertyTags, cbNode);
15529             case 306:
15530             case 310:
15531             case 311:
15532             case 312:
15533             case 313:
15534             case 314:
15535                 return visitNode(cbNode, node.tagName);
15536             case 326:
15537                 return visitNode(cbNode, node.expression);
15538         }
15539     }
15540     ts.forEachChild = forEachChild;
15541     function forEachChildRecursively(rootNode, cbNode, cbNodes) {
15542         var stack = [rootNode];
15543         while (stack.length) {
15544             var parent = stack.pop();
15545             var res = visitAllPossibleChildren(parent, gatherPossibleChildren(parent));
15546             if (res) {
15547                 return res;
15548             }
15549         }
15550         return;
15551         function gatherPossibleChildren(node) {
15552             var children = [];
15553             forEachChild(node, addWorkItem, addWorkItem);
15554             return children;
15555             function addWorkItem(n) {
15556                 children.unshift(n);
15557             }
15558         }
15559         function visitAllPossibleChildren(parent, children) {
15560             for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
15561                 var child = children_1[_i];
15562                 if (ts.isArray(child)) {
15563                     if (cbNodes) {
15564                         var res = cbNodes(child, parent);
15565                         if (res) {
15566                             if (res === "skip")
15567                                 continue;
15568                             return res;
15569                         }
15570                     }
15571                     for (var i = child.length - 1; i >= 0; i--) {
15572                         var realChild = child[i];
15573                         var res = cbNode(realChild, parent);
15574                         if (res) {
15575                             if (res === "skip")
15576                                 continue;
15577                             return res;
15578                         }
15579                         stack.push(realChild);
15580                     }
15581                 }
15582                 else {
15583                     stack.push(child);
15584                     var res = cbNode(child, parent);
15585                     if (res) {
15586                         if (res === "skip")
15587                             continue;
15588                         return res;
15589                     }
15590                 }
15591             }
15592         }
15593     }
15594     ts.forEachChildRecursively = forEachChildRecursively;
15595     function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) {
15596         if (setParentNodes === void 0) { setParentNodes = false; }
15597         ts.performance.mark("beforeParse");
15598         var result;
15599         ts.perfLogger.logStartParseSourceFile(fileName);
15600         if (languageVersion === 100) {
15601             result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes, 6);
15602         }
15603         else {
15604             result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes, scriptKind);
15605         }
15606         ts.perfLogger.logStopParseSourceFile();
15607         ts.performance.mark("afterParse");
15608         ts.performance.measure("Parse", "beforeParse", "afterParse");
15609         return result;
15610     }
15611     ts.createSourceFile = createSourceFile;
15612     function parseIsolatedEntityName(text, languageVersion) {
15613         return Parser.parseIsolatedEntityName(text, languageVersion);
15614     }
15615     ts.parseIsolatedEntityName = parseIsolatedEntityName;
15616     function parseJsonText(fileName, sourceText) {
15617         return Parser.parseJsonText(fileName, sourceText);
15618     }
15619     ts.parseJsonText = parseJsonText;
15620     function isExternalModule(file) {
15621         return file.externalModuleIndicator !== undefined;
15622     }
15623     ts.isExternalModule = isExternalModule;
15624     function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) {
15625         if (aggressiveChecks === void 0) { aggressiveChecks = false; }
15626         var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
15627         newSourceFile.flags |= (sourceFile.flags & 3145728);
15628         return newSourceFile;
15629     }
15630     ts.updateSourceFile = updateSourceFile;
15631     function parseIsolatedJSDocComment(content, start, length) {
15632         var result = Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length);
15633         if (result && result.jsDoc) {
15634             Parser.fixupParentReferences(result.jsDoc);
15635         }
15636         return result;
15637     }
15638     ts.parseIsolatedJSDocComment = parseIsolatedJSDocComment;
15639     function parseJSDocTypeExpressionForTests(content, start, length) {
15640         return Parser.JSDocParser.parseJSDocTypeExpressionForTests(content, start, length);
15641     }
15642     ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests;
15643     var Parser;
15644     (function (Parser) {
15645         var scanner = ts.createScanner(99, true);
15646         var disallowInAndDecoratorContext = 4096 | 16384;
15647         var NodeConstructor;
15648         var TokenConstructor;
15649         var IdentifierConstructor;
15650         var PrivateIdentifierConstructor;
15651         var SourceFileConstructor;
15652         var sourceFile;
15653         var parseDiagnostics;
15654         var syntaxCursor;
15655         var currentToken;
15656         var sourceText;
15657         var nodeCount;
15658         var identifiers;
15659         var privateIdentifiers;
15660         var identifierCount;
15661         var parsingContext;
15662         var notParenthesizedArrow;
15663         var contextFlags;
15664         var parseErrorBeforeNextFinishedNode = false;
15665         function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) {
15666             if (setParentNodes === void 0) { setParentNodes = false; }
15667             scriptKind = ts.ensureScriptKind(fileName, scriptKind);
15668             if (scriptKind === 6) {
15669                 var result_2 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes);
15670                 ts.convertToObjectWorker(result_2, result_2.parseDiagnostics, false, undefined, undefined);
15671                 result_2.referencedFiles = ts.emptyArray;
15672                 result_2.typeReferenceDirectives = ts.emptyArray;
15673                 result_2.libReferenceDirectives = ts.emptyArray;
15674                 result_2.amdDependencies = ts.emptyArray;
15675                 result_2.hasNoDefaultLib = false;
15676                 result_2.pragmas = ts.emptyMap;
15677                 return result_2;
15678             }
15679             initializeState(sourceText, languageVersion, syntaxCursor, scriptKind);
15680             var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind);
15681             clearState();
15682             return result;
15683         }
15684         Parser.parseSourceFile = parseSourceFile;
15685         function parseIsolatedEntityName(content, languageVersion) {
15686             initializeState(content, languageVersion, undefined, 1);
15687             nextToken();
15688             var entityName = parseEntityName(true);
15689             var isInvalid = token() === 1 && !parseDiagnostics.length;
15690             clearState();
15691             return isInvalid ? entityName : undefined;
15692         }
15693         Parser.parseIsolatedEntityName = parseIsolatedEntityName;
15694         function parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes) {
15695             if (languageVersion === void 0) { languageVersion = 2; }
15696             initializeState(sourceText, languageVersion, syntaxCursor, 6);
15697             sourceFile = createSourceFile(fileName, 2, 6, false);
15698             sourceFile.flags = contextFlags;
15699             nextToken();
15700             var pos = getNodePos();
15701             if (token() === 1) {
15702                 sourceFile.statements = createNodeArray([], pos, pos);
15703                 sourceFile.endOfFileToken = parseTokenNode();
15704             }
15705             else {
15706                 var statement = createNode(226);
15707                 switch (token()) {
15708                     case 22:
15709                         statement.expression = parseArrayLiteralExpression();
15710                         break;
15711                     case 106:
15712                     case 91:
15713                     case 100:
15714                         statement.expression = parseTokenNode();
15715                         break;
15716                     case 40:
15717                         if (lookAhead(function () { return nextToken() === 8 && nextToken() !== 58; })) {
15718                             statement.expression = parsePrefixUnaryExpression();
15719                         }
15720                         else {
15721                             statement.expression = parseObjectLiteralExpression();
15722                         }
15723                         break;
15724                     case 8:
15725                     case 10:
15726                         if (lookAhead(function () { return nextToken() !== 58; })) {
15727                             statement.expression = parseLiteralNode();
15728                             break;
15729                         }
15730                     default:
15731                         statement.expression = parseObjectLiteralExpression();
15732                         break;
15733                 }
15734                 finishNode(statement);
15735                 sourceFile.statements = createNodeArray([statement], pos);
15736                 sourceFile.endOfFileToken = parseExpectedToken(1, ts.Diagnostics.Unexpected_token);
15737             }
15738             if (setParentNodes) {
15739                 fixupParentReferences(sourceFile);
15740             }
15741             sourceFile.nodeCount = nodeCount;
15742             sourceFile.identifierCount = identifierCount;
15743             sourceFile.identifiers = identifiers;
15744             sourceFile.parseDiagnostics = parseDiagnostics;
15745             var result = sourceFile;
15746             clearState();
15747             return result;
15748         }
15749         Parser.parseJsonText = parseJsonText;
15750         function getLanguageVariant(scriptKind) {
15751             return scriptKind === 4 || scriptKind === 2 || scriptKind === 1 || scriptKind === 6 ? 1 : 0;
15752         }
15753         function initializeState(_sourceText, languageVersion, _syntaxCursor, scriptKind) {
15754             NodeConstructor = ts.objectAllocator.getNodeConstructor();
15755             TokenConstructor = ts.objectAllocator.getTokenConstructor();
15756             IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor();
15757             PrivateIdentifierConstructor = ts.objectAllocator.getPrivateIdentifierConstructor();
15758             SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor();
15759             sourceText = _sourceText;
15760             syntaxCursor = _syntaxCursor;
15761             parseDiagnostics = [];
15762             parsingContext = 0;
15763             identifiers = ts.createMap();
15764             privateIdentifiers = ts.createMap();
15765             identifierCount = 0;
15766             nodeCount = 0;
15767             switch (scriptKind) {
15768                 case 1:
15769                 case 2:
15770                     contextFlags = 131072;
15771                     break;
15772                 case 6:
15773                     contextFlags = 131072 | 33554432;
15774                     break;
15775                 default:
15776                     contextFlags = 0;
15777                     break;
15778             }
15779             parseErrorBeforeNextFinishedNode = false;
15780             scanner.setText(sourceText);
15781             scanner.setOnError(scanError);
15782             scanner.setScriptTarget(languageVersion);
15783             scanner.setLanguageVariant(getLanguageVariant(scriptKind));
15784         }
15785         function clearState() {
15786             scanner.clearCommentDirectives();
15787             scanner.setText("");
15788             scanner.setOnError(undefined);
15789             parseDiagnostics = undefined;
15790             sourceFile = undefined;
15791             identifiers = undefined;
15792             syntaxCursor = undefined;
15793             sourceText = undefined;
15794             notParenthesizedArrow = undefined;
15795         }
15796         function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) {
15797             var isDeclarationFile = isDeclarationFileName(fileName);
15798             if (isDeclarationFile) {
15799                 contextFlags |= 8388608;
15800             }
15801             sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile);
15802             sourceFile.flags = contextFlags;
15803             nextToken();
15804             processCommentPragmas(sourceFile, sourceText);
15805             processPragmasIntoFields(sourceFile, reportPragmaDiagnostic);
15806             sourceFile.statements = parseList(0, parseStatement);
15807             ts.Debug.assert(token() === 1);
15808             sourceFile.endOfFileToken = addJSDocComment(parseTokenNode());
15809             setExternalModuleIndicator(sourceFile);
15810             sourceFile.commentDirectives = scanner.getCommentDirectives();
15811             sourceFile.nodeCount = nodeCount;
15812             sourceFile.identifierCount = identifierCount;
15813             sourceFile.identifiers = identifiers;
15814             sourceFile.parseDiagnostics = parseDiagnostics;
15815             if (setParentNodes) {
15816                 fixupParentReferences(sourceFile);
15817             }
15818             return sourceFile;
15819             function reportPragmaDiagnostic(pos, end, diagnostic) {
15820                 parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, pos, end, diagnostic));
15821             }
15822         }
15823         function addJSDocComment(node) {
15824             ts.Debug.assert(!node.jsDoc);
15825             var jsDoc = ts.mapDefined(ts.getJSDocCommentRanges(node, sourceFile.text), function (comment) { return JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); });
15826             if (jsDoc.length)
15827                 node.jsDoc = jsDoc;
15828             return node;
15829         }
15830         function fixupParentReferences(rootNode) {
15831             forEachChildRecursively(rootNode, bindParentToChild);
15832             function bindParentToChild(child, parent) {
15833                 child.parent = parent;
15834                 if (ts.hasJSDocNodes(child)) {
15835                     for (var _i = 0, _a = child.jsDoc; _i < _a.length; _i++) {
15836                         var doc = _a[_i];
15837                         bindParentToChild(doc, child);
15838                         forEachChildRecursively(doc, bindParentToChild);
15839                     }
15840                 }
15841             }
15842         }
15843         Parser.fixupParentReferences = fixupParentReferences;
15844         function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) {
15845             var sourceFile = new SourceFileConstructor(290, 0, sourceText.length);
15846             nodeCount++;
15847             sourceFile.text = sourceText;
15848             sourceFile.bindDiagnostics = [];
15849             sourceFile.bindSuggestionDiagnostics = undefined;
15850             sourceFile.languageVersion = languageVersion;
15851             sourceFile.fileName = ts.normalizePath(fileName);
15852             sourceFile.languageVariant = getLanguageVariant(scriptKind);
15853             sourceFile.isDeclarationFile = isDeclarationFile;
15854             sourceFile.scriptKind = scriptKind;
15855             return sourceFile;
15856         }
15857         function setContextFlag(val, flag) {
15858             if (val) {
15859                 contextFlags |= flag;
15860             }
15861             else {
15862                 contextFlags &= ~flag;
15863             }
15864         }
15865         function setDisallowInContext(val) {
15866             setContextFlag(val, 4096);
15867         }
15868         function setYieldContext(val) {
15869             setContextFlag(val, 8192);
15870         }
15871         function setDecoratorContext(val) {
15872             setContextFlag(val, 16384);
15873         }
15874         function setAwaitContext(val) {
15875             setContextFlag(val, 32768);
15876         }
15877         function doOutsideOfContext(context, func) {
15878             var contextFlagsToClear = context & contextFlags;
15879             if (contextFlagsToClear) {
15880                 setContextFlag(false, contextFlagsToClear);
15881                 var result = func();
15882                 setContextFlag(true, contextFlagsToClear);
15883                 return result;
15884             }
15885             return func();
15886         }
15887         function doInsideOfContext(context, func) {
15888             var contextFlagsToSet = context & ~contextFlags;
15889             if (contextFlagsToSet) {
15890                 setContextFlag(true, contextFlagsToSet);
15891                 var result = func();
15892                 setContextFlag(false, contextFlagsToSet);
15893                 return result;
15894             }
15895             return func();
15896         }
15897         function allowInAnd(func) {
15898             return doOutsideOfContext(4096, func);
15899         }
15900         function disallowInAnd(func) {
15901             return doInsideOfContext(4096, func);
15902         }
15903         function doInYieldContext(func) {
15904             return doInsideOfContext(8192, func);
15905         }
15906         function doInDecoratorContext(func) {
15907             return doInsideOfContext(16384, func);
15908         }
15909         function doInAwaitContext(func) {
15910             return doInsideOfContext(32768, func);
15911         }
15912         function doOutsideOfAwaitContext(func) {
15913             return doOutsideOfContext(32768, func);
15914         }
15915         function doInYieldAndAwaitContext(func) {
15916             return doInsideOfContext(8192 | 32768, func);
15917         }
15918         function doOutsideOfYieldAndAwaitContext(func) {
15919             return doOutsideOfContext(8192 | 32768, func);
15920         }
15921         function inContext(flags) {
15922             return (contextFlags & flags) !== 0;
15923         }
15924         function inYieldContext() {
15925             return inContext(8192);
15926         }
15927         function inDisallowInContext() {
15928             return inContext(4096);
15929         }
15930         function inDecoratorContext() {
15931             return inContext(16384);
15932         }
15933         function inAwaitContext() {
15934             return inContext(32768);
15935         }
15936         function parseErrorAtCurrentToken(message, arg0) {
15937             parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
15938         }
15939         function parseErrorAtPosition(start, length, message, arg0) {
15940             var lastError = ts.lastOrUndefined(parseDiagnostics);
15941             if (!lastError || start !== lastError.start) {
15942                 parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, start, length, message, arg0));
15943             }
15944             parseErrorBeforeNextFinishedNode = true;
15945         }
15946         function parseErrorAt(start, end, message, arg0) {
15947             parseErrorAtPosition(start, end - start, message, arg0);
15948         }
15949         function parseErrorAtRange(range, message, arg0) {
15950             parseErrorAt(range.pos, range.end, message, arg0);
15951         }
15952         function scanError(message, length) {
15953             parseErrorAtPosition(scanner.getTextPos(), length, message);
15954         }
15955         function getNodePos() {
15956             return scanner.getStartPos();
15957         }
15958         function token() {
15959             return currentToken;
15960         }
15961         function nextTokenWithoutCheck() {
15962             return currentToken = scanner.scan();
15963         }
15964         function nextToken() {
15965             if (ts.isKeyword(currentToken) && (scanner.hasUnicodeEscape() || scanner.hasExtendedUnicodeEscape())) {
15966                 parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), ts.Diagnostics.Keywords_cannot_contain_escape_characters);
15967             }
15968             return nextTokenWithoutCheck();
15969         }
15970         function nextTokenJSDoc() {
15971             return currentToken = scanner.scanJsDocToken();
15972         }
15973         function reScanGreaterToken() {
15974             return currentToken = scanner.reScanGreaterToken();
15975         }
15976         function reScanSlashToken() {
15977             return currentToken = scanner.reScanSlashToken();
15978         }
15979         function reScanTemplateToken(isTaggedTemplate) {
15980             return currentToken = scanner.reScanTemplateToken(isTaggedTemplate);
15981         }
15982         function reScanTemplateHeadOrNoSubstitutionTemplate() {
15983             return currentToken = scanner.reScanTemplateHeadOrNoSubstitutionTemplate();
15984         }
15985         function reScanLessThanToken() {
15986             return currentToken = scanner.reScanLessThanToken();
15987         }
15988         function scanJsxIdentifier() {
15989             return currentToken = scanner.scanJsxIdentifier();
15990         }
15991         function scanJsxText() {
15992             return currentToken = scanner.scanJsxToken();
15993         }
15994         function scanJsxAttributeValue() {
15995             return currentToken = scanner.scanJsxAttributeValue();
15996         }
15997         function speculationHelper(callback, isLookAhead) {
15998             var saveToken = currentToken;
15999             var saveParseDiagnosticsLength = parseDiagnostics.length;
16000             var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
16001             var saveContextFlags = contextFlags;
16002             var result = isLookAhead
16003                 ? scanner.lookAhead(callback)
16004                 : scanner.tryScan(callback);
16005             ts.Debug.assert(saveContextFlags === contextFlags);
16006             if (!result || isLookAhead) {
16007                 currentToken = saveToken;
16008                 parseDiagnostics.length = saveParseDiagnosticsLength;
16009                 parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode;
16010             }
16011             return result;
16012         }
16013         function lookAhead(callback) {
16014             return speculationHelper(callback, true);
16015         }
16016         function tryParse(callback) {
16017             return speculationHelper(callback, false);
16018         }
16019         function isIdentifier() {
16020             if (token() === 75) {
16021                 return true;
16022             }
16023             if (token() === 121 && inYieldContext()) {
16024                 return false;
16025             }
16026             if (token() === 127 && inAwaitContext()) {
16027                 return false;
16028             }
16029             return token() > 112;
16030         }
16031         function parseExpected(kind, diagnosticMessage, shouldAdvance) {
16032             if (shouldAdvance === void 0) { shouldAdvance = true; }
16033             if (token() === kind) {
16034                 if (shouldAdvance) {
16035                     nextToken();
16036                 }
16037                 return true;
16038             }
16039             if (diagnosticMessage) {
16040                 parseErrorAtCurrentToken(diagnosticMessage);
16041             }
16042             else {
16043                 parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind));
16044             }
16045             return false;
16046         }
16047         function parseExpectedJSDoc(kind) {
16048             if (token() === kind) {
16049                 nextTokenJSDoc();
16050                 return true;
16051             }
16052             parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind));
16053             return false;
16054         }
16055         function parseOptional(t) {
16056             if (token() === t) {
16057                 nextToken();
16058                 return true;
16059             }
16060             return false;
16061         }
16062         function parseOptionalToken(t) {
16063             if (token() === t) {
16064                 return parseTokenNode();
16065             }
16066             return undefined;
16067         }
16068         function parseOptionalTokenJSDoc(t) {
16069             if (token() === t) {
16070                 return parseTokenNodeJSDoc();
16071             }
16072             return undefined;
16073         }
16074         function parseExpectedToken(t, diagnosticMessage, arg0) {
16075             return parseOptionalToken(t) ||
16076                 createMissingNode(t, false, diagnosticMessage || ts.Diagnostics._0_expected, arg0 || ts.tokenToString(t));
16077         }
16078         function parseExpectedTokenJSDoc(t) {
16079             return parseOptionalTokenJSDoc(t) ||
16080                 createMissingNode(t, false, ts.Diagnostics._0_expected, ts.tokenToString(t));
16081         }
16082         function parseTokenNode() {
16083             var node = createNode(token());
16084             nextToken();
16085             return finishNode(node);
16086         }
16087         function parseTokenNodeJSDoc() {
16088             var node = createNode(token());
16089             nextTokenJSDoc();
16090             return finishNode(node);
16091         }
16092         function canParseSemicolon() {
16093             if (token() === 26) {
16094                 return true;
16095             }
16096             return token() === 19 || token() === 1 || scanner.hasPrecedingLineBreak();
16097         }
16098         function parseSemicolon() {
16099             if (canParseSemicolon()) {
16100                 if (token() === 26) {
16101                     nextToken();
16102                 }
16103                 return true;
16104             }
16105             else {
16106                 return parseExpected(26);
16107             }
16108         }
16109         function createNode(kind, pos) {
16110             nodeCount++;
16111             var p = pos >= 0 ? pos : scanner.getStartPos();
16112             return ts.isNodeKind(kind) || kind === 0 ? new NodeConstructor(kind, p, p) :
16113                 kind === 75 ? new IdentifierConstructor(kind, p, p) :
16114                     kind === 76 ? new PrivateIdentifierConstructor(kind, p, p) :
16115                         new TokenConstructor(kind, p, p);
16116         }
16117         function createNodeWithJSDoc(kind, pos) {
16118             var node = createNode(kind, pos);
16119             if (scanner.getTokenFlags() & 2 && (kind !== 226 || token() !== 20)) {
16120                 addJSDocComment(node);
16121             }
16122             return node;
16123         }
16124         function createNodeArray(elements, pos, end) {
16125             var length = elements.length;
16126             var array = (length >= 1 && length <= 4 ? elements.slice() : elements);
16127             array.pos = pos;
16128             array.end = end === undefined ? scanner.getStartPos() : end;
16129             return array;
16130         }
16131         function finishNode(node, end) {
16132             node.end = end === undefined ? scanner.getStartPos() : end;
16133             if (contextFlags) {
16134                 node.flags |= contextFlags;
16135             }
16136             if (parseErrorBeforeNextFinishedNode) {
16137                 parseErrorBeforeNextFinishedNode = false;
16138                 node.flags |= 65536;
16139             }
16140             return node;
16141         }
16142         function createMissingNode(kind, reportAtCurrentPosition, diagnosticMessage, arg0) {
16143             if (reportAtCurrentPosition) {
16144                 parseErrorAtPosition(scanner.getStartPos(), 0, diagnosticMessage, arg0);
16145             }
16146             else if (diagnosticMessage) {
16147                 parseErrorAtCurrentToken(diagnosticMessage, arg0);
16148             }
16149             var result = createNode(kind);
16150             if (kind === 75) {
16151                 result.escapedText = "";
16152             }
16153             else if (ts.isLiteralKind(kind) || ts.isTemplateLiteralKind(kind)) {
16154                 result.text = "";
16155             }
16156             return finishNode(result);
16157         }
16158         function internIdentifier(text) {
16159             var identifier = identifiers.get(text);
16160             if (identifier === undefined) {
16161                 identifiers.set(text, identifier = text);
16162             }
16163             return identifier;
16164         }
16165         function createIdentifier(isIdentifier, diagnosticMessage, privateIdentifierDiagnosticMessage) {
16166             identifierCount++;
16167             if (isIdentifier) {
16168                 var node = createNode(75);
16169                 if (token() !== 75) {
16170                     node.originalKeywordKind = token();
16171                 }
16172                 node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue()));
16173                 nextTokenWithoutCheck();
16174                 return finishNode(node);
16175             }
16176             if (token() === 76) {
16177                 parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
16178                 return createIdentifier(true);
16179             }
16180             var reportAtCurrentPosition = token() === 1;
16181             var isReservedWord = scanner.isReservedWord();
16182             var msgArg = scanner.getTokenText();
16183             var defaultMessage = isReservedWord ?
16184                 ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here :
16185                 ts.Diagnostics.Identifier_expected;
16186             return createMissingNode(75, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg);
16187         }
16188         function parseIdentifier(diagnosticMessage, privateIdentifierDiagnosticMessage) {
16189             return createIdentifier(isIdentifier(), diagnosticMessage, privateIdentifierDiagnosticMessage);
16190         }
16191         function parseIdentifierName(diagnosticMessage) {
16192             return createIdentifier(ts.tokenIsIdentifierOrKeyword(token()), diagnosticMessage);
16193         }
16194         function isLiteralPropertyName() {
16195             return ts.tokenIsIdentifierOrKeyword(token()) ||
16196                 token() === 10 ||
16197                 token() === 8;
16198         }
16199         function parsePropertyNameWorker(allowComputedPropertyNames) {
16200             if (token() === 10 || token() === 8) {
16201                 var node = parseLiteralNode();
16202                 node.text = internIdentifier(node.text);
16203                 return node;
16204             }
16205             if (allowComputedPropertyNames && token() === 22) {
16206                 return parseComputedPropertyName();
16207             }
16208             if (token() === 76) {
16209                 return parsePrivateIdentifier();
16210             }
16211             return parseIdentifierName();
16212         }
16213         function parsePropertyName() {
16214             return parsePropertyNameWorker(true);
16215         }
16216         function parseComputedPropertyName() {
16217             var node = createNode(154);
16218             parseExpected(22);
16219             node.expression = allowInAnd(parseExpression);
16220             parseExpected(23);
16221             return finishNode(node);
16222         }
16223         function internPrivateIdentifier(text) {
16224             var privateIdentifier = privateIdentifiers.get(text);
16225             if (privateIdentifier === undefined) {
16226                 privateIdentifiers.set(text, privateIdentifier = text);
16227             }
16228             return privateIdentifier;
16229         }
16230         function parsePrivateIdentifier() {
16231             var node = createNode(76);
16232             node.escapedText = ts.escapeLeadingUnderscores(internPrivateIdentifier(scanner.getTokenText()));
16233             nextToken();
16234             return finishNode(node);
16235         }
16236         function parseContextualModifier(t) {
16237             return token() === t && tryParse(nextTokenCanFollowModifier);
16238         }
16239         function nextTokenIsOnSameLineAndCanFollowModifier() {
16240             nextToken();
16241             if (scanner.hasPrecedingLineBreak()) {
16242                 return false;
16243             }
16244             return canFollowModifier();
16245         }
16246         function nextTokenCanFollowModifier() {
16247             switch (token()) {
16248                 case 81:
16249                     return nextToken() === 88;
16250                 case 89:
16251                     nextToken();
16252                     if (token() === 84) {
16253                         return lookAhead(nextTokenCanFollowDefaultKeyword);
16254                     }
16255                     if (token() === 145) {
16256                         return lookAhead(nextTokenCanFollowExportModifier);
16257                     }
16258                     return canFollowExportModifier();
16259                 case 84:
16260                     return nextTokenCanFollowDefaultKeyword();
16261                 case 120:
16262                 case 131:
16263                 case 142:
16264                     nextToken();
16265                     return canFollowModifier();
16266                 default:
16267                     return nextTokenIsOnSameLineAndCanFollowModifier();
16268             }
16269         }
16270         function canFollowExportModifier() {
16271             return token() !== 41
16272                 && token() !== 123
16273                 && token() !== 18
16274                 && canFollowModifier();
16275         }
16276         function nextTokenCanFollowExportModifier() {
16277             nextToken();
16278             return canFollowExportModifier();
16279         }
16280         function parseAnyContextualModifier() {
16281             return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier);
16282         }
16283         function canFollowModifier() {
16284             return token() === 22
16285                 || token() === 18
16286                 || token() === 41
16287                 || token() === 25
16288                 || isLiteralPropertyName();
16289         }
16290         function nextTokenCanFollowDefaultKeyword() {
16291             nextToken();
16292             return token() === 80 || token() === 94 ||
16293                 token() === 114 ||
16294                 (token() === 122 && lookAhead(nextTokenIsClassKeywordOnSameLine)) ||
16295                 (token() === 126 && lookAhead(nextTokenIsFunctionKeywordOnSameLine));
16296         }
16297         function isListElement(parsingContext, inErrorRecovery) {
16298             var node = currentNode(parsingContext);
16299             if (node) {
16300                 return true;
16301             }
16302             switch (parsingContext) {
16303                 case 0:
16304                 case 1:
16305                 case 3:
16306                     return !(token() === 26 && inErrorRecovery) && isStartOfStatement();
16307                 case 2:
16308                     return token() === 78 || token() === 84;
16309                 case 4:
16310                     return lookAhead(isTypeMemberStart);
16311                 case 5:
16312                     return lookAhead(isClassMemberStart) || (token() === 26 && !inErrorRecovery);
16313                 case 6:
16314                     return token() === 22 || isLiteralPropertyName();
16315                 case 12:
16316                     switch (token()) {
16317                         case 22:
16318                         case 41:
16319                         case 25:
16320                         case 24:
16321                             return true;
16322                         default:
16323                             return isLiteralPropertyName();
16324                     }
16325                 case 18:
16326                     return isLiteralPropertyName();
16327                 case 9:
16328                     return token() === 22 || token() === 25 || isLiteralPropertyName();
16329                 case 7:
16330                     if (token() === 18) {
16331                         return lookAhead(isValidHeritageClauseObjectLiteral);
16332                     }
16333                     if (!inErrorRecovery) {
16334                         return isStartOfLeftHandSideExpression() && !isHeritageClauseExtendsOrImplementsKeyword();
16335                     }
16336                     else {
16337                         return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword();
16338                     }
16339                 case 8:
16340                     return isIdentifierOrPrivateIdentifierOrPattern();
16341                 case 10:
16342                     return token() === 27 || token() === 25 || isIdentifierOrPrivateIdentifierOrPattern();
16343                 case 19:
16344                     return isIdentifier();
16345                 case 15:
16346                     switch (token()) {
16347                         case 27:
16348                         case 24:
16349                             return true;
16350                     }
16351                 case 11:
16352                     return token() === 25 || isStartOfExpression();
16353                 case 16:
16354                     return isStartOfParameter(false);
16355                 case 17:
16356                     return isStartOfParameter(true);
16357                 case 20:
16358                 case 21:
16359                     return token() === 27 || isStartOfType();
16360                 case 22:
16361                     return isHeritageClause();
16362                 case 23:
16363                     return ts.tokenIsIdentifierOrKeyword(token());
16364                 case 13:
16365                     return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18;
16366                 case 14:
16367                     return true;
16368             }
16369             return ts.Debug.fail("Non-exhaustive case in 'isListElement'.");
16370         }
16371         function isValidHeritageClauseObjectLiteral() {
16372             ts.Debug.assert(token() === 18);
16373             if (nextToken() === 19) {
16374                 var next = nextToken();
16375                 return next === 27 || next === 18 || next === 90 || next === 113;
16376             }
16377             return true;
16378         }
16379         function nextTokenIsIdentifier() {
16380             nextToken();
16381             return isIdentifier();
16382         }
16383         function nextTokenIsIdentifierOrKeyword() {
16384             nextToken();
16385             return ts.tokenIsIdentifierOrKeyword(token());
16386         }
16387         function nextTokenIsIdentifierOrKeywordOrGreaterThan() {
16388             nextToken();
16389             return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token());
16390         }
16391         function isHeritageClauseExtendsOrImplementsKeyword() {
16392             if (token() === 113 ||
16393                 token() === 90) {
16394                 return lookAhead(nextTokenIsStartOfExpression);
16395             }
16396             return false;
16397         }
16398         function nextTokenIsStartOfExpression() {
16399             nextToken();
16400             return isStartOfExpression();
16401         }
16402         function nextTokenIsStartOfType() {
16403             nextToken();
16404             return isStartOfType();
16405         }
16406         function isListTerminator(kind) {
16407             if (token() === 1) {
16408                 return true;
16409             }
16410             switch (kind) {
16411                 case 1:
16412                 case 2:
16413                 case 4:
16414                 case 5:
16415                 case 6:
16416                 case 12:
16417                 case 9:
16418                 case 23:
16419                     return token() === 19;
16420                 case 3:
16421                     return token() === 19 || token() === 78 || token() === 84;
16422                 case 7:
16423                     return token() === 18 || token() === 90 || token() === 113;
16424                 case 8:
16425                     return isVariableDeclaratorListTerminator();
16426                 case 19:
16427                     return token() === 31 || token() === 20 || token() === 18 || token() === 90 || token() === 113;
16428                 case 11:
16429                     return token() === 21 || token() === 26;
16430                 case 15:
16431                 case 21:
16432                 case 10:
16433                     return token() === 23;
16434                 case 17:
16435                 case 16:
16436                 case 18:
16437                     return token() === 21 || token() === 23;
16438                 case 20:
16439                     return token() !== 27;
16440                 case 22:
16441                     return token() === 18 || token() === 19;
16442                 case 13:
16443                     return token() === 31 || token() === 43;
16444                 case 14:
16445                     return token() === 29 && lookAhead(nextTokenIsSlash);
16446                 default:
16447                     return false;
16448             }
16449         }
16450         function isVariableDeclaratorListTerminator() {
16451             if (canParseSemicolon()) {
16452                 return true;
16453             }
16454             if (isInOrOfKeyword(token())) {
16455                 return true;
16456             }
16457             if (token() === 38) {
16458                 return true;
16459             }
16460             return false;
16461         }
16462         function isInSomeParsingContext() {
16463             for (var kind = 0; kind < 24; kind++) {
16464                 if (parsingContext & (1 << kind)) {
16465                     if (isListElement(kind, true) || isListTerminator(kind)) {
16466                         return true;
16467                     }
16468                 }
16469             }
16470             return false;
16471         }
16472         function parseList(kind, parseElement) {
16473             var saveParsingContext = parsingContext;
16474             parsingContext |= 1 << kind;
16475             var list = [];
16476             var listPos = getNodePos();
16477             while (!isListTerminator(kind)) {
16478                 if (isListElement(kind, false)) {
16479                     var element = parseListElement(kind, parseElement);
16480                     list.push(element);
16481                     continue;
16482                 }
16483                 if (abortParsingListOrMoveToNextToken(kind)) {
16484                     break;
16485                 }
16486             }
16487             parsingContext = saveParsingContext;
16488             return createNodeArray(list, listPos);
16489         }
16490         function parseListElement(parsingContext, parseElement) {
16491             var node = currentNode(parsingContext);
16492             if (node) {
16493                 return consumeNode(node);
16494             }
16495             return parseElement();
16496         }
16497         function currentNode(parsingContext) {
16498             if (!syntaxCursor || !isReusableParsingContext(parsingContext) || parseErrorBeforeNextFinishedNode) {
16499                 return undefined;
16500             }
16501             var node = syntaxCursor.currentNode(scanner.getStartPos());
16502             if (ts.nodeIsMissing(node) || node.intersectsChange || ts.containsParseError(node)) {
16503                 return undefined;
16504             }
16505             var nodeContextFlags = node.flags & 25358336;
16506             if (nodeContextFlags !== contextFlags) {
16507                 return undefined;
16508             }
16509             if (!canReuseNode(node, parsingContext)) {
16510                 return undefined;
16511             }
16512             if (node.jsDocCache) {
16513                 node.jsDocCache = undefined;
16514             }
16515             return node;
16516         }
16517         function consumeNode(node) {
16518             scanner.setTextPos(node.end);
16519             nextToken();
16520             return node;
16521         }
16522         function isReusableParsingContext(parsingContext) {
16523             switch (parsingContext) {
16524                 case 5:
16525                 case 2:
16526                 case 0:
16527                 case 1:
16528                 case 3:
16529                 case 6:
16530                 case 4:
16531                 case 8:
16532                 case 17:
16533                 case 16:
16534                     return true;
16535             }
16536             return false;
16537         }
16538         function canReuseNode(node, parsingContext) {
16539             switch (parsingContext) {
16540                 case 5:
16541                     return isReusableClassMember(node);
16542                 case 2:
16543                     return isReusableSwitchClause(node);
16544                 case 0:
16545                 case 1:
16546                 case 3:
16547                     return isReusableStatement(node);
16548                 case 6:
16549                     return isReusableEnumMember(node);
16550                 case 4:
16551                     return isReusableTypeMember(node);
16552                 case 8:
16553                     return isReusableVariableDeclaration(node);
16554                 case 17:
16555                 case 16:
16556                     return isReusableParameter(node);
16557             }
16558             return false;
16559         }
16560         function isReusableClassMember(node) {
16561             if (node) {
16562                 switch (node.kind) {
16563                     case 162:
16564                     case 167:
16565                     case 163:
16566                     case 164:
16567                     case 159:
16568                     case 222:
16569                         return true;
16570                     case 161:
16571                         var methodDeclaration = node;
16572                         var nameIsConstructor = methodDeclaration.name.kind === 75 &&
16573                             methodDeclaration.name.originalKeywordKind === 129;
16574                         return !nameIsConstructor;
16575                 }
16576             }
16577             return false;
16578         }
16579         function isReusableSwitchClause(node) {
16580             if (node) {
16581                 switch (node.kind) {
16582                     case 277:
16583                     case 278:
16584                         return true;
16585                 }
16586             }
16587             return false;
16588         }
16589         function isReusableStatement(node) {
16590             if (node) {
16591                 switch (node.kind) {
16592                     case 244:
16593                     case 225:
16594                     case 223:
16595                     case 227:
16596                     case 226:
16597                     case 239:
16598                     case 235:
16599                     case 237:
16600                     case 234:
16601                     case 233:
16602                     case 231:
16603                     case 232:
16604                     case 230:
16605                     case 229:
16606                     case 236:
16607                     case 224:
16608                     case 240:
16609                     case 238:
16610                     case 228:
16611                     case 241:
16612                     case 254:
16613                     case 253:
16614                     case 260:
16615                     case 259:
16616                     case 249:
16617                     case 245:
16618                     case 246:
16619                     case 248:
16620                     case 247:
16621                         return true;
16622                 }
16623             }
16624             return false;
16625         }
16626         function isReusableEnumMember(node) {
16627             return node.kind === 284;
16628         }
16629         function isReusableTypeMember(node) {
16630             if (node) {
16631                 switch (node.kind) {
16632                     case 166:
16633                     case 160:
16634                     case 167:
16635                     case 158:
16636                     case 165:
16637                         return true;
16638                 }
16639             }
16640             return false;
16641         }
16642         function isReusableVariableDeclaration(node) {
16643             if (node.kind !== 242) {
16644                 return false;
16645             }
16646             var variableDeclarator = node;
16647             return variableDeclarator.initializer === undefined;
16648         }
16649         function isReusableParameter(node) {
16650             if (node.kind !== 156) {
16651                 return false;
16652             }
16653             var parameter = node;
16654             return parameter.initializer === undefined;
16655         }
16656         function abortParsingListOrMoveToNextToken(kind) {
16657             parseErrorAtCurrentToken(parsingContextErrors(kind));
16658             if (isInSomeParsingContext()) {
16659                 return true;
16660             }
16661             nextToken();
16662             return false;
16663         }
16664         function parsingContextErrors(context) {
16665             switch (context) {
16666                 case 0: return ts.Diagnostics.Declaration_or_statement_expected;
16667                 case 1: return ts.Diagnostics.Declaration_or_statement_expected;
16668                 case 2: return ts.Diagnostics.case_or_default_expected;
16669                 case 3: return ts.Diagnostics.Statement_expected;
16670                 case 18:
16671                 case 4: return ts.Diagnostics.Property_or_signature_expected;
16672                 case 5: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected;
16673                 case 6: return ts.Diagnostics.Enum_member_expected;
16674                 case 7: return ts.Diagnostics.Expression_expected;
16675                 case 8: return ts.Diagnostics.Variable_declaration_expected;
16676                 case 9: return ts.Diagnostics.Property_destructuring_pattern_expected;
16677                 case 10: return ts.Diagnostics.Array_element_destructuring_pattern_expected;
16678                 case 11: return ts.Diagnostics.Argument_expression_expected;
16679                 case 12: return ts.Diagnostics.Property_assignment_expected;
16680                 case 15: return ts.Diagnostics.Expression_or_comma_expected;
16681                 case 17: return ts.Diagnostics.Parameter_declaration_expected;
16682                 case 16: return ts.Diagnostics.Parameter_declaration_expected;
16683                 case 19: return ts.Diagnostics.Type_parameter_declaration_expected;
16684                 case 20: return ts.Diagnostics.Type_argument_expected;
16685                 case 21: return ts.Diagnostics.Type_expected;
16686                 case 22: return ts.Diagnostics.Unexpected_token_expected;
16687                 case 23: return ts.Diagnostics.Identifier_expected;
16688                 case 13: return ts.Diagnostics.Identifier_expected;
16689                 case 14: return ts.Diagnostics.Identifier_expected;
16690                 default: return undefined;
16691             }
16692         }
16693         function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) {
16694             var saveParsingContext = parsingContext;
16695             parsingContext |= 1 << kind;
16696             var list = [];
16697             var listPos = getNodePos();
16698             var commaStart = -1;
16699             while (true) {
16700                 if (isListElement(kind, false)) {
16701                     var startPos = scanner.getStartPos();
16702                     list.push(parseListElement(kind, parseElement));
16703                     commaStart = scanner.getTokenPos();
16704                     if (parseOptional(27)) {
16705                         continue;
16706                     }
16707                     commaStart = -1;
16708                     if (isListTerminator(kind)) {
16709                         break;
16710                     }
16711                     parseExpected(27, getExpectedCommaDiagnostic(kind));
16712                     if (considerSemicolonAsDelimiter && token() === 26 && !scanner.hasPrecedingLineBreak()) {
16713                         nextToken();
16714                     }
16715                     if (startPos === scanner.getStartPos()) {
16716                         nextToken();
16717                     }
16718                     continue;
16719                 }
16720                 if (isListTerminator(kind)) {
16721                     break;
16722                 }
16723                 if (abortParsingListOrMoveToNextToken(kind)) {
16724                     break;
16725                 }
16726             }
16727             parsingContext = saveParsingContext;
16728             var result = createNodeArray(list, listPos);
16729             if (commaStart >= 0) {
16730                 result.hasTrailingComma = true;
16731             }
16732             return result;
16733         }
16734         function getExpectedCommaDiagnostic(kind) {
16735             return kind === 6 ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined;
16736         }
16737         function createMissingList() {
16738             var list = createNodeArray([], getNodePos());
16739             list.isMissingList = true;
16740             return list;
16741         }
16742         function isMissingList(arr) {
16743             return !!arr.isMissingList;
16744         }
16745         function parseBracketedList(kind, parseElement, open, close) {
16746             if (parseExpected(open)) {
16747                 var result = parseDelimitedList(kind, parseElement);
16748                 parseExpected(close);
16749                 return result;
16750             }
16751             return createMissingList();
16752         }
16753         function parseEntityName(allowReservedWords, diagnosticMessage) {
16754             var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage);
16755             var dotPos = scanner.getStartPos();
16756             while (parseOptional(24)) {
16757                 if (token() === 29) {
16758                     entity.jsdocDotPos = dotPos;
16759                     break;
16760                 }
16761                 dotPos = scanner.getStartPos();
16762                 entity = createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, false));
16763             }
16764             return entity;
16765         }
16766         function createQualifiedName(entity, name) {
16767             var node = createNode(153, entity.pos);
16768             node.left = entity;
16769             node.right = name;
16770             return finishNode(node);
16771         }
16772         function parseRightSideOfDot(allowIdentifierNames, allowPrivateIdentifiers) {
16773             if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token())) {
16774                 var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
16775                 if (matchesPattern) {
16776                     return createMissingNode(75, true, ts.Diagnostics.Identifier_expected);
16777                 }
16778             }
16779             if (token() === 76) {
16780                 var node = parsePrivateIdentifier();
16781                 return allowPrivateIdentifiers ? node : createMissingNode(75, true, ts.Diagnostics.Identifier_expected);
16782             }
16783             return allowIdentifierNames ? parseIdentifierName() : parseIdentifier();
16784         }
16785         function parseTemplateExpression(isTaggedTemplate) {
16786             var template = createNode(211);
16787             template.head = parseTemplateHead(isTaggedTemplate);
16788             ts.Debug.assert(template.head.kind === 15, "Template head has wrong token kind");
16789             var list = [];
16790             var listPos = getNodePos();
16791             do {
16792                 list.push(parseTemplateSpan(isTaggedTemplate));
16793             } while (ts.last(list).literal.kind === 16);
16794             template.templateSpans = createNodeArray(list, listPos);
16795             return finishNode(template);
16796         }
16797         function parseTemplateSpan(isTaggedTemplate) {
16798             var span = createNode(221);
16799             span.expression = allowInAnd(parseExpression);
16800             var literal;
16801             if (token() === 19) {
16802                 reScanTemplateToken(isTaggedTemplate);
16803                 literal = parseTemplateMiddleOrTemplateTail();
16804             }
16805             else {
16806                 literal = parseExpectedToken(17, ts.Diagnostics._0_expected, ts.tokenToString(19));
16807             }
16808             span.literal = literal;
16809             return finishNode(span);
16810         }
16811         function parseLiteralNode() {
16812             return parseLiteralLikeNode(token());
16813         }
16814         function parseTemplateHead(isTaggedTemplate) {
16815             if (isTaggedTemplate) {
16816                 reScanTemplateHeadOrNoSubstitutionTemplate();
16817             }
16818             var fragment = parseLiteralLikeNode(token());
16819             ts.Debug.assert(fragment.kind === 15, "Template head has wrong token kind");
16820             return fragment;
16821         }
16822         function parseTemplateMiddleOrTemplateTail() {
16823             var fragment = parseLiteralLikeNode(token());
16824             ts.Debug.assert(fragment.kind === 16 || fragment.kind === 17, "Template fragment has wrong token kind");
16825             return fragment;
16826         }
16827         function parseLiteralLikeNode(kind) {
16828             var node = createNode(kind);
16829             node.text = scanner.getTokenValue();
16830             switch (kind) {
16831                 case 14:
16832                 case 15:
16833                 case 16:
16834                 case 17:
16835                     var isLast = kind === 14 || kind === 17;
16836                     var tokenText = scanner.getTokenText();
16837                     node.rawText = tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2));
16838                     break;
16839             }
16840             if (scanner.hasExtendedUnicodeEscape()) {
16841                 node.hasExtendedUnicodeEscape = true;
16842             }
16843             if (scanner.isUnterminated()) {
16844                 node.isUnterminated = true;
16845             }
16846             if (node.kind === 8) {
16847                 node.numericLiteralFlags = scanner.getTokenFlags() & 1008;
16848             }
16849             if (ts.isTemplateLiteralKind(node.kind)) {
16850                 node.templateFlags = scanner.getTokenFlags() & 2048;
16851             }
16852             nextToken();
16853             finishNode(node);
16854             return node;
16855         }
16856         function parseTypeReference() {
16857             var node = createNode(169);
16858             node.typeName = parseEntityName(true, ts.Diagnostics.Type_expected);
16859             if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29) {
16860                 node.typeArguments = parseBracketedList(20, parseType, 29, 31);
16861             }
16862             return finishNode(node);
16863         }
16864         function typeHasArrowFunctionBlockingParseError(node) {
16865             switch (node.kind) {
16866                 case 169:
16867                     return ts.nodeIsMissing(node.typeName);
16868                 case 170:
16869                 case 171: {
16870                     var _a = node, parameters = _a.parameters, type = _a.type;
16871                     return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type);
16872                 }
16873                 case 182:
16874                     return typeHasArrowFunctionBlockingParseError(node.type);
16875                 default:
16876                     return false;
16877             }
16878         }
16879         function parseThisTypePredicate(lhs) {
16880             nextToken();
16881             var node = createNode(168, lhs.pos);
16882             node.parameterName = lhs;
16883             node.type = parseType();
16884             return finishNode(node);
16885         }
16886         function parseThisTypeNode() {
16887             var node = createNode(183);
16888             nextToken();
16889             return finishNode(node);
16890         }
16891         function parseJSDocAllType(postFixEquals) {
16892             var result = createNode(295);
16893             if (postFixEquals) {
16894                 return createPostfixType(299, result);
16895             }
16896             else {
16897                 nextToken();
16898             }
16899             return finishNode(result);
16900         }
16901         function parseJSDocNonNullableType() {
16902             var result = createNode(298);
16903             nextToken();
16904             result.type = parseNonArrayType();
16905             return finishNode(result);
16906         }
16907         function parseJSDocUnknownOrNullableType() {
16908             var pos = scanner.getStartPos();
16909             nextToken();
16910             if (token() === 27 ||
16911                 token() === 19 ||
16912                 token() === 21 ||
16913                 token() === 31 ||
16914                 token() === 62 ||
16915                 token() === 51) {
16916                 var result = createNode(296, pos);
16917                 return finishNode(result);
16918             }
16919             else {
16920                 var result = createNode(297, pos);
16921                 result.type = parseType();
16922                 return finishNode(result);
16923             }
16924         }
16925         function parseJSDocFunctionType() {
16926             if (lookAhead(nextTokenIsOpenParen)) {
16927                 var result = createNodeWithJSDoc(300);
16928                 nextToken();
16929                 fillSignature(58, 4 | 32, result);
16930                 return finishNode(result);
16931             }
16932             var node = createNode(169);
16933             node.typeName = parseIdentifierName();
16934             return finishNode(node);
16935         }
16936         function parseJSDocParameter() {
16937             var parameter = createNode(156);
16938             if (token() === 104 || token() === 99) {
16939                 parameter.name = parseIdentifierName();
16940                 parseExpected(58);
16941             }
16942             parameter.type = parseJSDocType();
16943             return finishNode(parameter);
16944         }
16945         function parseJSDocType() {
16946             scanner.setInJSDocType(true);
16947             var moduleSpecifier = parseOptionalToken(135);
16948             if (moduleSpecifier) {
16949                 var moduleTag = createNode(302, moduleSpecifier.pos);
16950                 terminate: while (true) {
16951                     switch (token()) {
16952                         case 19:
16953                         case 1:
16954                         case 27:
16955                         case 5:
16956                             break terminate;
16957                         default:
16958                             nextTokenJSDoc();
16959                     }
16960                 }
16961                 scanner.setInJSDocType(false);
16962                 return finishNode(moduleTag);
16963             }
16964             var dotdotdot = parseOptionalToken(25);
16965             var type = parseTypeOrTypePredicate();
16966             scanner.setInJSDocType(false);
16967             if (dotdotdot) {
16968                 var variadic = createNode(301, dotdotdot.pos);
16969                 variadic.type = type;
16970                 type = finishNode(variadic);
16971             }
16972             if (token() === 62) {
16973                 return createPostfixType(299, type);
16974             }
16975             return type;
16976         }
16977         function parseTypeQuery() {
16978             var node = createNode(172);
16979             parseExpected(108);
16980             node.exprName = parseEntityName(true);
16981             return finishNode(node);
16982         }
16983         function parseTypeParameter() {
16984             var node = createNode(155);
16985             node.name = parseIdentifier();
16986             if (parseOptional(90)) {
16987                 if (isStartOfType() || !isStartOfExpression()) {
16988                     node.constraint = parseType();
16989                 }
16990                 else {
16991                     node.expression = parseUnaryExpressionOrHigher();
16992                 }
16993             }
16994             if (parseOptional(62)) {
16995                 node.default = parseType();
16996             }
16997             return finishNode(node);
16998         }
16999         function parseTypeParameters() {
17000             if (token() === 29) {
17001                 return parseBracketedList(19, parseTypeParameter, 29, 31);
17002             }
17003         }
17004         function parseParameterType() {
17005             if (parseOptional(58)) {
17006                 return parseType();
17007             }
17008             return undefined;
17009         }
17010         function isStartOfParameter(isJSDocParameter) {
17011             return token() === 25 ||
17012                 isIdentifierOrPrivateIdentifierOrPattern() ||
17013                 ts.isModifierKind(token()) ||
17014                 token() === 59 ||
17015                 isStartOfType(!isJSDocParameter);
17016         }
17017         function parseParameter() {
17018             var node = createNodeWithJSDoc(156);
17019             if (token() === 104) {
17020                 node.name = createIdentifier(true);
17021                 node.type = parseParameterType();
17022                 return finishNode(node);
17023             }
17024             node.decorators = parseDecorators();
17025             node.modifiers = parseModifiers();
17026             node.dotDotDotToken = parseOptionalToken(25);
17027             node.name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_cannot_be_used_as_parameters);
17028             if (ts.getFullWidth(node.name) === 0 && !node.modifiers && ts.isModifierKind(token())) {
17029                 nextToken();
17030             }
17031             node.questionToken = parseOptionalToken(57);
17032             node.type = parseParameterType();
17033             node.initializer = parseInitializer();
17034             return finishNode(node);
17035         }
17036         function fillSignature(returnToken, flags, signature) {
17037             if (!(flags & 32)) {
17038                 signature.typeParameters = parseTypeParameters();
17039             }
17040             var parametersParsedSuccessfully = parseParameterList(signature, flags);
17041             if (shouldParseReturnType(returnToken, !!(flags & 4))) {
17042                 signature.type = parseTypeOrTypePredicate();
17043                 if (typeHasArrowFunctionBlockingParseError(signature.type))
17044                     return false;
17045             }
17046             return parametersParsedSuccessfully;
17047         }
17048         function shouldParseReturnType(returnToken, isType) {
17049             if (returnToken === 38) {
17050                 parseExpected(returnToken);
17051                 return true;
17052             }
17053             else if (parseOptional(58)) {
17054                 return true;
17055             }
17056             else if (isType && token() === 38) {
17057                 parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58));
17058                 nextToken();
17059                 return true;
17060             }
17061             return false;
17062         }
17063         function parseParameterList(signature, flags) {
17064             if (!parseExpected(20)) {
17065                 signature.parameters = createMissingList();
17066                 return false;
17067             }
17068             var savedYieldContext = inYieldContext();
17069             var savedAwaitContext = inAwaitContext();
17070             setYieldContext(!!(flags & 1));
17071             setAwaitContext(!!(flags & 2));
17072             signature.parameters = flags & 32 ?
17073                 parseDelimitedList(17, parseJSDocParameter) :
17074                 parseDelimitedList(16, parseParameter);
17075             setYieldContext(savedYieldContext);
17076             setAwaitContext(savedAwaitContext);
17077             return parseExpected(21);
17078         }
17079         function parseTypeMemberSemicolon() {
17080             if (parseOptional(27)) {
17081                 return;
17082             }
17083             parseSemicolon();
17084         }
17085         function parseSignatureMember(kind) {
17086             var node = createNodeWithJSDoc(kind);
17087             if (kind === 166) {
17088                 parseExpected(99);
17089             }
17090             fillSignature(58, 4, node);
17091             parseTypeMemberSemicolon();
17092             return finishNode(node);
17093         }
17094         function isIndexSignature() {
17095             return token() === 22 && lookAhead(isUnambiguouslyIndexSignature);
17096         }
17097         function isUnambiguouslyIndexSignature() {
17098             nextToken();
17099             if (token() === 25 || token() === 23) {
17100                 return true;
17101             }
17102             if (ts.isModifierKind(token())) {
17103                 nextToken();
17104                 if (isIdentifier()) {
17105                     return true;
17106                 }
17107             }
17108             else if (!isIdentifier()) {
17109                 return false;
17110             }
17111             else {
17112                 nextToken();
17113             }
17114             if (token() === 58 || token() === 27) {
17115                 return true;
17116             }
17117             if (token() !== 57) {
17118                 return false;
17119             }
17120             nextToken();
17121             return token() === 58 || token() === 27 || token() === 23;
17122         }
17123         function parseIndexSignatureDeclaration(node) {
17124             node.kind = 167;
17125             node.parameters = parseBracketedList(16, parseParameter, 22, 23);
17126             node.type = parseTypeAnnotation();
17127             parseTypeMemberSemicolon();
17128             return finishNode(node);
17129         }
17130         function parsePropertyOrMethodSignature(node) {
17131             node.name = parsePropertyName();
17132             node.questionToken = parseOptionalToken(57);
17133             if (token() === 20 || token() === 29) {
17134                 node.kind = 160;
17135                 fillSignature(58, 4, node);
17136             }
17137             else {
17138                 node.kind = 158;
17139                 node.type = parseTypeAnnotation();
17140                 if (token() === 62) {
17141                     node.initializer = parseInitializer();
17142                 }
17143             }
17144             parseTypeMemberSemicolon();
17145             return finishNode(node);
17146         }
17147         function isTypeMemberStart() {
17148             if (token() === 20 || token() === 29) {
17149                 return true;
17150             }
17151             var idToken = false;
17152             while (ts.isModifierKind(token())) {
17153                 idToken = true;
17154                 nextToken();
17155             }
17156             if (token() === 22) {
17157                 return true;
17158             }
17159             if (isLiteralPropertyName()) {
17160                 idToken = true;
17161                 nextToken();
17162             }
17163             if (idToken) {
17164                 return token() === 20 ||
17165                     token() === 29 ||
17166                     token() === 57 ||
17167                     token() === 58 ||
17168                     token() === 27 ||
17169                     canParseSemicolon();
17170             }
17171             return false;
17172         }
17173         function parseTypeMember() {
17174             if (token() === 20 || token() === 29) {
17175                 return parseSignatureMember(165);
17176             }
17177             if (token() === 99 && lookAhead(nextTokenIsOpenParenOrLessThan)) {
17178                 return parseSignatureMember(166);
17179             }
17180             var node = createNodeWithJSDoc(0);
17181             node.modifiers = parseModifiers();
17182             if (isIndexSignature()) {
17183                 return parseIndexSignatureDeclaration(node);
17184             }
17185             return parsePropertyOrMethodSignature(node);
17186         }
17187         function nextTokenIsOpenParenOrLessThan() {
17188             nextToken();
17189             return token() === 20 || token() === 29;
17190         }
17191         function nextTokenIsDot() {
17192             return nextToken() === 24;
17193         }
17194         function nextTokenIsOpenParenOrLessThanOrDot() {
17195             switch (nextToken()) {
17196                 case 20:
17197                 case 29:
17198                 case 24:
17199                     return true;
17200             }
17201             return false;
17202         }
17203         function parseTypeLiteral() {
17204             var node = createNode(173);
17205             node.members = parseObjectTypeMembers();
17206             return finishNode(node);
17207         }
17208         function parseObjectTypeMembers() {
17209             var members;
17210             if (parseExpected(18)) {
17211                 members = parseList(4, parseTypeMember);
17212                 parseExpected(19);
17213             }
17214             else {
17215                 members = createMissingList();
17216             }
17217             return members;
17218         }
17219         function isStartOfMappedType() {
17220             nextToken();
17221             if (token() === 39 || token() === 40) {
17222                 return nextToken() === 138;
17223             }
17224             if (token() === 138) {
17225                 nextToken();
17226             }
17227             return token() === 22 && nextTokenIsIdentifier() && nextToken() === 97;
17228         }
17229         function parseMappedTypeParameter() {
17230             var node = createNode(155);
17231             node.name = parseIdentifier();
17232             parseExpected(97);
17233             node.constraint = parseType();
17234             return finishNode(node);
17235         }
17236         function parseMappedType() {
17237             var node = createNode(186);
17238             parseExpected(18);
17239             if (token() === 138 || token() === 39 || token() === 40) {
17240                 node.readonlyToken = parseTokenNode();
17241                 if (node.readonlyToken.kind !== 138) {
17242                     parseExpectedToken(138);
17243                 }
17244             }
17245             parseExpected(22);
17246             node.typeParameter = parseMappedTypeParameter();
17247             parseExpected(23);
17248             if (token() === 57 || token() === 39 || token() === 40) {
17249                 node.questionToken = parseTokenNode();
17250                 if (node.questionToken.kind !== 57) {
17251                     parseExpectedToken(57);
17252                 }
17253             }
17254             node.type = parseTypeAnnotation();
17255             parseSemicolon();
17256             parseExpected(19);
17257             return finishNode(node);
17258         }
17259         function parseTupleElementType() {
17260             var pos = getNodePos();
17261             if (parseOptional(25)) {
17262                 var node = createNode(177, pos);
17263                 node.type = parseType();
17264                 return finishNode(node);
17265             }
17266             var type = parseType();
17267             if (!(contextFlags & 4194304) && type.kind === 297 && type.pos === type.type.pos) {
17268                 type.kind = 176;
17269             }
17270             return type;
17271         }
17272         function parseTupleType() {
17273             var node = createNode(175);
17274             node.elementTypes = parseBracketedList(21, parseTupleElementType, 22, 23);
17275             return finishNode(node);
17276         }
17277         function parseParenthesizedType() {
17278             var node = createNode(182);
17279             parseExpected(20);
17280             node.type = parseType();
17281             parseExpected(21);
17282             return finishNode(node);
17283         }
17284         function parseFunctionOrConstructorType() {
17285             var pos = getNodePos();
17286             var kind = parseOptional(99) ? 171 : 170;
17287             var node = createNodeWithJSDoc(kind, pos);
17288             fillSignature(38, 4, node);
17289             return finishNode(node);
17290         }
17291         function parseKeywordAndNoDot() {
17292             var node = parseTokenNode();
17293             return token() === 24 ? undefined : node;
17294         }
17295         function parseLiteralTypeNode(negative) {
17296             var node = createNode(187);
17297             var unaryMinusExpression;
17298             if (negative) {
17299                 unaryMinusExpression = createNode(207);
17300                 unaryMinusExpression.operator = 40;
17301                 nextToken();
17302             }
17303             var expression = token() === 106 || token() === 91
17304                 ? parseTokenNode()
17305                 : parseLiteralLikeNode(token());
17306             if (negative) {
17307                 unaryMinusExpression.operand = expression;
17308                 finishNode(unaryMinusExpression);
17309                 expression = unaryMinusExpression;
17310             }
17311             node.literal = expression;
17312             return finishNode(node);
17313         }
17314         function isStartOfTypeOfImportType() {
17315             nextToken();
17316             return token() === 96;
17317         }
17318         function parseImportType() {
17319             sourceFile.flags |= 1048576;
17320             var node = createNode(188);
17321             if (parseOptional(108)) {
17322                 node.isTypeOf = true;
17323             }
17324             parseExpected(96);
17325             parseExpected(20);
17326             node.argument = parseType();
17327             parseExpected(21);
17328             if (parseOptional(24)) {
17329                 node.qualifier = parseEntityName(true, ts.Diagnostics.Type_expected);
17330             }
17331             if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29) {
17332                 node.typeArguments = parseBracketedList(20, parseType, 29, 31);
17333             }
17334             return finishNode(node);
17335         }
17336         function nextTokenIsNumericOrBigIntLiteral() {
17337             nextToken();
17338             return token() === 8 || token() === 9;
17339         }
17340         function parseNonArrayType() {
17341             switch (token()) {
17342                 case 125:
17343                 case 148:
17344                 case 143:
17345                 case 140:
17346                 case 151:
17347                 case 144:
17348                 case 128:
17349                 case 146:
17350                 case 137:
17351                 case 141:
17352                     return tryParse(parseKeywordAndNoDot) || parseTypeReference();
17353                 case 41:
17354                     return parseJSDocAllType(false);
17355                 case 65:
17356                     return parseJSDocAllType(true);
17357                 case 60:
17358                     scanner.reScanQuestionToken();
17359                 case 57:
17360                     return parseJSDocUnknownOrNullableType();
17361                 case 94:
17362                     return parseJSDocFunctionType();
17363                 case 53:
17364                     return parseJSDocNonNullableType();
17365                 case 14:
17366                 case 10:
17367                 case 8:
17368                 case 9:
17369                 case 106:
17370                 case 91:
17371                     return parseLiteralTypeNode();
17372                 case 40:
17373                     return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(true) : parseTypeReference();
17374                 case 110:
17375                 case 100:
17376                     return parseTokenNode();
17377                 case 104: {
17378                     var thisKeyword = parseThisTypeNode();
17379                     if (token() === 133 && !scanner.hasPrecedingLineBreak()) {
17380                         return parseThisTypePredicate(thisKeyword);
17381                     }
17382                     else {
17383                         return thisKeyword;
17384                     }
17385                 }
17386                 case 108:
17387                     return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery();
17388                 case 18:
17389                     return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral();
17390                 case 22:
17391                     return parseTupleType();
17392                 case 20:
17393                     return parseParenthesizedType();
17394                 case 96:
17395                     return parseImportType();
17396                 case 124:
17397                     return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference();
17398                 default:
17399                     return parseTypeReference();
17400             }
17401         }
17402         function isStartOfType(inStartOfParameter) {
17403             switch (token()) {
17404                 case 125:
17405                 case 148:
17406                 case 143:
17407                 case 140:
17408                 case 151:
17409                 case 128:
17410                 case 138:
17411                 case 144:
17412                 case 147:
17413                 case 110:
17414                 case 146:
17415                 case 100:
17416                 case 104:
17417                 case 108:
17418                 case 137:
17419                 case 18:
17420                 case 22:
17421                 case 29:
17422                 case 51:
17423                 case 50:
17424                 case 99:
17425                 case 10:
17426                 case 8:
17427                 case 9:
17428                 case 106:
17429                 case 91:
17430                 case 141:
17431                 case 41:
17432                 case 57:
17433                 case 53:
17434                 case 25:
17435                 case 132:
17436                 case 96:
17437                 case 124:
17438                     return true;
17439                 case 94:
17440                     return !inStartOfParameter;
17441                 case 40:
17442                     return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral);
17443                 case 20:
17444                     return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType);
17445                 default:
17446                     return isIdentifier();
17447             }
17448         }
17449         function isStartOfParenthesizedOrFunctionType() {
17450             nextToken();
17451             return token() === 21 || isStartOfParameter(false) || isStartOfType();
17452         }
17453         function parsePostfixTypeOrHigher() {
17454             var type = parseNonArrayType();
17455             while (!scanner.hasPrecedingLineBreak()) {
17456                 switch (token()) {
17457                     case 53:
17458                         type = createPostfixType(298, type);
17459                         break;
17460                     case 57:
17461                         if (!(contextFlags & 4194304) && lookAhead(nextTokenIsStartOfType)) {
17462                             return type;
17463                         }
17464                         type = createPostfixType(297, type);
17465                         break;
17466                     case 22:
17467                         parseExpected(22);
17468                         if (isStartOfType()) {
17469                             var node = createNode(185, type.pos);
17470                             node.objectType = type;
17471                             node.indexType = parseType();
17472                             parseExpected(23);
17473                             type = finishNode(node);
17474                         }
17475                         else {
17476                             var node = createNode(174, type.pos);
17477                             node.elementType = type;
17478                             parseExpected(23);
17479                             type = finishNode(node);
17480                         }
17481                         break;
17482                     default:
17483                         return type;
17484                 }
17485             }
17486             return type;
17487         }
17488         function createPostfixType(kind, type) {
17489             nextToken();
17490             var postfix = createNode(kind, type.pos);
17491             postfix.type = type;
17492             return finishNode(postfix);
17493         }
17494         function parseTypeOperator(operator) {
17495             var node = createNode(184);
17496             parseExpected(operator);
17497             node.operator = operator;
17498             node.type = parseTypeOperatorOrHigher();
17499             return finishNode(node);
17500         }
17501         function parseInferType() {
17502             var node = createNode(181);
17503             parseExpected(132);
17504             var typeParameter = createNode(155);
17505             typeParameter.name = parseIdentifier();
17506             node.typeParameter = finishNode(typeParameter);
17507             return finishNode(node);
17508         }
17509         function parseTypeOperatorOrHigher() {
17510             var operator = token();
17511             switch (operator) {
17512                 case 134:
17513                 case 147:
17514                 case 138:
17515                     return parseTypeOperator(operator);
17516                 case 132:
17517                     return parseInferType();
17518             }
17519             return parsePostfixTypeOrHigher();
17520         }
17521         function parseUnionOrIntersectionType(kind, parseConstituentType, operator) {
17522             var start = scanner.getStartPos();
17523             var hasLeadingOperator = parseOptional(operator);
17524             var type = parseConstituentType();
17525             if (token() === operator || hasLeadingOperator) {
17526                 var types = [type];
17527                 while (parseOptional(operator)) {
17528                     types.push(parseConstituentType());
17529                 }
17530                 var node = createNode(kind, start);
17531                 node.types = createNodeArray(types, start);
17532                 type = finishNode(node);
17533             }
17534             return type;
17535         }
17536         function parseIntersectionTypeOrHigher() {
17537             return parseUnionOrIntersectionType(179, parseTypeOperatorOrHigher, 50);
17538         }
17539         function parseUnionTypeOrHigher() {
17540             return parseUnionOrIntersectionType(178, parseIntersectionTypeOrHigher, 51);
17541         }
17542         function isStartOfFunctionType() {
17543             if (token() === 29) {
17544                 return true;
17545             }
17546             return token() === 20 && lookAhead(isUnambiguouslyStartOfFunctionType);
17547         }
17548         function skipParameterStart() {
17549             if (ts.isModifierKind(token())) {
17550                 parseModifiers();
17551             }
17552             if (isIdentifier() || token() === 104) {
17553                 nextToken();
17554                 return true;
17555             }
17556             if (token() === 22 || token() === 18) {
17557                 var previousErrorCount = parseDiagnostics.length;
17558                 parseIdentifierOrPattern();
17559                 return previousErrorCount === parseDiagnostics.length;
17560             }
17561             return false;
17562         }
17563         function isUnambiguouslyStartOfFunctionType() {
17564             nextToken();
17565             if (token() === 21 || token() === 25) {
17566                 return true;
17567             }
17568             if (skipParameterStart()) {
17569                 if (token() === 58 || token() === 27 ||
17570                     token() === 57 || token() === 62) {
17571                     return true;
17572                 }
17573                 if (token() === 21) {
17574                     nextToken();
17575                     if (token() === 38) {
17576                         return true;
17577                     }
17578                 }
17579             }
17580             return false;
17581         }
17582         function parseTypeOrTypePredicate() {
17583             var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix);
17584             var type = parseType();
17585             if (typePredicateVariable) {
17586                 var node = createNode(168, typePredicateVariable.pos);
17587                 node.assertsModifier = undefined;
17588                 node.parameterName = typePredicateVariable;
17589                 node.type = type;
17590                 return finishNode(node);
17591             }
17592             else {
17593                 return type;
17594             }
17595         }
17596         function parseTypePredicatePrefix() {
17597             var id = parseIdentifier();
17598             if (token() === 133 && !scanner.hasPrecedingLineBreak()) {
17599                 nextToken();
17600                 return id;
17601             }
17602         }
17603         function parseAssertsTypePredicate() {
17604             var node = createNode(168);
17605             node.assertsModifier = parseExpectedToken(124);
17606             node.parameterName = token() === 104 ? parseThisTypeNode() : parseIdentifier();
17607             node.type = parseOptional(133) ? parseType() : undefined;
17608             return finishNode(node);
17609         }
17610         function parseType() {
17611             return doOutsideOfContext(40960, parseTypeWorker);
17612         }
17613         function parseTypeWorker(noConditionalTypes) {
17614             if (isStartOfFunctionType() || token() === 99) {
17615                 return parseFunctionOrConstructorType();
17616             }
17617             var type = parseUnionTypeOrHigher();
17618             if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(90)) {
17619                 var node = createNode(180, type.pos);
17620                 node.checkType = type;
17621                 node.extendsType = parseTypeWorker(true);
17622                 parseExpected(57);
17623                 node.trueType = parseTypeWorker();
17624                 parseExpected(58);
17625                 node.falseType = parseTypeWorker();
17626                 return finishNode(node);
17627             }
17628             return type;
17629         }
17630         function parseTypeAnnotation() {
17631             return parseOptional(58) ? parseType() : undefined;
17632         }
17633         function isStartOfLeftHandSideExpression() {
17634             switch (token()) {
17635                 case 104:
17636                 case 102:
17637                 case 100:
17638                 case 106:
17639                 case 91:
17640                 case 8:
17641                 case 9:
17642                 case 10:
17643                 case 14:
17644                 case 15:
17645                 case 20:
17646                 case 22:
17647                 case 18:
17648                 case 94:
17649                 case 80:
17650                 case 99:
17651                 case 43:
17652                 case 67:
17653                 case 75:
17654                     return true;
17655                 case 96:
17656                     return lookAhead(nextTokenIsOpenParenOrLessThanOrDot);
17657                 default:
17658                     return isIdentifier();
17659             }
17660         }
17661         function isStartOfExpression() {
17662             if (isStartOfLeftHandSideExpression()) {
17663                 return true;
17664             }
17665             switch (token()) {
17666                 case 39:
17667                 case 40:
17668                 case 54:
17669                 case 53:
17670                 case 85:
17671                 case 108:
17672                 case 110:
17673                 case 45:
17674                 case 46:
17675                 case 29:
17676                 case 127:
17677                 case 121:
17678                 case 76:
17679                     return true;
17680                 default:
17681                     if (isBinaryOperator()) {
17682                         return true;
17683                     }
17684                     return isIdentifier();
17685             }
17686         }
17687         function isStartOfExpressionStatement() {
17688             return token() !== 18 &&
17689                 token() !== 94 &&
17690                 token() !== 80 &&
17691                 token() !== 59 &&
17692                 isStartOfExpression();
17693         }
17694         function parseExpression() {
17695             var saveDecoratorContext = inDecoratorContext();
17696             if (saveDecoratorContext) {
17697                 setDecoratorContext(false);
17698             }
17699             var expr = parseAssignmentExpressionOrHigher();
17700             var operatorToken;
17701             while ((operatorToken = parseOptionalToken(27))) {
17702                 expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher());
17703             }
17704             if (saveDecoratorContext) {
17705                 setDecoratorContext(true);
17706             }
17707             return expr;
17708         }
17709         function parseInitializer() {
17710             return parseOptional(62) ? parseAssignmentExpressionOrHigher() : undefined;
17711         }
17712         function parseAssignmentExpressionOrHigher() {
17713             if (isYieldExpression()) {
17714                 return parseYieldExpression();
17715             }
17716             var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
17717             if (arrowExpression) {
17718                 return arrowExpression;
17719             }
17720             var expr = parseBinaryExpressionOrHigher(0);
17721             if (expr.kind === 75 && token() === 38) {
17722                 return parseSimpleArrowFunctionExpression(expr);
17723             }
17724             if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) {
17725                 return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher());
17726             }
17727             return parseConditionalExpressionRest(expr);
17728         }
17729         function isYieldExpression() {
17730             if (token() === 121) {
17731                 if (inYieldContext()) {
17732                     return true;
17733                 }
17734                 return lookAhead(nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine);
17735             }
17736             return false;
17737         }
17738         function nextTokenIsIdentifierOnSameLine() {
17739             nextToken();
17740             return !scanner.hasPrecedingLineBreak() && isIdentifier();
17741         }
17742         function parseYieldExpression() {
17743             var node = createNode(212);
17744             nextToken();
17745             if (!scanner.hasPrecedingLineBreak() &&
17746                 (token() === 41 || isStartOfExpression())) {
17747                 node.asteriskToken = parseOptionalToken(41);
17748                 node.expression = parseAssignmentExpressionOrHigher();
17749                 return finishNode(node);
17750             }
17751             else {
17752                 return finishNode(node);
17753             }
17754         }
17755         function parseSimpleArrowFunctionExpression(identifier, asyncModifier) {
17756             ts.Debug.assert(token() === 38, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
17757             var node;
17758             if (asyncModifier) {
17759                 node = createNode(202, asyncModifier.pos);
17760                 node.modifiers = asyncModifier;
17761             }
17762             else {
17763                 node = createNode(202, identifier.pos);
17764             }
17765             var parameter = createNode(156, identifier.pos);
17766             parameter.name = identifier;
17767             finishNode(parameter);
17768             node.parameters = createNodeArray([parameter], parameter.pos, parameter.end);
17769             node.equalsGreaterThanToken = parseExpectedToken(38);
17770             node.body = parseArrowFunctionExpressionBody(!!asyncModifier);
17771             return addJSDocComment(finishNode(node));
17772         }
17773         function tryParseParenthesizedArrowFunctionExpression() {
17774             var triState = isParenthesizedArrowFunctionExpression();
17775             if (triState === 0) {
17776                 return undefined;
17777             }
17778             var arrowFunction = triState === 1
17779                 ? parseParenthesizedArrowFunctionExpressionHead(true)
17780                 : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead);
17781             if (!arrowFunction) {
17782                 return undefined;
17783             }
17784             var isAsync = hasModifierOfKind(arrowFunction, 126);
17785             var lastToken = token();
17786             arrowFunction.equalsGreaterThanToken = parseExpectedToken(38);
17787             arrowFunction.body = (lastToken === 38 || lastToken === 18)
17788                 ? parseArrowFunctionExpressionBody(isAsync)
17789                 : parseIdentifier();
17790             return finishNode(arrowFunction);
17791         }
17792         function isParenthesizedArrowFunctionExpression() {
17793             if (token() === 20 || token() === 29 || token() === 126) {
17794                 return lookAhead(isParenthesizedArrowFunctionExpressionWorker);
17795             }
17796             if (token() === 38) {
17797                 return 1;
17798             }
17799             return 0;
17800         }
17801         function isParenthesizedArrowFunctionExpressionWorker() {
17802             if (token() === 126) {
17803                 nextToken();
17804                 if (scanner.hasPrecedingLineBreak()) {
17805                     return 0;
17806                 }
17807                 if (token() !== 20 && token() !== 29) {
17808                     return 0;
17809                 }
17810             }
17811             var first = token();
17812             var second = nextToken();
17813             if (first === 20) {
17814                 if (second === 21) {
17815                     var third = nextToken();
17816                     switch (third) {
17817                         case 38:
17818                         case 58:
17819                         case 18:
17820                             return 1;
17821                         default:
17822                             return 0;
17823                     }
17824                 }
17825                 if (second === 22 || second === 18) {
17826                     return 2;
17827                 }
17828                 if (second === 25) {
17829                     return 1;
17830                 }
17831                 if (ts.isModifierKind(second) && second !== 126 && lookAhead(nextTokenIsIdentifier)) {
17832                     return 1;
17833                 }
17834                 if (!isIdentifier() && second !== 104) {
17835                     return 0;
17836                 }
17837                 switch (nextToken()) {
17838                     case 58:
17839                         return 1;
17840                     case 57:
17841                         nextToken();
17842                         if (token() === 58 || token() === 27 || token() === 62 || token() === 21) {
17843                             return 1;
17844                         }
17845                         return 0;
17846                     case 27:
17847                     case 62:
17848                     case 21:
17849                         return 2;
17850                 }
17851                 return 0;
17852             }
17853             else {
17854                 ts.Debug.assert(first === 29);
17855                 if (!isIdentifier()) {
17856                     return 0;
17857                 }
17858                 if (sourceFile.languageVariant === 1) {
17859                     var isArrowFunctionInJsx = lookAhead(function () {
17860                         var third = nextToken();
17861                         if (third === 90) {
17862                             var fourth = nextToken();
17863                             switch (fourth) {
17864                                 case 62:
17865                                 case 31:
17866                                     return false;
17867                                 default:
17868                                     return true;
17869                             }
17870                         }
17871                         else if (third === 27) {
17872                             return true;
17873                         }
17874                         return false;
17875                     });
17876                     if (isArrowFunctionInJsx) {
17877                         return 1;
17878                     }
17879                     return 0;
17880                 }
17881                 return 2;
17882             }
17883         }
17884         function parsePossibleParenthesizedArrowFunctionExpressionHead() {
17885             var tokenPos = scanner.getTokenPos();
17886             if (notParenthesizedArrow && notParenthesizedArrow.has(tokenPos.toString())) {
17887                 return undefined;
17888             }
17889             var result = parseParenthesizedArrowFunctionExpressionHead(false);
17890             if (!result) {
17891                 (notParenthesizedArrow || (notParenthesizedArrow = ts.createMap())).set(tokenPos.toString(), true);
17892             }
17893             return result;
17894         }
17895         function tryParseAsyncSimpleArrowFunctionExpression() {
17896             if (token() === 126) {
17897                 if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1) {
17898                     var asyncModifier = parseModifiersForArrowFunction();
17899                     var expr = parseBinaryExpressionOrHigher(0);
17900                     return parseSimpleArrowFunctionExpression(expr, asyncModifier);
17901                 }
17902             }
17903             return undefined;
17904         }
17905         function isUnParenthesizedAsyncArrowFunctionWorker() {
17906             if (token() === 126) {
17907                 nextToken();
17908                 if (scanner.hasPrecedingLineBreak() || token() === 38) {
17909                     return 0;
17910                 }
17911                 var expr = parseBinaryExpressionOrHigher(0);
17912                 if (!scanner.hasPrecedingLineBreak() && expr.kind === 75 && token() === 38) {
17913                     return 1;
17914                 }
17915             }
17916             return 0;
17917         }
17918         function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) {
17919             var node = createNodeWithJSDoc(202);
17920             node.modifiers = parseModifiersForArrowFunction();
17921             var isAsync = hasModifierOfKind(node, 126) ? 2 : 0;
17922             if (!fillSignature(58, isAsync, node) && !allowAmbiguity) {
17923                 return undefined;
17924             }
17925             var hasJSDocFunctionType = node.type && ts.isJSDocFunctionType(node.type);
17926             if (!allowAmbiguity && token() !== 38 && (hasJSDocFunctionType || token() !== 18)) {
17927                 return undefined;
17928             }
17929             return node;
17930         }
17931         function parseArrowFunctionExpressionBody(isAsync) {
17932             if (token() === 18) {
17933                 return parseFunctionBlock(isAsync ? 2 : 0);
17934             }
17935             if (token() !== 26 &&
17936                 token() !== 94 &&
17937                 token() !== 80 &&
17938                 isStartOfStatement() &&
17939                 !isStartOfExpressionStatement()) {
17940                 return parseFunctionBlock(16 | (isAsync ? 2 : 0));
17941             }
17942             return isAsync
17943                 ? doInAwaitContext(parseAssignmentExpressionOrHigher)
17944                 : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
17945         }
17946         function parseConditionalExpressionRest(leftOperand) {
17947             var questionToken = parseOptionalToken(57);
17948             if (!questionToken) {
17949                 return leftOperand;
17950             }
17951             var node = createNode(210, leftOperand.pos);
17952             node.condition = leftOperand;
17953             node.questionToken = questionToken;
17954             node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher);
17955             node.colonToken = parseExpectedToken(58);
17956             node.whenFalse = ts.nodeIsPresent(node.colonToken)
17957                 ? parseAssignmentExpressionOrHigher()
17958                 : createMissingNode(75, false, ts.Diagnostics._0_expected, ts.tokenToString(58));
17959             return finishNode(node);
17960         }
17961         function parseBinaryExpressionOrHigher(precedence) {
17962             var leftOperand = parseUnaryExpressionOrHigher();
17963             return parseBinaryExpressionRest(precedence, leftOperand);
17964         }
17965         function isInOrOfKeyword(t) {
17966             return t === 97 || t === 152;
17967         }
17968         function parseBinaryExpressionRest(precedence, leftOperand) {
17969             while (true) {
17970                 reScanGreaterToken();
17971                 var newPrecedence = ts.getBinaryOperatorPrecedence(token());
17972                 var consumeCurrentOperator = token() === 42 ?
17973                     newPrecedence >= precedence :
17974                     newPrecedence > precedence;
17975                 if (!consumeCurrentOperator) {
17976                     break;
17977                 }
17978                 if (token() === 97 && inDisallowInContext()) {
17979                     break;
17980                 }
17981                 if (token() === 123) {
17982                     if (scanner.hasPrecedingLineBreak()) {
17983                         break;
17984                     }
17985                     else {
17986                         nextToken();
17987                         leftOperand = makeAsExpression(leftOperand, parseType());
17988                     }
17989                 }
17990                 else {
17991                     leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence));
17992                 }
17993             }
17994             return leftOperand;
17995         }
17996         function isBinaryOperator() {
17997             if (inDisallowInContext() && token() === 97) {
17998                 return false;
17999             }
18000             return ts.getBinaryOperatorPrecedence(token()) > 0;
18001         }
18002         function makeBinaryExpression(left, operatorToken, right) {
18003             var node = createNode(209, left.pos);
18004             node.left = left;
18005             node.operatorToken = operatorToken;
18006             node.right = right;
18007             return finishNode(node);
18008         }
18009         function makeAsExpression(left, right) {
18010             var node = createNode(217, left.pos);
18011             node.expression = left;
18012             node.type = right;
18013             return finishNode(node);
18014         }
18015         function parsePrefixUnaryExpression() {
18016             var node = createNode(207);
18017             node.operator = token();
18018             nextToken();
18019             node.operand = parseSimpleUnaryExpression();
18020             return finishNode(node);
18021         }
18022         function parseDeleteExpression() {
18023             var node = createNode(203);
18024             nextToken();
18025             node.expression = parseSimpleUnaryExpression();
18026             return finishNode(node);
18027         }
18028         function parseTypeOfExpression() {
18029             var node = createNode(204);
18030             nextToken();
18031             node.expression = parseSimpleUnaryExpression();
18032             return finishNode(node);
18033         }
18034         function parseVoidExpression() {
18035             var node = createNode(205);
18036             nextToken();
18037             node.expression = parseSimpleUnaryExpression();
18038             return finishNode(node);
18039         }
18040         function isAwaitExpression() {
18041             if (token() === 127) {
18042                 if (inAwaitContext()) {
18043                     return true;
18044                 }
18045                 return lookAhead(nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine);
18046             }
18047             return false;
18048         }
18049         function parseAwaitExpression() {
18050             var node = createNode(206);
18051             nextToken();
18052             node.expression = parseSimpleUnaryExpression();
18053             return finishNode(node);
18054         }
18055         function parseUnaryExpressionOrHigher() {
18056             if (isUpdateExpression()) {
18057                 var updateExpression = parseUpdateExpression();
18058                 return token() === 42 ?
18059                     parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression) :
18060                     updateExpression;
18061             }
18062             var unaryOperator = token();
18063             var simpleUnaryExpression = parseSimpleUnaryExpression();
18064             if (token() === 42) {
18065                 var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos);
18066                 var end = simpleUnaryExpression.end;
18067                 if (simpleUnaryExpression.kind === 199) {
18068                     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);
18069                 }
18070                 else {
18071                     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));
18072                 }
18073             }
18074             return simpleUnaryExpression;
18075         }
18076         function parseSimpleUnaryExpression() {
18077             switch (token()) {
18078                 case 39:
18079                 case 40:
18080                 case 54:
18081                 case 53:
18082                     return parsePrefixUnaryExpression();
18083                 case 85:
18084                     return parseDeleteExpression();
18085                 case 108:
18086                     return parseTypeOfExpression();
18087                 case 110:
18088                     return parseVoidExpression();
18089                 case 29:
18090                     return parseTypeAssertion();
18091                 case 127:
18092                     if (isAwaitExpression()) {
18093                         return parseAwaitExpression();
18094                     }
18095                 default:
18096                     return parseUpdateExpression();
18097             }
18098         }
18099         function isUpdateExpression() {
18100             switch (token()) {
18101                 case 39:
18102                 case 40:
18103                 case 54:
18104                 case 53:
18105                 case 85:
18106                 case 108:
18107                 case 110:
18108                 case 127:
18109                     return false;
18110                 case 29:
18111                     if (sourceFile.languageVariant !== 1) {
18112                         return false;
18113                     }
18114                 default:
18115                     return true;
18116             }
18117         }
18118         function parseUpdateExpression() {
18119             if (token() === 45 || token() === 46) {
18120                 var node = createNode(207);
18121                 node.operator = token();
18122                 nextToken();
18123                 node.operand = parseLeftHandSideExpressionOrHigher();
18124                 return finishNode(node);
18125             }
18126             else if (sourceFile.languageVariant === 1 && token() === 29 && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) {
18127                 return parseJsxElementOrSelfClosingElementOrFragment(true);
18128             }
18129             var expression = parseLeftHandSideExpressionOrHigher();
18130             ts.Debug.assert(ts.isLeftHandSideExpression(expression));
18131             if ((token() === 45 || token() === 46) && !scanner.hasPrecedingLineBreak()) {
18132                 var node = createNode(208, expression.pos);
18133                 node.operand = expression;
18134                 node.operator = token();
18135                 nextToken();
18136                 return finishNode(node);
18137             }
18138             return expression;
18139         }
18140         function parseLeftHandSideExpressionOrHigher() {
18141             var expression;
18142             if (token() === 96) {
18143                 if (lookAhead(nextTokenIsOpenParenOrLessThan)) {
18144                     sourceFile.flags |= 1048576;
18145                     expression = parseTokenNode();
18146                 }
18147                 else if (lookAhead(nextTokenIsDot)) {
18148                     var fullStart = scanner.getStartPos();
18149                     nextToken();
18150                     nextToken();
18151                     var node = createNode(219, fullStart);
18152                     node.keywordToken = 96;
18153                     node.name = parseIdentifierName();
18154                     expression = finishNode(node);
18155                     sourceFile.flags |= 2097152;
18156                 }
18157                 else {
18158                     expression = parseMemberExpressionOrHigher();
18159                 }
18160             }
18161             else {
18162                 expression = token() === 102 ? parseSuperExpression() : parseMemberExpressionOrHigher();
18163             }
18164             return parseCallExpressionRest(expression);
18165         }
18166         function parseMemberExpressionOrHigher() {
18167             var expression = parsePrimaryExpression();
18168             return parseMemberExpressionRest(expression, true);
18169         }
18170         function parseSuperExpression() {
18171             var expression = parseTokenNode();
18172             if (token() === 29) {
18173                 var startPos = getNodePos();
18174                 var typeArguments = tryParse(parseTypeArgumentsInExpression);
18175                 if (typeArguments !== undefined) {
18176                     parseErrorAt(startPos, getNodePos(), ts.Diagnostics.super_may_not_use_type_arguments);
18177                 }
18178             }
18179             if (token() === 20 || token() === 24 || token() === 22) {
18180                 return expression;
18181             }
18182             var node = createNode(194, expression.pos);
18183             node.expression = expression;
18184             parseExpectedToken(24, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access);
18185             node.name = parseRightSideOfDot(true, true);
18186             return finishNode(node);
18187         }
18188         function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) {
18189             var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext);
18190             var result;
18191             if (opening.kind === 268) {
18192                 var node = createNode(266, opening.pos);
18193                 node.openingElement = opening;
18194                 node.children = parseJsxChildren(node.openingElement);
18195                 node.closingElement = parseJsxClosingElement(inExpressionContext);
18196                 if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) {
18197                     parseErrorAtRange(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, node.openingElement.tagName));
18198                 }
18199                 result = finishNode(node);
18200             }
18201             else if (opening.kind === 271) {
18202                 var node = createNode(270, opening.pos);
18203                 node.openingFragment = opening;
18204                 node.children = parseJsxChildren(node.openingFragment);
18205                 node.closingFragment = parseJsxClosingFragment(inExpressionContext);
18206                 result = finishNode(node);
18207             }
18208             else {
18209                 ts.Debug.assert(opening.kind === 267);
18210                 result = opening;
18211             }
18212             if (inExpressionContext && token() === 29) {
18213                 var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(true); });
18214                 if (invalidElement) {
18215                     parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element);
18216                     var badNode = createNode(209, result.pos);
18217                     badNode.end = invalidElement.end;
18218                     badNode.left = result;
18219                     badNode.right = invalidElement;
18220                     badNode.operatorToken = createMissingNode(27, false);
18221                     badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos;
18222                     return badNode;
18223                 }
18224             }
18225             return result;
18226         }
18227         function parseJsxText() {
18228             var node = createNode(11);
18229             node.text = scanner.getTokenValue();
18230             node.containsOnlyTriviaWhiteSpaces = currentToken === 12;
18231             currentToken = scanner.scanJsxToken();
18232             return finishNode(node);
18233         }
18234         function parseJsxChild(openingTag, token) {
18235             switch (token) {
18236                 case 1:
18237                     if (ts.isJsxOpeningFragment(openingTag)) {
18238                         parseErrorAtRange(openingTag, ts.Diagnostics.JSX_fragment_has_no_corresponding_closing_tag);
18239                     }
18240                     else {
18241                         var tag = openingTag.tagName;
18242                         var start = ts.skipTrivia(sourceText, tag.pos);
18243                         parseErrorAt(start, tag.end, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName));
18244                     }
18245                     return undefined;
18246                 case 30:
18247                 case 7:
18248                     return undefined;
18249                 case 11:
18250                 case 12:
18251                     return parseJsxText();
18252                 case 18:
18253                     return parseJsxExpression(false);
18254                 case 29:
18255                     return parseJsxElementOrSelfClosingElementOrFragment(false);
18256                 default:
18257                     return ts.Debug.assertNever(token);
18258             }
18259         }
18260         function parseJsxChildren(openingTag) {
18261             var list = [];
18262             var listPos = getNodePos();
18263             var saveParsingContext = parsingContext;
18264             parsingContext |= 1 << 14;
18265             while (true) {
18266                 var child = parseJsxChild(openingTag, currentToken = scanner.reScanJsxToken());
18267                 if (!child)
18268                     break;
18269                 list.push(child);
18270             }
18271             parsingContext = saveParsingContext;
18272             return createNodeArray(list, listPos);
18273         }
18274         function parseJsxAttributes() {
18275             var jsxAttributes = createNode(274);
18276             jsxAttributes.properties = parseList(13, parseJsxAttribute);
18277             return finishNode(jsxAttributes);
18278         }
18279         function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) {
18280             var fullStart = scanner.getStartPos();
18281             parseExpected(29);
18282             if (token() === 31) {
18283                 var node_1 = createNode(271, fullStart);
18284                 scanJsxText();
18285                 return finishNode(node_1);
18286             }
18287             var tagName = parseJsxElementName();
18288             var typeArguments = tryParseTypeArguments();
18289             var attributes = parseJsxAttributes();
18290             var node;
18291             if (token() === 31) {
18292                 node = createNode(268, fullStart);
18293                 scanJsxText();
18294             }
18295             else {
18296                 parseExpected(43);
18297                 if (inExpressionContext) {
18298                     parseExpected(31);
18299                 }
18300                 else {
18301                     parseExpected(31, undefined, false);
18302                     scanJsxText();
18303                 }
18304                 node = createNode(267, fullStart);
18305             }
18306             node.tagName = tagName;
18307             node.typeArguments = typeArguments;
18308             node.attributes = attributes;
18309             return finishNode(node);
18310         }
18311         function parseJsxElementName() {
18312             scanJsxIdentifier();
18313             var expression = token() === 104 ?
18314                 parseTokenNode() : parseIdentifierName();
18315             while (parseOptional(24)) {
18316                 var propertyAccess = createNode(194, expression.pos);
18317                 propertyAccess.expression = expression;
18318                 propertyAccess.name = parseRightSideOfDot(true, false);
18319                 expression = finishNode(propertyAccess);
18320             }
18321             return expression;
18322         }
18323         function parseJsxExpression(inExpressionContext) {
18324             var node = createNode(276);
18325             if (!parseExpected(18)) {
18326                 return undefined;
18327             }
18328             if (token() !== 19) {
18329                 node.dotDotDotToken = parseOptionalToken(25);
18330                 node.expression = parseExpression();
18331             }
18332             if (inExpressionContext) {
18333                 parseExpected(19);
18334             }
18335             else {
18336                 if (parseExpected(19, undefined, false)) {
18337                     scanJsxText();
18338                 }
18339             }
18340             return finishNode(node);
18341         }
18342         function parseJsxAttribute() {
18343             if (token() === 18) {
18344                 return parseJsxSpreadAttribute();
18345             }
18346             scanJsxIdentifier();
18347             var node = createNode(273);
18348             node.name = parseIdentifierName();
18349             if (token() === 62) {
18350                 switch (scanJsxAttributeValue()) {
18351                     case 10:
18352                         node.initializer = parseLiteralNode();
18353                         break;
18354                     default:
18355                         node.initializer = parseJsxExpression(true);
18356                         break;
18357                 }
18358             }
18359             return finishNode(node);
18360         }
18361         function parseJsxSpreadAttribute() {
18362             var node = createNode(275);
18363             parseExpected(18);
18364             parseExpected(25);
18365             node.expression = parseExpression();
18366             parseExpected(19);
18367             return finishNode(node);
18368         }
18369         function parseJsxClosingElement(inExpressionContext) {
18370             var node = createNode(269);
18371             parseExpected(30);
18372             node.tagName = parseJsxElementName();
18373             if (inExpressionContext) {
18374                 parseExpected(31);
18375             }
18376             else {
18377                 parseExpected(31, undefined, false);
18378                 scanJsxText();
18379             }
18380             return finishNode(node);
18381         }
18382         function parseJsxClosingFragment(inExpressionContext) {
18383             var node = createNode(272);
18384             parseExpected(30);
18385             if (ts.tokenIsIdentifierOrKeyword(token())) {
18386                 parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment);
18387             }
18388             if (inExpressionContext) {
18389                 parseExpected(31);
18390             }
18391             else {
18392                 parseExpected(31, undefined, false);
18393                 scanJsxText();
18394             }
18395             return finishNode(node);
18396         }
18397         function parseTypeAssertion() {
18398             var node = createNode(199);
18399             parseExpected(29);
18400             node.type = parseType();
18401             parseExpected(31);
18402             node.expression = parseSimpleUnaryExpression();
18403             return finishNode(node);
18404         }
18405         function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() {
18406             nextToken();
18407             return ts.tokenIsIdentifierOrKeyword(token())
18408                 || token() === 22
18409                 || isTemplateStartOfTaggedTemplate();
18410         }
18411         function isStartOfOptionalPropertyOrElementAccessChain() {
18412             return token() === 28
18413                 && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate);
18414         }
18415         function tryReparseOptionalChain(node) {
18416             if (node.flags & 32) {
18417                 return true;
18418             }
18419             if (ts.isNonNullExpression(node)) {
18420                 var expr = node.expression;
18421                 while (ts.isNonNullExpression(expr) && !(expr.flags & 32)) {
18422                     expr = expr.expression;
18423                 }
18424                 if (expr.flags & 32) {
18425                     while (ts.isNonNullExpression(node)) {
18426                         node.flags |= 32;
18427                         node = node.expression;
18428                     }
18429                     return true;
18430                 }
18431             }
18432             return false;
18433         }
18434         function parsePropertyAccessExpressionRest(expression, questionDotToken) {
18435             var propertyAccess = createNode(194, expression.pos);
18436             propertyAccess.expression = expression;
18437             propertyAccess.questionDotToken = questionDotToken;
18438             propertyAccess.name = parseRightSideOfDot(true, true);
18439             if (questionDotToken || tryReparseOptionalChain(expression)) {
18440                 propertyAccess.flags |= 32;
18441                 if (ts.isPrivateIdentifier(propertyAccess.name)) {
18442                     parseErrorAtRange(propertyAccess.name, ts.Diagnostics.An_optional_chain_cannot_contain_private_identifiers);
18443                 }
18444             }
18445             return finishNode(propertyAccess);
18446         }
18447         function parseElementAccessExpressionRest(expression, questionDotToken) {
18448             var indexedAccess = createNode(195, expression.pos);
18449             indexedAccess.expression = expression;
18450             indexedAccess.questionDotToken = questionDotToken;
18451             if (token() === 23) {
18452                 indexedAccess.argumentExpression = createMissingNode(75, true, ts.Diagnostics.An_element_access_expression_should_take_an_argument);
18453             }
18454             else {
18455                 var argument = allowInAnd(parseExpression);
18456                 if (ts.isStringOrNumericLiteralLike(argument)) {
18457                     argument.text = internIdentifier(argument.text);
18458                 }
18459                 indexedAccess.argumentExpression = argument;
18460             }
18461             parseExpected(23);
18462             if (questionDotToken || tryReparseOptionalChain(expression)) {
18463                 indexedAccess.flags |= 32;
18464             }
18465             return finishNode(indexedAccess);
18466         }
18467         function parseMemberExpressionRest(expression, allowOptionalChain) {
18468             while (true) {
18469                 var questionDotToken = void 0;
18470                 var isPropertyAccess = false;
18471                 if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) {
18472                     questionDotToken = parseExpectedToken(28);
18473                     isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token());
18474                 }
18475                 else {
18476                     isPropertyAccess = parseOptional(24);
18477                 }
18478                 if (isPropertyAccess) {
18479                     expression = parsePropertyAccessExpressionRest(expression, questionDotToken);
18480                     continue;
18481                 }
18482                 if (!questionDotToken && token() === 53 && !scanner.hasPrecedingLineBreak()) {
18483                     nextToken();
18484                     var nonNullExpression = createNode(218, expression.pos);
18485                     nonNullExpression.expression = expression;
18486                     expression = finishNode(nonNullExpression);
18487                     continue;
18488                 }
18489                 if ((questionDotToken || !inDecoratorContext()) && parseOptional(22)) {
18490                     expression = parseElementAccessExpressionRest(expression, questionDotToken);
18491                     continue;
18492                 }
18493                 if (isTemplateStartOfTaggedTemplate()) {
18494                     expression = parseTaggedTemplateRest(expression, questionDotToken, undefined);
18495                     continue;
18496                 }
18497                 return expression;
18498             }
18499         }
18500         function isTemplateStartOfTaggedTemplate() {
18501             return token() === 14 || token() === 15;
18502         }
18503         function parseTaggedTemplateRest(tag, questionDotToken, typeArguments) {
18504             var tagExpression = createNode(198, tag.pos);
18505             tagExpression.tag = tag;
18506             tagExpression.questionDotToken = questionDotToken;
18507             tagExpression.typeArguments = typeArguments;
18508             tagExpression.template = token() === 14
18509                 ? (reScanTemplateHeadOrNoSubstitutionTemplate(), parseLiteralNode())
18510                 : parseTemplateExpression(true);
18511             if (questionDotToken || tag.flags & 32) {
18512                 tagExpression.flags |= 32;
18513             }
18514             return finishNode(tagExpression);
18515         }
18516         function parseCallExpressionRest(expression) {
18517             while (true) {
18518                 expression = parseMemberExpressionRest(expression, true);
18519                 var questionDotToken = parseOptionalToken(28);
18520                 if (token() === 29 || token() === 47) {
18521                     var typeArguments = tryParse(parseTypeArgumentsInExpression);
18522                     if (typeArguments) {
18523                         if (isTemplateStartOfTaggedTemplate()) {
18524                             expression = parseTaggedTemplateRest(expression, questionDotToken, typeArguments);
18525                             continue;
18526                         }
18527                         var callExpr = createNode(196, expression.pos);
18528                         callExpr.expression = expression;
18529                         callExpr.questionDotToken = questionDotToken;
18530                         callExpr.typeArguments = typeArguments;
18531                         callExpr.arguments = parseArgumentList();
18532                         if (questionDotToken || tryReparseOptionalChain(expression)) {
18533                             callExpr.flags |= 32;
18534                         }
18535                         expression = finishNode(callExpr);
18536                         continue;
18537                     }
18538                 }
18539                 else if (token() === 20) {
18540                     var callExpr = createNode(196, expression.pos);
18541                     callExpr.expression = expression;
18542                     callExpr.questionDotToken = questionDotToken;
18543                     callExpr.arguments = parseArgumentList();
18544                     if (questionDotToken || tryReparseOptionalChain(expression)) {
18545                         callExpr.flags |= 32;
18546                     }
18547                     expression = finishNode(callExpr);
18548                     continue;
18549                 }
18550                 if (questionDotToken) {
18551                     var propertyAccess = createNode(194, expression.pos);
18552                     propertyAccess.expression = expression;
18553                     propertyAccess.questionDotToken = questionDotToken;
18554                     propertyAccess.name = createMissingNode(75, false, ts.Diagnostics.Identifier_expected);
18555                     propertyAccess.flags |= 32;
18556                     expression = finishNode(propertyAccess);
18557                 }
18558                 break;
18559             }
18560             return expression;
18561         }
18562         function parseArgumentList() {
18563             parseExpected(20);
18564             var result = parseDelimitedList(11, parseArgumentExpression);
18565             parseExpected(21);
18566             return result;
18567         }
18568         function parseTypeArgumentsInExpression() {
18569             if (reScanLessThanToken() !== 29) {
18570                 return undefined;
18571             }
18572             nextToken();
18573             var typeArguments = parseDelimitedList(20, parseType);
18574             if (!parseExpected(31)) {
18575                 return undefined;
18576             }
18577             return typeArguments && canFollowTypeArgumentsInExpression()
18578                 ? typeArguments
18579                 : undefined;
18580         }
18581         function canFollowTypeArgumentsInExpression() {
18582             switch (token()) {
18583                 case 20:
18584                 case 14:
18585                 case 15:
18586                 case 24:
18587                 case 21:
18588                 case 23:
18589                 case 58:
18590                 case 26:
18591                 case 57:
18592                 case 34:
18593                 case 36:
18594                 case 35:
18595                 case 37:
18596                 case 55:
18597                 case 56:
18598                 case 60:
18599                 case 52:
18600                 case 50:
18601                 case 51:
18602                 case 19:
18603                 case 1:
18604                     return true;
18605                 case 27:
18606                 case 18:
18607                 default:
18608                     return false;
18609             }
18610         }
18611         function parsePrimaryExpression() {
18612             switch (token()) {
18613                 case 8:
18614                 case 9:
18615                 case 10:
18616                 case 14:
18617                     return parseLiteralNode();
18618                 case 104:
18619                 case 102:
18620                 case 100:
18621                 case 106:
18622                 case 91:
18623                     return parseTokenNode();
18624                 case 20:
18625                     return parseParenthesizedExpression();
18626                 case 22:
18627                     return parseArrayLiteralExpression();
18628                 case 18:
18629                     return parseObjectLiteralExpression();
18630                 case 126:
18631                     if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) {
18632                         break;
18633                     }
18634                     return parseFunctionExpression();
18635                 case 80:
18636                     return parseClassExpression();
18637                 case 94:
18638                     return parseFunctionExpression();
18639                 case 99:
18640                     return parseNewExpressionOrNewDotTarget();
18641                 case 43:
18642                 case 67:
18643                     if (reScanSlashToken() === 13) {
18644                         return parseLiteralNode();
18645                     }
18646                     break;
18647                 case 15:
18648                     return parseTemplateExpression(false);
18649             }
18650             return parseIdentifier(ts.Diagnostics.Expression_expected);
18651         }
18652         function parseParenthesizedExpression() {
18653             var node = createNodeWithJSDoc(200);
18654             parseExpected(20);
18655             node.expression = allowInAnd(parseExpression);
18656             parseExpected(21);
18657             return finishNode(node);
18658         }
18659         function parseSpreadElement() {
18660             var node = createNode(213);
18661             parseExpected(25);
18662             node.expression = parseAssignmentExpressionOrHigher();
18663             return finishNode(node);
18664         }
18665         function parseArgumentOrArrayLiteralElement() {
18666             return token() === 25 ? parseSpreadElement() :
18667                 token() === 27 ? createNode(215) :
18668                     parseAssignmentExpressionOrHigher();
18669         }
18670         function parseArgumentExpression() {
18671             return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement);
18672         }
18673         function parseArrayLiteralExpression() {
18674             var node = createNode(192);
18675             parseExpected(22);
18676             if (scanner.hasPrecedingLineBreak()) {
18677                 node.multiLine = true;
18678             }
18679             node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement);
18680             parseExpected(23);
18681             return finishNode(node);
18682         }
18683         function parseObjectLiteralElement() {
18684             var node = createNodeWithJSDoc(0);
18685             if (parseOptionalToken(25)) {
18686                 node.kind = 283;
18687                 node.expression = parseAssignmentExpressionOrHigher();
18688                 return finishNode(node);
18689             }
18690             node.decorators = parseDecorators();
18691             node.modifiers = parseModifiers();
18692             if (parseContextualModifier(131)) {
18693                 return parseAccessorDeclaration(node, 163);
18694             }
18695             if (parseContextualModifier(142)) {
18696                 return parseAccessorDeclaration(node, 164);
18697             }
18698             var asteriskToken = parseOptionalToken(41);
18699             var tokenIsIdentifier = isIdentifier();
18700             node.name = parsePropertyName();
18701             node.questionToken = parseOptionalToken(57);
18702             node.exclamationToken = parseOptionalToken(53);
18703             if (asteriskToken || token() === 20 || token() === 29) {
18704                 return parseMethodDeclaration(node, asteriskToken);
18705             }
18706             var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58);
18707             if (isShorthandPropertyAssignment) {
18708                 node.kind = 282;
18709                 var equalsToken = parseOptionalToken(62);
18710                 if (equalsToken) {
18711                     node.equalsToken = equalsToken;
18712                     node.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher);
18713                 }
18714             }
18715             else {
18716                 node.kind = 281;
18717                 parseExpected(58);
18718                 node.initializer = allowInAnd(parseAssignmentExpressionOrHigher);
18719             }
18720             return finishNode(node);
18721         }
18722         function parseObjectLiteralExpression() {
18723             var node = createNode(193);
18724             var openBracePosition = scanner.getTokenPos();
18725             parseExpected(18);
18726             if (scanner.hasPrecedingLineBreak()) {
18727                 node.multiLine = true;
18728             }
18729             node.properties = parseDelimitedList(12, parseObjectLiteralElement, true);
18730             if (!parseExpected(19)) {
18731                 var lastError = ts.lastOrUndefined(parseDiagnostics);
18732                 if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
18733                     ts.addRelatedInfo(lastError, ts.createFileDiagnostic(sourceFile, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
18734                 }
18735             }
18736             return finishNode(node);
18737         }
18738         function parseFunctionExpression() {
18739             var saveDecoratorContext = inDecoratorContext();
18740             if (saveDecoratorContext) {
18741                 setDecoratorContext(false);
18742             }
18743             var node = createNodeWithJSDoc(201);
18744             node.modifiers = parseModifiers();
18745             parseExpected(94);
18746             node.asteriskToken = parseOptionalToken(41);
18747             var isGenerator = node.asteriskToken ? 1 : 0;
18748             var isAsync = hasModifierOfKind(node, 126) ? 2 : 0;
18749             node.name =
18750                 isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) :
18751                     isGenerator ? doInYieldContext(parseOptionalIdentifier) :
18752                         isAsync ? doInAwaitContext(parseOptionalIdentifier) :
18753                             parseOptionalIdentifier();
18754             fillSignature(58, isGenerator | isAsync, node);
18755             node.body = parseFunctionBlock(isGenerator | isAsync);
18756             if (saveDecoratorContext) {
18757                 setDecoratorContext(true);
18758             }
18759             return finishNode(node);
18760         }
18761         function parseOptionalIdentifier() {
18762             return isIdentifier() ? parseIdentifier() : undefined;
18763         }
18764         function parseNewExpressionOrNewDotTarget() {
18765             var fullStart = scanner.getStartPos();
18766             parseExpected(99);
18767             if (parseOptional(24)) {
18768                 var node_2 = createNode(219, fullStart);
18769                 node_2.keywordToken = 99;
18770                 node_2.name = parseIdentifierName();
18771                 return finishNode(node_2);
18772             }
18773             var expression = parsePrimaryExpression();
18774             var typeArguments;
18775             while (true) {
18776                 expression = parseMemberExpressionRest(expression, false);
18777                 typeArguments = tryParse(parseTypeArgumentsInExpression);
18778                 if (isTemplateStartOfTaggedTemplate()) {
18779                     ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'");
18780                     expression = parseTaggedTemplateRest(expression, undefined, typeArguments);
18781                     typeArguments = undefined;
18782                 }
18783                 break;
18784             }
18785             var node = createNode(197, fullStart);
18786             node.expression = expression;
18787             node.typeArguments = typeArguments;
18788             if (token() === 20) {
18789                 node.arguments = parseArgumentList();
18790             }
18791             else if (node.typeArguments) {
18792                 parseErrorAt(fullStart, scanner.getStartPos(), ts.Diagnostics.A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list);
18793             }
18794             return finishNode(node);
18795         }
18796         function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) {
18797             var node = createNode(223);
18798             var openBracePosition = scanner.getTokenPos();
18799             if (parseExpected(18, diagnosticMessage) || ignoreMissingOpenBrace) {
18800                 if (scanner.hasPrecedingLineBreak()) {
18801                     node.multiLine = true;
18802                 }
18803                 node.statements = parseList(1, parseStatement);
18804                 if (!parseExpected(19)) {
18805                     var lastError = ts.lastOrUndefined(parseDiagnostics);
18806                     if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
18807                         ts.addRelatedInfo(lastError, ts.createFileDiagnostic(sourceFile, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
18808                     }
18809                 }
18810             }
18811             else {
18812                 node.statements = createMissingList();
18813             }
18814             return finishNode(node);
18815         }
18816         function parseFunctionBlock(flags, diagnosticMessage) {
18817             var savedYieldContext = inYieldContext();
18818             setYieldContext(!!(flags & 1));
18819             var savedAwaitContext = inAwaitContext();
18820             setAwaitContext(!!(flags & 2));
18821             var saveDecoratorContext = inDecoratorContext();
18822             if (saveDecoratorContext) {
18823                 setDecoratorContext(false);
18824             }
18825             var block = parseBlock(!!(flags & 16), diagnosticMessage);
18826             if (saveDecoratorContext) {
18827                 setDecoratorContext(true);
18828             }
18829             setYieldContext(savedYieldContext);
18830             setAwaitContext(savedAwaitContext);
18831             return block;
18832         }
18833         function parseEmptyStatement() {
18834             var node = createNode(224);
18835             parseExpected(26);
18836             return finishNode(node);
18837         }
18838         function parseIfStatement() {
18839             var node = createNode(227);
18840             parseExpected(95);
18841             parseExpected(20);
18842             node.expression = allowInAnd(parseExpression);
18843             parseExpected(21);
18844             node.thenStatement = parseStatement();
18845             node.elseStatement = parseOptional(87) ? parseStatement() : undefined;
18846             return finishNode(node);
18847         }
18848         function parseDoStatement() {
18849             var node = createNode(228);
18850             parseExpected(86);
18851             node.statement = parseStatement();
18852             parseExpected(111);
18853             parseExpected(20);
18854             node.expression = allowInAnd(parseExpression);
18855             parseExpected(21);
18856             parseOptional(26);
18857             return finishNode(node);
18858         }
18859         function parseWhileStatement() {
18860             var node = createNode(229);
18861             parseExpected(111);
18862             parseExpected(20);
18863             node.expression = allowInAnd(parseExpression);
18864             parseExpected(21);
18865             node.statement = parseStatement();
18866             return finishNode(node);
18867         }
18868         function parseForOrForInOrForOfStatement() {
18869             var pos = getNodePos();
18870             parseExpected(93);
18871             var awaitToken = parseOptionalToken(127);
18872             parseExpected(20);
18873             var initializer;
18874             if (token() !== 26) {
18875                 if (token() === 109 || token() === 115 || token() === 81) {
18876                     initializer = parseVariableDeclarationList(true);
18877                 }
18878                 else {
18879                     initializer = disallowInAnd(parseExpression);
18880                 }
18881             }
18882             var forOrForInOrForOfStatement;
18883             if (awaitToken ? parseExpected(152) : parseOptional(152)) {
18884                 var forOfStatement = createNode(232, pos);
18885                 forOfStatement.awaitModifier = awaitToken;
18886                 forOfStatement.initializer = initializer;
18887                 forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher);
18888                 parseExpected(21);
18889                 forOrForInOrForOfStatement = forOfStatement;
18890             }
18891             else if (parseOptional(97)) {
18892                 var forInStatement = createNode(231, pos);
18893                 forInStatement.initializer = initializer;
18894                 forInStatement.expression = allowInAnd(parseExpression);
18895                 parseExpected(21);
18896                 forOrForInOrForOfStatement = forInStatement;
18897             }
18898             else {
18899                 var forStatement = createNode(230, pos);
18900                 forStatement.initializer = initializer;
18901                 parseExpected(26);
18902                 if (token() !== 26 && token() !== 21) {
18903                     forStatement.condition = allowInAnd(parseExpression);
18904                 }
18905                 parseExpected(26);
18906                 if (token() !== 21) {
18907                     forStatement.incrementor = allowInAnd(parseExpression);
18908                 }
18909                 parseExpected(21);
18910                 forOrForInOrForOfStatement = forStatement;
18911             }
18912             forOrForInOrForOfStatement.statement = parseStatement();
18913             return finishNode(forOrForInOrForOfStatement);
18914         }
18915         function parseBreakOrContinueStatement(kind) {
18916             var node = createNode(kind);
18917             parseExpected(kind === 234 ? 77 : 82);
18918             if (!canParseSemicolon()) {
18919                 node.label = parseIdentifier();
18920             }
18921             parseSemicolon();
18922             return finishNode(node);
18923         }
18924         function parseReturnStatement() {
18925             var node = createNode(235);
18926             parseExpected(101);
18927             if (!canParseSemicolon()) {
18928                 node.expression = allowInAnd(parseExpression);
18929             }
18930             parseSemicolon();
18931             return finishNode(node);
18932         }
18933         function parseWithStatement() {
18934             var node = createNode(236);
18935             parseExpected(112);
18936             parseExpected(20);
18937             node.expression = allowInAnd(parseExpression);
18938             parseExpected(21);
18939             node.statement = doInsideOfContext(16777216, parseStatement);
18940             return finishNode(node);
18941         }
18942         function parseCaseClause() {
18943             var node = createNode(277);
18944             parseExpected(78);
18945             node.expression = allowInAnd(parseExpression);
18946             parseExpected(58);
18947             node.statements = parseList(3, parseStatement);
18948             return finishNode(node);
18949         }
18950         function parseDefaultClause() {
18951             var node = createNode(278);
18952             parseExpected(84);
18953             parseExpected(58);
18954             node.statements = parseList(3, parseStatement);
18955             return finishNode(node);
18956         }
18957         function parseCaseOrDefaultClause() {
18958             return token() === 78 ? parseCaseClause() : parseDefaultClause();
18959         }
18960         function parseSwitchStatement() {
18961             var node = createNode(237);
18962             parseExpected(103);
18963             parseExpected(20);
18964             node.expression = allowInAnd(parseExpression);
18965             parseExpected(21);
18966             var caseBlock = createNode(251);
18967             parseExpected(18);
18968             caseBlock.clauses = parseList(2, parseCaseOrDefaultClause);
18969             parseExpected(19);
18970             node.caseBlock = finishNode(caseBlock);
18971             return finishNode(node);
18972         }
18973         function parseThrowStatement() {
18974             var node = createNode(239);
18975             parseExpected(105);
18976             node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression);
18977             parseSemicolon();
18978             return finishNode(node);
18979         }
18980         function parseTryStatement() {
18981             var node = createNode(240);
18982             parseExpected(107);
18983             node.tryBlock = parseBlock(false);
18984             node.catchClause = token() === 79 ? parseCatchClause() : undefined;
18985             if (!node.catchClause || token() === 92) {
18986                 parseExpected(92);
18987                 node.finallyBlock = parseBlock(false);
18988             }
18989             return finishNode(node);
18990         }
18991         function parseCatchClause() {
18992             var result = createNode(280);
18993             parseExpected(79);
18994             if (parseOptional(20)) {
18995                 result.variableDeclaration = parseVariableDeclaration();
18996                 parseExpected(21);
18997             }
18998             else {
18999                 result.variableDeclaration = undefined;
19000             }
19001             result.block = parseBlock(false);
19002             return finishNode(result);
19003         }
19004         function parseDebuggerStatement() {
19005             var node = createNode(241);
19006             parseExpected(83);
19007             parseSemicolon();
19008             return finishNode(node);
19009         }
19010         function parseExpressionOrLabeledStatement() {
19011             var node = createNodeWithJSDoc(token() === 75 ? 0 : 226);
19012             var expression = allowInAnd(parseExpression);
19013             if (expression.kind === 75 && parseOptional(58)) {
19014                 node.kind = 238;
19015                 node.label = expression;
19016                 node.statement = parseStatement();
19017             }
19018             else {
19019                 node.kind = 226;
19020                 node.expression = expression;
19021                 parseSemicolon();
19022             }
19023             return finishNode(node);
19024         }
19025         function nextTokenIsIdentifierOrKeywordOnSameLine() {
19026             nextToken();
19027             return ts.tokenIsIdentifierOrKeyword(token()) && !scanner.hasPrecedingLineBreak();
19028         }
19029         function nextTokenIsClassKeywordOnSameLine() {
19030             nextToken();
19031             return token() === 80 && !scanner.hasPrecedingLineBreak();
19032         }
19033         function nextTokenIsFunctionKeywordOnSameLine() {
19034             nextToken();
19035             return token() === 94 && !scanner.hasPrecedingLineBreak();
19036         }
19037         function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() {
19038             nextToken();
19039             return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 || token() === 9 || token() === 10) && !scanner.hasPrecedingLineBreak();
19040         }
19041         function isDeclaration() {
19042             while (true) {
19043                 switch (token()) {
19044                     case 109:
19045                     case 115:
19046                     case 81:
19047                     case 94:
19048                     case 80:
19049                     case 88:
19050                         return true;
19051                     case 114:
19052                     case 145:
19053                         return nextTokenIsIdentifierOnSameLine();
19054                     case 135:
19055                     case 136:
19056                         return nextTokenIsIdentifierOrStringLiteralOnSameLine();
19057                     case 122:
19058                     case 126:
19059                     case 130:
19060                     case 117:
19061                     case 118:
19062                     case 119:
19063                     case 138:
19064                         nextToken();
19065                         if (scanner.hasPrecedingLineBreak()) {
19066                             return false;
19067                         }
19068                         continue;
19069                     case 150:
19070                         nextToken();
19071                         return token() === 18 || token() === 75 || token() === 89;
19072                     case 96:
19073                         nextToken();
19074                         return token() === 10 || token() === 41 ||
19075                             token() === 18 || ts.tokenIsIdentifierOrKeyword(token());
19076                     case 89:
19077                         var currentToken_1 = nextToken();
19078                         if (currentToken_1 === 145) {
19079                             currentToken_1 = lookAhead(nextToken);
19080                         }
19081                         if (currentToken_1 === 62 || currentToken_1 === 41 ||
19082                             currentToken_1 === 18 || currentToken_1 === 84 ||
19083                             currentToken_1 === 123) {
19084                             return true;
19085                         }
19086                         continue;
19087                     case 120:
19088                         nextToken();
19089                         continue;
19090                     default:
19091                         return false;
19092                 }
19093             }
19094         }
19095         function isStartOfDeclaration() {
19096             return lookAhead(isDeclaration);
19097         }
19098         function isStartOfStatement() {
19099             switch (token()) {
19100                 case 59:
19101                 case 26:
19102                 case 18:
19103                 case 109:
19104                 case 115:
19105                 case 94:
19106                 case 80:
19107                 case 88:
19108                 case 95:
19109                 case 86:
19110                 case 111:
19111                 case 93:
19112                 case 82:
19113                 case 77:
19114                 case 101:
19115                 case 112:
19116                 case 103:
19117                 case 105:
19118                 case 107:
19119                 case 83:
19120                 case 79:
19121                 case 92:
19122                     return true;
19123                 case 96:
19124                     return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot);
19125                 case 81:
19126                 case 89:
19127                     return isStartOfDeclaration();
19128                 case 126:
19129                 case 130:
19130                 case 114:
19131                 case 135:
19132                 case 136:
19133                 case 145:
19134                 case 150:
19135                     return true;
19136                 case 119:
19137                 case 117:
19138                 case 118:
19139                 case 120:
19140                 case 138:
19141                     return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
19142                 default:
19143                     return isStartOfExpression();
19144             }
19145         }
19146         function nextTokenIsIdentifierOrStartOfDestructuring() {
19147             nextToken();
19148             return isIdentifier() || token() === 18 || token() === 22;
19149         }
19150         function isLetDeclaration() {
19151             return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring);
19152         }
19153         function parseStatement() {
19154             switch (token()) {
19155                 case 26:
19156                     return parseEmptyStatement();
19157                 case 18:
19158                     return parseBlock(false);
19159                 case 109:
19160                     return parseVariableStatement(createNodeWithJSDoc(242));
19161                 case 115:
19162                     if (isLetDeclaration()) {
19163                         return parseVariableStatement(createNodeWithJSDoc(242));
19164                     }
19165                     break;
19166                 case 94:
19167                     return parseFunctionDeclaration(createNodeWithJSDoc(244));
19168                 case 80:
19169                     return parseClassDeclaration(createNodeWithJSDoc(245));
19170                 case 95:
19171                     return parseIfStatement();
19172                 case 86:
19173                     return parseDoStatement();
19174                 case 111:
19175                     return parseWhileStatement();
19176                 case 93:
19177                     return parseForOrForInOrForOfStatement();
19178                 case 82:
19179                     return parseBreakOrContinueStatement(233);
19180                 case 77:
19181                     return parseBreakOrContinueStatement(234);
19182                 case 101:
19183                     return parseReturnStatement();
19184                 case 112:
19185                     return parseWithStatement();
19186                 case 103:
19187                     return parseSwitchStatement();
19188                 case 105:
19189                     return parseThrowStatement();
19190                 case 107:
19191                 case 79:
19192                 case 92:
19193                     return parseTryStatement();
19194                 case 83:
19195                     return parseDebuggerStatement();
19196                 case 59:
19197                     return parseDeclaration();
19198                 case 126:
19199                 case 114:
19200                 case 145:
19201                 case 135:
19202                 case 136:
19203                 case 130:
19204                 case 81:
19205                 case 88:
19206                 case 89:
19207                 case 96:
19208                 case 117:
19209                 case 118:
19210                 case 119:
19211                 case 122:
19212                 case 120:
19213                 case 138:
19214                 case 150:
19215                     if (isStartOfDeclaration()) {
19216                         return parseDeclaration();
19217                     }
19218                     break;
19219             }
19220             return parseExpressionOrLabeledStatement();
19221         }
19222         function isDeclareModifier(modifier) {
19223             return modifier.kind === 130;
19224         }
19225         function parseDeclaration() {
19226             var modifiers = lookAhead(function () { return (parseDecorators(), parseModifiers()); });
19227             var isAmbient = ts.some(modifiers, isDeclareModifier);
19228             if (isAmbient) {
19229                 var node_3 = tryReuseAmbientDeclaration();
19230                 if (node_3) {
19231                     return node_3;
19232                 }
19233             }
19234             var node = createNodeWithJSDoc(0);
19235             node.decorators = parseDecorators();
19236             node.modifiers = parseModifiers();
19237             if (isAmbient) {
19238                 for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
19239                     var m = _a[_i];
19240                     m.flags |= 8388608;
19241                 }
19242                 return doInsideOfContext(8388608, function () { return parseDeclarationWorker(node); });
19243             }
19244             else {
19245                 return parseDeclarationWorker(node);
19246             }
19247         }
19248         function tryReuseAmbientDeclaration() {
19249             return doInsideOfContext(8388608, function () {
19250                 var node = currentNode(parsingContext);
19251                 if (node) {
19252                     return consumeNode(node);
19253                 }
19254             });
19255         }
19256         function parseDeclarationWorker(node) {
19257             switch (token()) {
19258                 case 109:
19259                 case 115:
19260                 case 81:
19261                     return parseVariableStatement(node);
19262                 case 94:
19263                     return parseFunctionDeclaration(node);
19264                 case 80:
19265                     return parseClassDeclaration(node);
19266                 case 114:
19267                     return parseInterfaceDeclaration(node);
19268                 case 145:
19269                     return parseTypeAliasDeclaration(node);
19270                 case 88:
19271                     return parseEnumDeclaration(node);
19272                 case 150:
19273                 case 135:
19274                 case 136:
19275                     return parseModuleDeclaration(node);
19276                 case 96:
19277                     return parseImportDeclarationOrImportEqualsDeclaration(node);
19278                 case 89:
19279                     nextToken();
19280                     switch (token()) {
19281                         case 84:
19282                         case 62:
19283                             return parseExportAssignment(node);
19284                         case 123:
19285                             return parseNamespaceExportDeclaration(node);
19286                         default:
19287                             return parseExportDeclaration(node);
19288                     }
19289                 default:
19290                     if (node.decorators || node.modifiers) {
19291                         var missing = createMissingNode(264, true, ts.Diagnostics.Declaration_expected);
19292                         missing.pos = node.pos;
19293                         missing.decorators = node.decorators;
19294                         missing.modifiers = node.modifiers;
19295                         return finishNode(missing);
19296                     }
19297                     return undefined;
19298             }
19299         }
19300         function nextTokenIsIdentifierOrStringLiteralOnSameLine() {
19301             nextToken();
19302             return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10);
19303         }
19304         function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) {
19305             if (token() !== 18 && canParseSemicolon()) {
19306                 parseSemicolon();
19307                 return;
19308             }
19309             return parseFunctionBlock(flags, diagnosticMessage);
19310         }
19311         function parseArrayBindingElement() {
19312             if (token() === 27) {
19313                 return createNode(215);
19314             }
19315             var node = createNode(191);
19316             node.dotDotDotToken = parseOptionalToken(25);
19317             node.name = parseIdentifierOrPattern();
19318             node.initializer = parseInitializer();
19319             return finishNode(node);
19320         }
19321         function parseObjectBindingElement() {
19322             var node = createNode(191);
19323             node.dotDotDotToken = parseOptionalToken(25);
19324             var tokenIsIdentifier = isIdentifier();
19325             var propertyName = parsePropertyName();
19326             if (tokenIsIdentifier && token() !== 58) {
19327                 node.name = propertyName;
19328             }
19329             else {
19330                 parseExpected(58);
19331                 node.propertyName = propertyName;
19332                 node.name = parseIdentifierOrPattern();
19333             }
19334             node.initializer = parseInitializer();
19335             return finishNode(node);
19336         }
19337         function parseObjectBindingPattern() {
19338             var node = createNode(189);
19339             parseExpected(18);
19340             node.elements = parseDelimitedList(9, parseObjectBindingElement);
19341             parseExpected(19);
19342             return finishNode(node);
19343         }
19344         function parseArrayBindingPattern() {
19345             var node = createNode(190);
19346             parseExpected(22);
19347             node.elements = parseDelimitedList(10, parseArrayBindingElement);
19348             parseExpected(23);
19349             return finishNode(node);
19350         }
19351         function isIdentifierOrPrivateIdentifierOrPattern() {
19352             return token() === 18
19353                 || token() === 22
19354                 || token() === 76
19355                 || isIdentifier();
19356         }
19357         function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) {
19358             if (token() === 22) {
19359                 return parseArrayBindingPattern();
19360             }
19361             if (token() === 18) {
19362                 return parseObjectBindingPattern();
19363             }
19364             return parseIdentifier(undefined, privateIdentifierDiagnosticMessage);
19365         }
19366         function parseVariableDeclarationAllowExclamation() {
19367             return parseVariableDeclaration(true);
19368         }
19369         function parseVariableDeclaration(allowExclamation) {
19370             var node = createNode(242);
19371             node.name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations);
19372             if (allowExclamation && node.name.kind === 75 &&
19373                 token() === 53 && !scanner.hasPrecedingLineBreak()) {
19374                 node.exclamationToken = parseTokenNode();
19375             }
19376             node.type = parseTypeAnnotation();
19377             if (!isInOrOfKeyword(token())) {
19378                 node.initializer = parseInitializer();
19379             }
19380             return finishNode(node);
19381         }
19382         function parseVariableDeclarationList(inForStatementInitializer) {
19383             var node = createNode(243);
19384             switch (token()) {
19385                 case 109:
19386                     break;
19387                 case 115:
19388                     node.flags |= 1;
19389                     break;
19390                 case 81:
19391                     node.flags |= 2;
19392                     break;
19393                 default:
19394                     ts.Debug.fail();
19395             }
19396             nextToken();
19397             if (token() === 152 && lookAhead(canFollowContextualOfKeyword)) {
19398                 node.declarations = createMissingList();
19399             }
19400             else {
19401                 var savedDisallowIn = inDisallowInContext();
19402                 setDisallowInContext(inForStatementInitializer);
19403                 node.declarations = parseDelimitedList(8, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation);
19404                 setDisallowInContext(savedDisallowIn);
19405             }
19406             return finishNode(node);
19407         }
19408         function canFollowContextualOfKeyword() {
19409             return nextTokenIsIdentifier() && nextToken() === 21;
19410         }
19411         function parseVariableStatement(node) {
19412             node.kind = 225;
19413             node.declarationList = parseVariableDeclarationList(false);
19414             parseSemicolon();
19415             return finishNode(node);
19416         }
19417         function parseFunctionDeclaration(node) {
19418             node.kind = 244;
19419             parseExpected(94);
19420             node.asteriskToken = parseOptionalToken(41);
19421             node.name = hasModifierOfKind(node, 84) ? parseOptionalIdentifier() : parseIdentifier();
19422             var isGenerator = node.asteriskToken ? 1 : 0;
19423             var isAsync = hasModifierOfKind(node, 126) ? 2 : 0;
19424             fillSignature(58, isGenerator | isAsync, node);
19425             node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected);
19426             return finishNode(node);
19427         }
19428         function parseConstructorName() {
19429             if (token() === 129) {
19430                 return parseExpected(129);
19431             }
19432             if (token() === 10 && lookAhead(nextToken) === 20) {
19433                 return tryParse(function () {
19434                     var literalNode = parseLiteralNode();
19435                     return literalNode.text === "constructor" ? literalNode : undefined;
19436                 });
19437             }
19438         }
19439         function tryParseConstructorDeclaration(node) {
19440             return tryParse(function () {
19441                 if (parseConstructorName()) {
19442                     node.kind = 162;
19443                     fillSignature(58, 0, node);
19444                     node.body = parseFunctionBlockOrSemicolon(0, ts.Diagnostics.or_expected);
19445                     return finishNode(node);
19446                 }
19447             });
19448         }
19449         function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) {
19450             node.kind = 161;
19451             node.asteriskToken = asteriskToken;
19452             var isGenerator = asteriskToken ? 1 : 0;
19453             var isAsync = hasModifierOfKind(node, 126) ? 2 : 0;
19454             fillSignature(58, isGenerator | isAsync, node);
19455             node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage);
19456             return finishNode(node);
19457         }
19458         function parsePropertyDeclaration(node) {
19459             node.kind = 159;
19460             if (!node.questionToken && token() === 53 && !scanner.hasPrecedingLineBreak()) {
19461                 node.exclamationToken = parseTokenNode();
19462             }
19463             node.type = parseTypeAnnotation();
19464             node.initializer = doOutsideOfContext(8192 | 32768 | 4096, parseInitializer);
19465             parseSemicolon();
19466             return finishNode(node);
19467         }
19468         function parsePropertyOrMethodDeclaration(node) {
19469             var asteriskToken = parseOptionalToken(41);
19470             node.name = parsePropertyName();
19471             node.questionToken = parseOptionalToken(57);
19472             if (asteriskToken || token() === 20 || token() === 29) {
19473                 return parseMethodDeclaration(node, asteriskToken, ts.Diagnostics.or_expected);
19474             }
19475             return parsePropertyDeclaration(node);
19476         }
19477         function parseAccessorDeclaration(node, kind) {
19478             node.kind = kind;
19479             node.name = parsePropertyName();
19480             fillSignature(58, 0, node);
19481             node.body = parseFunctionBlockOrSemicolon(0);
19482             return finishNode(node);
19483         }
19484         function isClassMemberStart() {
19485             var idToken;
19486             if (token() === 59) {
19487                 return true;
19488             }
19489             while (ts.isModifierKind(token())) {
19490                 idToken = token();
19491                 if (ts.isClassMemberModifier(idToken)) {
19492                     return true;
19493                 }
19494                 nextToken();
19495             }
19496             if (token() === 41) {
19497                 return true;
19498             }
19499             if (isLiteralPropertyName()) {
19500                 idToken = token();
19501                 nextToken();
19502             }
19503             if (token() === 22) {
19504                 return true;
19505             }
19506             if (idToken !== undefined) {
19507                 if (!ts.isKeyword(idToken) || idToken === 142 || idToken === 131) {
19508                     return true;
19509                 }
19510                 switch (token()) {
19511                     case 20:
19512                     case 29:
19513                     case 53:
19514                     case 58:
19515                     case 62:
19516                     case 57:
19517                         return true;
19518                     default:
19519                         return canParseSemicolon();
19520                 }
19521             }
19522             return false;
19523         }
19524         function parseDecorators() {
19525             var list;
19526             var listPos = getNodePos();
19527             while (true) {
19528                 var decoratorStart = getNodePos();
19529                 if (!parseOptional(59)) {
19530                     break;
19531                 }
19532                 var decorator = createNode(157, decoratorStart);
19533                 decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher);
19534                 finishNode(decorator);
19535                 (list || (list = [])).push(decorator);
19536             }
19537             return list && createNodeArray(list, listPos);
19538         }
19539         function parseModifiers(permitInvalidConstAsModifier) {
19540             var list;
19541             var listPos = getNodePos();
19542             while (true) {
19543                 var modifierStart = scanner.getStartPos();
19544                 var modifierKind = token();
19545                 if (token() === 81 && permitInvalidConstAsModifier) {
19546                     if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) {
19547                         break;
19548                     }
19549                 }
19550                 else {
19551                     if (!parseAnyContextualModifier()) {
19552                         break;
19553                     }
19554                 }
19555                 var modifier = finishNode(createNode(modifierKind, modifierStart));
19556                 (list || (list = [])).push(modifier);
19557             }
19558             return list && createNodeArray(list, listPos);
19559         }
19560         function parseModifiersForArrowFunction() {
19561             var modifiers;
19562             if (token() === 126) {
19563                 var modifierStart = scanner.getStartPos();
19564                 var modifierKind = token();
19565                 nextToken();
19566                 var modifier = finishNode(createNode(modifierKind, modifierStart));
19567                 modifiers = createNodeArray([modifier], modifierStart);
19568             }
19569             return modifiers;
19570         }
19571         function parseClassElement() {
19572             if (token() === 26) {
19573                 var result = createNode(222);
19574                 nextToken();
19575                 return finishNode(result);
19576             }
19577             var node = createNodeWithJSDoc(0);
19578             node.decorators = parseDecorators();
19579             node.modifiers = parseModifiers(true);
19580             if (parseContextualModifier(131)) {
19581                 return parseAccessorDeclaration(node, 163);
19582             }
19583             if (parseContextualModifier(142)) {
19584                 return parseAccessorDeclaration(node, 164);
19585             }
19586             if (token() === 129 || token() === 10) {
19587                 var constructorDeclaration = tryParseConstructorDeclaration(node);
19588                 if (constructorDeclaration) {
19589                     return constructorDeclaration;
19590                 }
19591             }
19592             if (isIndexSignature()) {
19593                 return parseIndexSignatureDeclaration(node);
19594             }
19595             if (ts.tokenIsIdentifierOrKeyword(token()) ||
19596                 token() === 10 ||
19597                 token() === 8 ||
19598                 token() === 41 ||
19599                 token() === 22) {
19600                 var isAmbient = node.modifiers && ts.some(node.modifiers, isDeclareModifier);
19601                 if (isAmbient) {
19602                     for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
19603                         var m = _a[_i];
19604                         m.flags |= 8388608;
19605                     }
19606                     return doInsideOfContext(8388608, function () { return parsePropertyOrMethodDeclaration(node); });
19607                 }
19608                 else {
19609                     return parsePropertyOrMethodDeclaration(node);
19610                 }
19611             }
19612             if (node.decorators || node.modifiers) {
19613                 node.name = createMissingNode(75, true, ts.Diagnostics.Declaration_expected);
19614                 return parsePropertyDeclaration(node);
19615             }
19616             return ts.Debug.fail("Should not have attempted to parse class member declaration.");
19617         }
19618         function parseClassExpression() {
19619             return parseClassDeclarationOrExpression(createNodeWithJSDoc(0), 214);
19620         }
19621         function parseClassDeclaration(node) {
19622             return parseClassDeclarationOrExpression(node, 245);
19623         }
19624         function parseClassDeclarationOrExpression(node, kind) {
19625             node.kind = kind;
19626             parseExpected(80);
19627             node.name = parseNameOfClassDeclarationOrExpression();
19628             node.typeParameters = parseTypeParameters();
19629             node.heritageClauses = parseHeritageClauses();
19630             if (parseExpected(18)) {
19631                 node.members = parseClassMembers();
19632                 parseExpected(19);
19633             }
19634             else {
19635                 node.members = createMissingList();
19636             }
19637             return finishNode(node);
19638         }
19639         function parseNameOfClassDeclarationOrExpression() {
19640             return isIdentifier() && !isImplementsClause()
19641                 ? parseIdentifier()
19642                 : undefined;
19643         }
19644         function isImplementsClause() {
19645             return token() === 113 && lookAhead(nextTokenIsIdentifierOrKeyword);
19646         }
19647         function parseHeritageClauses() {
19648             if (isHeritageClause()) {
19649                 return parseList(22, parseHeritageClause);
19650             }
19651             return undefined;
19652         }
19653         function parseHeritageClause() {
19654             var tok = token();
19655             ts.Debug.assert(tok === 90 || tok === 113);
19656             var node = createNode(279);
19657             node.token = tok;
19658             nextToken();
19659             node.types = parseDelimitedList(7, parseExpressionWithTypeArguments);
19660             return finishNode(node);
19661         }
19662         function parseExpressionWithTypeArguments() {
19663             var node = createNode(216);
19664             node.expression = parseLeftHandSideExpressionOrHigher();
19665             node.typeArguments = tryParseTypeArguments();
19666             return finishNode(node);
19667         }
19668         function tryParseTypeArguments() {
19669             return token() === 29 ?
19670                 parseBracketedList(20, parseType, 29, 31) : undefined;
19671         }
19672         function isHeritageClause() {
19673             return token() === 90 || token() === 113;
19674         }
19675         function parseClassMembers() {
19676             return parseList(5, parseClassElement);
19677         }
19678         function parseInterfaceDeclaration(node) {
19679             node.kind = 246;
19680             parseExpected(114);
19681             node.name = parseIdentifier();
19682             node.typeParameters = parseTypeParameters();
19683             node.heritageClauses = parseHeritageClauses();
19684             node.members = parseObjectTypeMembers();
19685             return finishNode(node);
19686         }
19687         function parseTypeAliasDeclaration(node) {
19688             node.kind = 247;
19689             parseExpected(145);
19690             node.name = parseIdentifier();
19691             node.typeParameters = parseTypeParameters();
19692             parseExpected(62);
19693             node.type = parseType();
19694             parseSemicolon();
19695             return finishNode(node);
19696         }
19697         function parseEnumMember() {
19698             var node = createNodeWithJSDoc(284);
19699             node.name = parsePropertyName();
19700             node.initializer = allowInAnd(parseInitializer);
19701             return finishNode(node);
19702         }
19703         function parseEnumDeclaration(node) {
19704             node.kind = 248;
19705             parseExpected(88);
19706             node.name = parseIdentifier();
19707             if (parseExpected(18)) {
19708                 node.members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6, parseEnumMember); });
19709                 parseExpected(19);
19710             }
19711             else {
19712                 node.members = createMissingList();
19713             }
19714             return finishNode(node);
19715         }
19716         function parseModuleBlock() {
19717             var node = createNode(250);
19718             if (parseExpected(18)) {
19719                 node.statements = parseList(1, parseStatement);
19720                 parseExpected(19);
19721             }
19722             else {
19723                 node.statements = createMissingList();
19724             }
19725             return finishNode(node);
19726         }
19727         function parseModuleOrNamespaceDeclaration(node, flags) {
19728             node.kind = 249;
19729             var namespaceFlag = flags & 16;
19730             node.flags |= flags;
19731             node.name = parseIdentifier();
19732             node.body = parseOptional(24)
19733                 ? parseModuleOrNamespaceDeclaration(createNode(0), 4 | namespaceFlag)
19734                 : parseModuleBlock();
19735             return finishNode(node);
19736         }
19737         function parseAmbientExternalModuleDeclaration(node) {
19738             node.kind = 249;
19739             if (token() === 150) {
19740                 node.name = parseIdentifier();
19741                 node.flags |= 1024;
19742             }
19743             else {
19744                 node.name = parseLiteralNode();
19745                 node.name.text = internIdentifier(node.name.text);
19746             }
19747             if (token() === 18) {
19748                 node.body = parseModuleBlock();
19749             }
19750             else {
19751                 parseSemicolon();
19752             }
19753             return finishNode(node);
19754         }
19755         function parseModuleDeclaration(node) {
19756             var flags = 0;
19757             if (token() === 150) {
19758                 return parseAmbientExternalModuleDeclaration(node);
19759             }
19760             else if (parseOptional(136)) {
19761                 flags |= 16;
19762             }
19763             else {
19764                 parseExpected(135);
19765                 if (token() === 10) {
19766                     return parseAmbientExternalModuleDeclaration(node);
19767                 }
19768             }
19769             return parseModuleOrNamespaceDeclaration(node, flags);
19770         }
19771         function isExternalModuleReference() {
19772             return token() === 139 &&
19773                 lookAhead(nextTokenIsOpenParen);
19774         }
19775         function nextTokenIsOpenParen() {
19776             return nextToken() === 20;
19777         }
19778         function nextTokenIsSlash() {
19779             return nextToken() === 43;
19780         }
19781         function parseNamespaceExportDeclaration(node) {
19782             node.kind = 252;
19783             parseExpected(123);
19784             parseExpected(136);
19785             node.name = parseIdentifier();
19786             parseSemicolon();
19787             return finishNode(node);
19788         }
19789         function parseImportDeclarationOrImportEqualsDeclaration(node) {
19790             parseExpected(96);
19791             var afterImportPos = scanner.getStartPos();
19792             var identifier;
19793             if (isIdentifier()) {
19794                 identifier = parseIdentifier();
19795             }
19796             var isTypeOnly = false;
19797             if (token() !== 149 &&
19798                 (identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" &&
19799                 (isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
19800                 isTypeOnly = true;
19801                 identifier = isIdentifier() ? parseIdentifier() : undefined;
19802             }
19803             if (identifier && !tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration()) {
19804                 return parseImportEqualsDeclaration(node, identifier, isTypeOnly);
19805             }
19806             node.kind = 254;
19807             if (identifier ||
19808                 token() === 41 ||
19809                 token() === 18) {
19810                 node.importClause = parseImportClause(identifier, afterImportPos, isTypeOnly);
19811                 parseExpected(149);
19812             }
19813             node.moduleSpecifier = parseModuleSpecifier();
19814             parseSemicolon();
19815             return finishNode(node);
19816         }
19817         function tokenAfterImportDefinitelyProducesImportDeclaration() {
19818             return token() === 41 || token() === 18;
19819         }
19820         function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() {
19821             return token() === 27 || token() === 149;
19822         }
19823         function parseImportEqualsDeclaration(node, identifier, isTypeOnly) {
19824             node.kind = 253;
19825             node.name = identifier;
19826             parseExpected(62);
19827             node.moduleReference = parseModuleReference();
19828             parseSemicolon();
19829             var finished = finishNode(node);
19830             if (isTypeOnly) {
19831                 parseErrorAtRange(finished, ts.Diagnostics.Only_ECMAScript_imports_may_use_import_type);
19832             }
19833             return finished;
19834         }
19835         function parseImportClause(identifier, fullStart, isTypeOnly) {
19836             var importClause = createNode(255, fullStart);
19837             importClause.isTypeOnly = isTypeOnly;
19838             if (identifier) {
19839                 importClause.name = identifier;
19840             }
19841             if (!importClause.name ||
19842                 parseOptional(27)) {
19843                 importClause.namedBindings = token() === 41 ? parseNamespaceImport() : parseNamedImportsOrExports(257);
19844             }
19845             return finishNode(importClause);
19846         }
19847         function parseModuleReference() {
19848             return isExternalModuleReference()
19849                 ? parseExternalModuleReference()
19850                 : parseEntityName(false);
19851         }
19852         function parseExternalModuleReference() {
19853             var node = createNode(265);
19854             parseExpected(139);
19855             parseExpected(20);
19856             node.expression = parseModuleSpecifier();
19857             parseExpected(21);
19858             return finishNode(node);
19859         }
19860         function parseModuleSpecifier() {
19861             if (token() === 10) {
19862                 var result = parseLiteralNode();
19863                 result.text = internIdentifier(result.text);
19864                 return result;
19865             }
19866             else {
19867                 return parseExpression();
19868             }
19869         }
19870         function parseNamespaceImport() {
19871             var namespaceImport = createNode(256);
19872             parseExpected(41);
19873             parseExpected(123);
19874             namespaceImport.name = parseIdentifier();
19875             return finishNode(namespaceImport);
19876         }
19877         function parseNamedImportsOrExports(kind) {
19878             var node = createNode(kind);
19879             node.elements = parseBracketedList(23, kind === 257 ? parseImportSpecifier : parseExportSpecifier, 18, 19);
19880             return finishNode(node);
19881         }
19882         function parseExportSpecifier() {
19883             return parseImportOrExportSpecifier(263);
19884         }
19885         function parseImportSpecifier() {
19886             return parseImportOrExportSpecifier(258);
19887         }
19888         function parseImportOrExportSpecifier(kind) {
19889             var node = createNode(kind);
19890             var checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier();
19891             var checkIdentifierStart = scanner.getTokenPos();
19892             var checkIdentifierEnd = scanner.getTextPos();
19893             var identifierName = parseIdentifierName();
19894             if (token() === 123) {
19895                 node.propertyName = identifierName;
19896                 parseExpected(123);
19897                 checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier();
19898                 checkIdentifierStart = scanner.getTokenPos();
19899                 checkIdentifierEnd = scanner.getTextPos();
19900                 node.name = parseIdentifierName();
19901             }
19902             else {
19903                 node.name = identifierName;
19904             }
19905             if (kind === 258 && checkIdentifierIsKeyword) {
19906                 parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected);
19907             }
19908             return finishNode(node);
19909         }
19910         function parseNamespaceExport(pos) {
19911             var node = createNode(262, pos);
19912             node.name = parseIdentifier();
19913             return finishNode(node);
19914         }
19915         function parseExportDeclaration(node) {
19916             node.kind = 260;
19917             node.isTypeOnly = parseOptional(145);
19918             var namespaceExportPos = scanner.getStartPos();
19919             if (parseOptional(41)) {
19920                 if (parseOptional(123)) {
19921                     node.exportClause = parseNamespaceExport(namespaceExportPos);
19922                 }
19923                 parseExpected(149);
19924                 node.moduleSpecifier = parseModuleSpecifier();
19925             }
19926             else {
19927                 node.exportClause = parseNamedImportsOrExports(261);
19928                 if (token() === 149 || (token() === 10 && !scanner.hasPrecedingLineBreak())) {
19929                     parseExpected(149);
19930                     node.moduleSpecifier = parseModuleSpecifier();
19931                 }
19932             }
19933             parseSemicolon();
19934             return finishNode(node);
19935         }
19936         function parseExportAssignment(node) {
19937             node.kind = 259;
19938             if (parseOptional(62)) {
19939                 node.isExportEquals = true;
19940             }
19941             else {
19942                 parseExpected(84);
19943             }
19944             node.expression = parseAssignmentExpressionOrHigher();
19945             parseSemicolon();
19946             return finishNode(node);
19947         }
19948         function setExternalModuleIndicator(sourceFile) {
19949             sourceFile.externalModuleIndicator =
19950                 ts.forEach(sourceFile.statements, isAnExternalModuleIndicatorNode) ||
19951                     getImportMetaIfNecessary(sourceFile);
19952         }
19953         function isAnExternalModuleIndicatorNode(node) {
19954             return hasModifierOfKind(node, 89)
19955                 || node.kind === 253 && node.moduleReference.kind === 265
19956                 || node.kind === 254
19957                 || node.kind === 259
19958                 || node.kind === 260 ? node : undefined;
19959         }
19960         function getImportMetaIfNecessary(sourceFile) {
19961             return sourceFile.flags & 2097152 ?
19962                 walkTreeForExternalModuleIndicators(sourceFile) :
19963                 undefined;
19964         }
19965         function walkTreeForExternalModuleIndicators(node) {
19966             return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators);
19967         }
19968         function hasModifierOfKind(node, kind) {
19969             return ts.some(node.modifiers, function (m) { return m.kind === kind; });
19970         }
19971         function isImportMeta(node) {
19972             return ts.isMetaProperty(node) && node.keywordToken === 96 && node.name.escapedText === "meta";
19973         }
19974         var JSDocParser;
19975         (function (JSDocParser) {
19976             function parseJSDocTypeExpressionForTests(content, start, length) {
19977                 initializeState(content, 99, undefined, 1);
19978                 sourceFile = createSourceFile("file.js", 99, 1, false);
19979                 scanner.setText(content, start, length);
19980                 currentToken = scanner.scan();
19981                 var jsDocTypeExpression = parseJSDocTypeExpression();
19982                 var diagnostics = parseDiagnostics;
19983                 clearState();
19984                 return jsDocTypeExpression ? { jsDocTypeExpression: jsDocTypeExpression, diagnostics: diagnostics } : undefined;
19985             }
19986             JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests;
19987             function parseJSDocTypeExpression(mayOmitBraces) {
19988                 var result = createNode(294);
19989                 var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18);
19990                 result.type = doInsideOfContext(4194304, parseJSDocType);
19991                 if (!mayOmitBraces || hasBrace) {
19992                     parseExpectedJSDoc(19);
19993                 }
19994                 fixupParentReferences(result);
19995                 return finishNode(result);
19996             }
19997             JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression;
19998             function parseIsolatedJSDocComment(content, start, length) {
19999                 initializeState(content, 99, undefined, 1);
20000                 sourceFile = { languageVariant: 0, text: content };
20001                 var jsDoc = doInsideOfContext(4194304, function () { return parseJSDocCommentWorker(start, length); });
20002                 var diagnostics = parseDiagnostics;
20003                 clearState();
20004                 return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined;
20005             }
20006             JSDocParser.parseIsolatedJSDocComment = parseIsolatedJSDocComment;
20007             function parseJSDocComment(parent, start, length) {
20008                 var _a;
20009                 var saveToken = currentToken;
20010                 var saveParseDiagnosticsLength = parseDiagnostics.length;
20011                 var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
20012                 var comment = doInsideOfContext(4194304, function () { return parseJSDocCommentWorker(start, length); });
20013                 if (comment) {
20014                     comment.parent = parent;
20015                 }
20016                 if (contextFlags & 131072) {
20017                     if (!sourceFile.jsDocDiagnostics) {
20018                         sourceFile.jsDocDiagnostics = [];
20019                     }
20020                     (_a = sourceFile.jsDocDiagnostics).push.apply(_a, parseDiagnostics);
20021                 }
20022                 currentToken = saveToken;
20023                 parseDiagnostics.length = saveParseDiagnosticsLength;
20024                 parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode;
20025                 return comment;
20026             }
20027             JSDocParser.parseJSDocComment = parseJSDocComment;
20028             function parseJSDocCommentWorker(start, length) {
20029                 if (start === void 0) { start = 0; }
20030                 var content = sourceText;
20031                 var end = length === undefined ? content.length : start + length;
20032                 length = end - start;
20033                 ts.Debug.assert(start >= 0);
20034                 ts.Debug.assert(start <= end);
20035                 ts.Debug.assert(end <= content.length);
20036                 if (!isJSDocLikeText(content, start)) {
20037                     return undefined;
20038                 }
20039                 var tags;
20040                 var tagsPos;
20041                 var tagsEnd;
20042                 var comments = [];
20043                 return scanner.scanRange(start + 3, length - 5, function () {
20044                     var state = 1;
20045                     var margin;
20046                     var indent = start - Math.max(content.lastIndexOf("\n", start), 0) + 4;
20047                     function pushComment(text) {
20048                         if (!margin) {
20049                             margin = indent;
20050                         }
20051                         comments.push(text);
20052                         indent += text.length;
20053                     }
20054                     nextTokenJSDoc();
20055                     while (parseOptionalJsdoc(5))
20056                         ;
20057                     if (parseOptionalJsdoc(4)) {
20058                         state = 0;
20059                         indent = 0;
20060                     }
20061                     loop: while (true) {
20062                         switch (token()) {
20063                             case 59:
20064                                 if (state === 0 || state === 1) {
20065                                     removeTrailingWhitespace(comments);
20066                                     addTag(parseTag(indent));
20067                                     state = 0;
20068                                     margin = undefined;
20069                                 }
20070                                 else {
20071                                     pushComment(scanner.getTokenText());
20072                                 }
20073                                 break;
20074                             case 4:
20075                                 comments.push(scanner.getTokenText());
20076                                 state = 0;
20077                                 indent = 0;
20078                                 break;
20079                             case 41:
20080                                 var asterisk = scanner.getTokenText();
20081                                 if (state === 1 || state === 2) {
20082                                     state = 2;
20083                                     pushComment(asterisk);
20084                                 }
20085                                 else {
20086                                     state = 1;
20087                                     indent += asterisk.length;
20088                                 }
20089                                 break;
20090                             case 5:
20091                                 var whitespace = scanner.getTokenText();
20092                                 if (state === 2) {
20093                                     comments.push(whitespace);
20094                                 }
20095                                 else if (margin !== undefined && indent + whitespace.length > margin) {
20096                                     comments.push(whitespace.slice(margin - indent - 1));
20097                                 }
20098                                 indent += whitespace.length;
20099                                 break;
20100                             case 1:
20101                                 break loop;
20102                             default:
20103                                 state = 2;
20104                                 pushComment(scanner.getTokenText());
20105                                 break;
20106                         }
20107                         nextTokenJSDoc();
20108                     }
20109                     removeLeadingNewlines(comments);
20110                     removeTrailingWhitespace(comments);
20111                     return createJSDocComment();
20112                 });
20113                 function removeLeadingNewlines(comments) {
20114                     while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) {
20115                         comments.shift();
20116                     }
20117                 }
20118                 function removeTrailingWhitespace(comments) {
20119                     while (comments.length && comments[comments.length - 1].trim() === "") {
20120                         comments.pop();
20121                     }
20122                 }
20123                 function createJSDocComment() {
20124                     var result = createNode(303, start);
20125                     result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd);
20126                     result.comment = comments.length ? comments.join("") : undefined;
20127                     return finishNode(result, end);
20128                 }
20129                 function isNextNonwhitespaceTokenEndOfFile() {
20130                     while (true) {
20131                         nextTokenJSDoc();
20132                         if (token() === 1) {
20133                             return true;
20134                         }
20135                         if (!(token() === 5 || token() === 4)) {
20136                             return false;
20137                         }
20138                     }
20139                 }
20140                 function skipWhitespace() {
20141                     if (token() === 5 || token() === 4) {
20142                         if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) {
20143                             return;
20144                         }
20145                     }
20146                     while (token() === 5 || token() === 4) {
20147                         nextTokenJSDoc();
20148                     }
20149                 }
20150                 function skipWhitespaceOrAsterisk() {
20151                     if (token() === 5 || token() === 4) {
20152                         if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) {
20153                             return "";
20154                         }
20155                     }
20156                     var precedingLineBreak = scanner.hasPrecedingLineBreak();
20157                     var seenLineBreak = false;
20158                     var indentText = "";
20159                     while ((precedingLineBreak && token() === 41) || token() === 5 || token() === 4) {
20160                         indentText += scanner.getTokenText();
20161                         if (token() === 4) {
20162                             precedingLineBreak = true;
20163                             seenLineBreak = true;
20164                             indentText = "";
20165                         }
20166                         else if (token() === 41) {
20167                             precedingLineBreak = false;
20168                         }
20169                         nextTokenJSDoc();
20170                     }
20171                     return seenLineBreak ? indentText : "";
20172                 }
20173                 function parseTag(margin) {
20174                     ts.Debug.assert(token() === 59);
20175                     var start = scanner.getTokenPos();
20176                     nextTokenJSDoc();
20177                     var tagName = parseJSDocIdentifierName(undefined);
20178                     var indentText = skipWhitespaceOrAsterisk();
20179                     var tag;
20180                     switch (tagName.escapedText) {
20181                         case "author":
20182                             tag = parseAuthorTag(start, tagName, margin);
20183                             break;
20184                         case "implements":
20185                             tag = parseImplementsTag(start, tagName);
20186                             break;
20187                         case "augments":
20188                         case "extends":
20189                             tag = parseAugmentsTag(start, tagName);
20190                             break;
20191                         case "class":
20192                         case "constructor":
20193                             tag = parseSimpleTag(start, 310, tagName);
20194                             break;
20195                         case "public":
20196                             tag = parseSimpleTag(start, 311, tagName);
20197                             break;
20198                         case "private":
20199                             tag = parseSimpleTag(start, 312, tagName);
20200                             break;
20201                         case "protected":
20202                             tag = parseSimpleTag(start, 313, tagName);
20203                             break;
20204                         case "readonly":
20205                             tag = parseSimpleTag(start, 314, tagName);
20206                             break;
20207                         case "this":
20208                             tag = parseThisTag(start, tagName);
20209                             break;
20210                         case "enum":
20211                             tag = parseEnumTag(start, tagName);
20212                             break;
20213                         case "arg":
20214                         case "argument":
20215                         case "param":
20216                             return parseParameterOrPropertyTag(start, tagName, 2, margin);
20217                         case "return":
20218                         case "returns":
20219                             tag = parseReturnTag(start, tagName);
20220                             break;
20221                         case "template":
20222                             tag = parseTemplateTag(start, tagName);
20223                             break;
20224                         case "type":
20225                             tag = parseTypeTag(start, tagName);
20226                             break;
20227                         case "typedef":
20228                             tag = parseTypedefTag(start, tagName, margin);
20229                             break;
20230                         case "callback":
20231                             tag = parseCallbackTag(start, tagName, margin);
20232                             break;
20233                         default:
20234                             tag = parseUnknownTag(start, tagName);
20235                             break;
20236                     }
20237                     if (!tag.comment) {
20238                         if (!indentText) {
20239                             margin += tag.end - tag.pos;
20240                         }
20241                         tag.comment = parseTagComments(margin, indentText.slice(margin));
20242                     }
20243                     return tag;
20244                 }
20245                 function parseTagComments(indent, initialMargin) {
20246                     var comments = [];
20247                     var state = 0;
20248                     var margin;
20249                     function pushComment(text) {
20250                         if (!margin) {
20251                             margin = indent;
20252                         }
20253                         comments.push(text);
20254                         indent += text.length;
20255                     }
20256                     if (initialMargin !== undefined) {
20257                         if (initialMargin !== "") {
20258                             pushComment(initialMargin);
20259                         }
20260                         state = 1;
20261                     }
20262                     var tok = token();
20263                     loop: while (true) {
20264                         switch (tok) {
20265                             case 4:
20266                                 if (state >= 1) {
20267                                     state = 0;
20268                                     comments.push(scanner.getTokenText());
20269                                 }
20270                                 indent = 0;
20271                                 break;
20272                             case 59:
20273                                 if (state === 3) {
20274                                     comments.push(scanner.getTokenText());
20275                                     break;
20276                                 }
20277                                 scanner.setTextPos(scanner.getTextPos() - 1);
20278                             case 1:
20279                                 break loop;
20280                             case 5:
20281                                 if (state === 2 || state === 3) {
20282                                     pushComment(scanner.getTokenText());
20283                                 }
20284                                 else {
20285                                     var whitespace = scanner.getTokenText();
20286                                     if (margin !== undefined && indent + whitespace.length > margin) {
20287                                         comments.push(whitespace.slice(margin - indent));
20288                                     }
20289                                     indent += whitespace.length;
20290                                 }
20291                                 break;
20292                             case 18:
20293                                 state = 2;
20294                                 if (lookAhead(function () { return nextTokenJSDoc() === 59 && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) {
20295                                     pushComment(scanner.getTokenText());
20296                                     nextTokenJSDoc();
20297                                     pushComment(scanner.getTokenText());
20298                                     nextTokenJSDoc();
20299                                 }
20300                                 pushComment(scanner.getTokenText());
20301                                 break;
20302                             case 61:
20303                                 if (state === 3) {
20304                                     state = 2;
20305                                 }
20306                                 else {
20307                                     state = 3;
20308                                 }
20309                                 pushComment(scanner.getTokenText());
20310                                 break;
20311                             case 41:
20312                                 if (state === 0) {
20313                                     state = 1;
20314                                     indent += 1;
20315                                     break;
20316                                 }
20317                             default:
20318                                 if (state !== 3) {
20319                                     state = 2;
20320                                 }
20321                                 pushComment(scanner.getTokenText());
20322                                 break;
20323                         }
20324                         tok = nextTokenJSDoc();
20325                     }
20326                     removeLeadingNewlines(comments);
20327                     removeTrailingWhitespace(comments);
20328                     return comments.length === 0 ? undefined : comments.join("");
20329                 }
20330                 function parseUnknownTag(start, tagName) {
20331                     var result = createNode(306, start);
20332                     result.tagName = tagName;
20333                     return finishNode(result);
20334                 }
20335                 function addTag(tag) {
20336                     if (!tag) {
20337                         return;
20338                     }
20339                     if (!tags) {
20340                         tags = [tag];
20341                         tagsPos = tag.pos;
20342                     }
20343                     else {
20344                         tags.push(tag);
20345                     }
20346                     tagsEnd = tag.end;
20347                 }
20348                 function tryParseTypeExpression() {
20349                     skipWhitespaceOrAsterisk();
20350                     return token() === 18 ? parseJSDocTypeExpression() : undefined;
20351                 }
20352                 function parseBracketNameInPropertyAndParamTag() {
20353                     var isBracketed = parseOptionalJsdoc(22);
20354                     if (isBracketed) {
20355                         skipWhitespace();
20356                     }
20357                     var isBackquoted = parseOptionalJsdoc(61);
20358                     var name = parseJSDocEntityName();
20359                     if (isBackquoted) {
20360                         parseExpectedTokenJSDoc(61);
20361                     }
20362                     if (isBracketed) {
20363                         skipWhitespace();
20364                         if (parseOptionalToken(62)) {
20365                             parseExpression();
20366                         }
20367                         parseExpected(23);
20368                     }
20369                     return { name: name, isBracketed: isBracketed };
20370                 }
20371                 function isObjectOrObjectArrayTypeReference(node) {
20372                     switch (node.kind) {
20373                         case 141:
20374                             return true;
20375                         case 174:
20376                             return isObjectOrObjectArrayTypeReference(node.elementType);
20377                         default:
20378                             return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments;
20379                     }
20380                 }
20381                 function parseParameterOrPropertyTag(start, tagName, target, indent) {
20382                     var typeExpression = tryParseTypeExpression();
20383                     var isNameFirst = !typeExpression;
20384                     skipWhitespaceOrAsterisk();
20385                     var _a = parseBracketNameInPropertyAndParamTag(), name = _a.name, isBracketed = _a.isBracketed;
20386                     skipWhitespace();
20387                     if (isNameFirst) {
20388                         typeExpression = tryParseTypeExpression();
20389                     }
20390                     var result = target === 1 ?
20391                         createNode(323, start) :
20392                         createNode(317, start);
20393                     var comment = parseTagComments(indent + scanner.getStartPos() - start);
20394                     var nestedTypeLiteral = target !== 4 && parseNestedTypeLiteral(typeExpression, name, target, indent);
20395                     if (nestedTypeLiteral) {
20396                         typeExpression = nestedTypeLiteral;
20397                         isNameFirst = true;
20398                     }
20399                     result.tagName = tagName;
20400                     result.typeExpression = typeExpression;
20401                     result.name = name;
20402                     result.isNameFirst = isNameFirst;
20403                     result.isBracketed = isBracketed;
20404                     result.comment = comment;
20405                     return finishNode(result);
20406                 }
20407                 function parseNestedTypeLiteral(typeExpression, name, target, indent) {
20408                     if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) {
20409                         var typeLiteralExpression = createNode(294, scanner.getTokenPos());
20410                         var child = void 0;
20411                         var jsdocTypeLiteral = void 0;
20412                         var start_3 = scanner.getStartPos();
20413                         var children = void 0;
20414                         while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) {
20415                             if (child.kind === 317 || child.kind === 323) {
20416                                 children = ts.append(children, child);
20417                             }
20418                         }
20419                         if (children) {
20420                             jsdocTypeLiteral = createNode(304, start_3);
20421                             jsdocTypeLiteral.jsDocPropertyTags = children;
20422                             if (typeExpression.type.kind === 174) {
20423                                 jsdocTypeLiteral.isArrayType = true;
20424                             }
20425                             typeLiteralExpression.type = finishNode(jsdocTypeLiteral);
20426                             return finishNode(typeLiteralExpression);
20427                         }
20428                     }
20429                 }
20430                 function parseReturnTag(start, tagName) {
20431                     if (ts.some(tags, ts.isJSDocReturnTag)) {
20432                         parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
20433                     }
20434                     var result = createNode(318, start);
20435                     result.tagName = tagName;
20436                     result.typeExpression = tryParseTypeExpression();
20437                     return finishNode(result);
20438                 }
20439                 function parseTypeTag(start, tagName) {
20440                     if (ts.some(tags, ts.isJSDocTypeTag)) {
20441                         parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
20442                     }
20443                     var result = createNode(320, start);
20444                     result.tagName = tagName;
20445                     result.typeExpression = parseJSDocTypeExpression(true);
20446                     return finishNode(result);
20447                 }
20448                 function parseAuthorTag(start, tagName, indent) {
20449                     var result = createNode(309, start);
20450                     result.tagName = tagName;
20451                     var authorInfoWithEmail = tryParse(function () { return tryParseAuthorNameAndEmail(); });
20452                     if (!authorInfoWithEmail) {
20453                         return finishNode(result);
20454                     }
20455                     result.comment = authorInfoWithEmail;
20456                     if (lookAhead(function () { return nextToken() !== 4; })) {
20457                         var comment = parseTagComments(indent);
20458                         if (comment) {
20459                             result.comment += comment;
20460                         }
20461                     }
20462                     return finishNode(result);
20463                 }
20464                 function tryParseAuthorNameAndEmail() {
20465                     var comments = [];
20466                     var seenLessThan = false;
20467                     var seenGreaterThan = false;
20468                     var token = scanner.getToken();
20469                     loop: while (true) {
20470                         switch (token) {
20471                             case 75:
20472                             case 5:
20473                             case 24:
20474                             case 59:
20475                                 comments.push(scanner.getTokenText());
20476                                 break;
20477                             case 29:
20478                                 if (seenLessThan || seenGreaterThan) {
20479                                     return;
20480                                 }
20481                                 seenLessThan = true;
20482                                 comments.push(scanner.getTokenText());
20483                                 break;
20484                             case 31:
20485                                 if (!seenLessThan || seenGreaterThan) {
20486                                     return;
20487                                 }
20488                                 seenGreaterThan = true;
20489                                 comments.push(scanner.getTokenText());
20490                                 scanner.setTextPos(scanner.getTokenPos() + 1);
20491                                 break loop;
20492                             case 4:
20493                             case 1:
20494                                 break loop;
20495                         }
20496                         token = nextTokenJSDoc();
20497                     }
20498                     if (seenLessThan && seenGreaterThan) {
20499                         return comments.length === 0 ? undefined : comments.join("");
20500                     }
20501                 }
20502                 function parseImplementsTag(start, tagName) {
20503                     var result = createNode(308, start);
20504                     result.tagName = tagName;
20505                     result.class = parseExpressionWithTypeArgumentsForAugments();
20506                     return finishNode(result);
20507                 }
20508                 function parseAugmentsTag(start, tagName) {
20509                     var result = createNode(307, start);
20510                     result.tagName = tagName;
20511                     result.class = parseExpressionWithTypeArgumentsForAugments();
20512                     return finishNode(result);
20513                 }
20514                 function parseExpressionWithTypeArgumentsForAugments() {
20515                     var usedBrace = parseOptional(18);
20516                     var node = createNode(216);
20517                     node.expression = parsePropertyAccessEntityNameExpression();
20518                     node.typeArguments = tryParseTypeArguments();
20519                     var res = finishNode(node);
20520                     if (usedBrace) {
20521                         parseExpected(19);
20522                     }
20523                     return res;
20524                 }
20525                 function parsePropertyAccessEntityNameExpression() {
20526                     var node = parseJSDocIdentifierName();
20527                     while (parseOptional(24)) {
20528                         var prop = createNode(194, node.pos);
20529                         prop.expression = node;
20530                         prop.name = parseJSDocIdentifierName();
20531                         node = finishNode(prop);
20532                     }
20533                     return node;
20534                 }
20535                 function parseSimpleTag(start, kind, tagName) {
20536                     var tag = createNode(kind, start);
20537                     tag.tagName = tagName;
20538                     return finishNode(tag);
20539                 }
20540                 function parseThisTag(start, tagName) {
20541                     var tag = createNode(319, start);
20542                     tag.tagName = tagName;
20543                     tag.typeExpression = parseJSDocTypeExpression(true);
20544                     skipWhitespace();
20545                     return finishNode(tag);
20546                 }
20547                 function parseEnumTag(start, tagName) {
20548                     var tag = createNode(316, start);
20549                     tag.tagName = tagName;
20550                     tag.typeExpression = parseJSDocTypeExpression(true);
20551                     skipWhitespace();
20552                     return finishNode(tag);
20553                 }
20554                 function parseTypedefTag(start, tagName, indent) {
20555                     var typeExpression = tryParseTypeExpression();
20556                     skipWhitespaceOrAsterisk();
20557                     var typedefTag = createNode(322, start);
20558                     typedefTag.tagName = tagName;
20559                     typedefTag.fullName = parseJSDocTypeNameWithNamespace();
20560                     typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName);
20561                     skipWhitespace();
20562                     typedefTag.comment = parseTagComments(indent);
20563                     typedefTag.typeExpression = typeExpression;
20564                     var end;
20565                     if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) {
20566                         var child = void 0;
20567                         var jsdocTypeLiteral = void 0;
20568                         var childTypeTag = void 0;
20569                         while (child = tryParse(function () { return parseChildPropertyTag(indent); })) {
20570                             if (!jsdocTypeLiteral) {
20571                                 jsdocTypeLiteral = createNode(304, start);
20572                             }
20573                             if (child.kind === 320) {
20574                                 if (childTypeTag) {
20575                                     break;
20576                                 }
20577                                 else {
20578                                     childTypeTag = child;
20579                                 }
20580                             }
20581                             else {
20582                                 jsdocTypeLiteral.jsDocPropertyTags = ts.append(jsdocTypeLiteral.jsDocPropertyTags, child);
20583                             }
20584                         }
20585                         if (jsdocTypeLiteral) {
20586                             if (typeExpression && typeExpression.type.kind === 174) {
20587                                 jsdocTypeLiteral.isArrayType = true;
20588                             }
20589                             typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ?
20590                                 childTypeTag.typeExpression :
20591                                 finishNode(jsdocTypeLiteral);
20592                             end = typedefTag.typeExpression.end;
20593                         }
20594                     }
20595                     return finishNode(typedefTag, end || typedefTag.comment !== undefined ? scanner.getStartPos() : (typedefTag.fullName || typedefTag.typeExpression || typedefTag.tagName).end);
20596                 }
20597                 function parseJSDocTypeNameWithNamespace(nested) {
20598                     var pos = scanner.getTokenPos();
20599                     if (!ts.tokenIsIdentifierOrKeyword(token())) {
20600                         return undefined;
20601                     }
20602                     var typeNameOrNamespaceName = parseJSDocIdentifierName();
20603                     if (parseOptional(24)) {
20604                         var jsDocNamespaceNode = createNode(249, pos);
20605                         if (nested) {
20606                             jsDocNamespaceNode.flags |= 4;
20607                         }
20608                         jsDocNamespaceNode.name = typeNameOrNamespaceName;
20609                         jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(true);
20610                         return finishNode(jsDocNamespaceNode);
20611                     }
20612                     if (nested) {
20613                         typeNameOrNamespaceName.isInJSDocNamespace = true;
20614                     }
20615                     return typeNameOrNamespaceName;
20616                 }
20617                 function parseCallbackTag(start, tagName, indent) {
20618                     var callbackTag = createNode(315, start);
20619                     callbackTag.tagName = tagName;
20620                     callbackTag.fullName = parseJSDocTypeNameWithNamespace();
20621                     callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName);
20622                     skipWhitespace();
20623                     callbackTag.comment = parseTagComments(indent);
20624                     var child;
20625                     var jsdocSignature = createNode(305, start);
20626                     jsdocSignature.parameters = [];
20627                     while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4, indent); })) {
20628                         jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child);
20629                     }
20630                     var returnTag = tryParse(function () {
20631                         if (parseOptionalJsdoc(59)) {
20632                             var tag = parseTag(indent);
20633                             if (tag && tag.kind === 318) {
20634                                 return tag;
20635                             }
20636                         }
20637                     });
20638                     if (returnTag) {
20639                         jsdocSignature.type = returnTag;
20640                     }
20641                     callbackTag.typeExpression = finishNode(jsdocSignature);
20642                     return finishNode(callbackTag);
20643                 }
20644                 function getJSDocTypeAliasName(fullName) {
20645                     if (fullName) {
20646                         var rightNode = fullName;
20647                         while (true) {
20648                             if (ts.isIdentifier(rightNode) || !rightNode.body) {
20649                                 return ts.isIdentifier(rightNode) ? rightNode : rightNode.name;
20650                             }
20651                             rightNode = rightNode.body;
20652                         }
20653                     }
20654                 }
20655                 function escapedTextsEqual(a, b) {
20656                     while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) {
20657                         if (!ts.isIdentifier(a) && !ts.isIdentifier(b) && a.right.escapedText === b.right.escapedText) {
20658                             a = a.left;
20659                             b = b.left;
20660                         }
20661                         else {
20662                             return false;
20663                         }
20664                     }
20665                     return a.escapedText === b.escapedText;
20666                 }
20667                 function parseChildPropertyTag(indent) {
20668                     return parseChildParameterOrPropertyTag(1, indent);
20669                 }
20670                 function parseChildParameterOrPropertyTag(target, indent, name) {
20671                     var canParseTag = true;
20672                     var seenAsterisk = false;
20673                     while (true) {
20674                         switch (nextTokenJSDoc()) {
20675                             case 59:
20676                                 if (canParseTag) {
20677                                     var child = tryParseChildTag(target, indent);
20678                                     if (child && (child.kind === 317 || child.kind === 323) &&
20679                                         target !== 4 &&
20680                                         name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) {
20681                                         return false;
20682                                     }
20683                                     return child;
20684                                 }
20685                                 seenAsterisk = false;
20686                                 break;
20687                             case 4:
20688                                 canParseTag = true;
20689                                 seenAsterisk = false;
20690                                 break;
20691                             case 41:
20692                                 if (seenAsterisk) {
20693                                     canParseTag = false;
20694                                 }
20695                                 seenAsterisk = true;
20696                                 break;
20697                             case 75:
20698                                 canParseTag = false;
20699                                 break;
20700                             case 1:
20701                                 return false;
20702                         }
20703                     }
20704                 }
20705                 function tryParseChildTag(target, indent) {
20706                     ts.Debug.assert(token() === 59);
20707                     var start = scanner.getStartPos();
20708                     nextTokenJSDoc();
20709                     var tagName = parseJSDocIdentifierName();
20710                     skipWhitespace();
20711                     var t;
20712                     switch (tagName.escapedText) {
20713                         case "type":
20714                             return target === 1 && parseTypeTag(start, tagName);
20715                         case "prop":
20716                         case "property":
20717                             t = 1;
20718                             break;
20719                         case "arg":
20720                         case "argument":
20721                         case "param":
20722                             t = 2 | 4;
20723                             break;
20724                         default:
20725                             return false;
20726                     }
20727                     if (!(target & t)) {
20728                         return false;
20729                     }
20730                     return parseParameterOrPropertyTag(start, tagName, target, indent);
20731                 }
20732                 function parseTemplateTag(start, tagName) {
20733                     var constraint;
20734                     if (token() === 18) {
20735                         constraint = parseJSDocTypeExpression();
20736                     }
20737                     var typeParameters = [];
20738                     var typeParametersPos = getNodePos();
20739                     do {
20740                         skipWhitespace();
20741                         var typeParameter = createNode(155);
20742                         typeParameter.name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces);
20743                         finishNode(typeParameter);
20744                         skipWhitespaceOrAsterisk();
20745                         typeParameters.push(typeParameter);
20746                     } while (parseOptionalJsdoc(27));
20747                     var result = createNode(321, start);
20748                     result.tagName = tagName;
20749                     result.constraint = constraint;
20750                     result.typeParameters = createNodeArray(typeParameters, typeParametersPos);
20751                     finishNode(result);
20752                     return result;
20753                 }
20754                 function parseOptionalJsdoc(t) {
20755                     if (token() === t) {
20756                         nextTokenJSDoc();
20757                         return true;
20758                     }
20759                     return false;
20760                 }
20761                 function parseJSDocEntityName() {
20762                     var entity = parseJSDocIdentifierName();
20763                     if (parseOptional(22)) {
20764                         parseExpected(23);
20765                     }
20766                     while (parseOptional(24)) {
20767                         var name = parseJSDocIdentifierName();
20768                         if (parseOptional(22)) {
20769                             parseExpected(23);
20770                         }
20771                         entity = createQualifiedName(entity, name);
20772                     }
20773                     return entity;
20774                 }
20775                 function parseJSDocIdentifierName(message) {
20776                     if (!ts.tokenIsIdentifierOrKeyword(token())) {
20777                         return createMissingNode(75, !message, message || ts.Diagnostics.Identifier_expected);
20778                     }
20779                     identifierCount++;
20780                     var pos = scanner.getTokenPos();
20781                     var end = scanner.getTextPos();
20782                     var result = createNode(75, pos);
20783                     if (token() !== 75) {
20784                         result.originalKeywordKind = token();
20785                     }
20786                     result.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue()));
20787                     finishNode(result, end);
20788                     nextTokenJSDoc();
20789                     return result;
20790                 }
20791             }
20792         })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {}));
20793     })(Parser || (Parser = {}));
20794     var IncrementalParser;
20795     (function (IncrementalParser) {
20796         function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) {
20797             aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2);
20798             checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks);
20799             if (ts.textChangeRangeIsUnchanged(textChangeRange)) {
20800                 return sourceFile;
20801             }
20802             if (sourceFile.statements.length === 0) {
20803                 return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, undefined, true, sourceFile.scriptKind);
20804             }
20805             var incrementalSourceFile = sourceFile;
20806             ts.Debug.assert(!incrementalSourceFile.hasBeenIncrementallyParsed);
20807             incrementalSourceFile.hasBeenIncrementallyParsed = true;
20808             var oldText = sourceFile.text;
20809             var syntaxCursor = createSyntaxCursor(sourceFile);
20810             var changeRange = extendToAffectedRange(sourceFile, textChangeRange);
20811             checkChangeRange(sourceFile, newText, changeRange, aggressiveChecks);
20812             ts.Debug.assert(changeRange.span.start <= textChangeRange.span.start);
20813             ts.Debug.assert(ts.textSpanEnd(changeRange.span) === ts.textSpanEnd(textChangeRange.span));
20814             ts.Debug.assert(ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)) === ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange)));
20815             var delta = ts.textChangeRangeNewSpan(changeRange).length - changeRange.span.length;
20816             updateTokenPositionsAndMarkElements(incrementalSourceFile, changeRange.span.start, ts.textSpanEnd(changeRange.span), ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)), delta, oldText, newText, aggressiveChecks);
20817             var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, true, sourceFile.scriptKind);
20818             result.commentDirectives = getNewCommentDirectives(sourceFile.commentDirectives, result.commentDirectives, changeRange.span.start, ts.textSpanEnd(changeRange.span), delta, oldText, newText, aggressiveChecks);
20819             return result;
20820         }
20821         IncrementalParser.updateSourceFile = updateSourceFile;
20822         function getNewCommentDirectives(oldDirectives, newDirectives, changeStart, changeRangeOldEnd, delta, oldText, newText, aggressiveChecks) {
20823             if (!oldDirectives)
20824                 return newDirectives;
20825             var commentDirectives;
20826             var addedNewlyScannedDirectives = false;
20827             for (var _i = 0, oldDirectives_1 = oldDirectives; _i < oldDirectives_1.length; _i++) {
20828                 var directive = oldDirectives_1[_i];
20829                 var range = directive.range, type = directive.type;
20830                 if (range.end < changeStart) {
20831                     commentDirectives = ts.append(commentDirectives, directive);
20832                 }
20833                 else if (range.pos > changeRangeOldEnd) {
20834                     addNewlyScannedDirectives();
20835                     var updatedDirective = {
20836                         range: { pos: range.pos + delta, end: range.end + delta },
20837                         type: type
20838                     };
20839                     commentDirectives = ts.append(commentDirectives, updatedDirective);
20840                     if (aggressiveChecks) {
20841                         ts.Debug.assert(oldText.substring(range.pos, range.end) === newText.substring(updatedDirective.range.pos, updatedDirective.range.end));
20842                     }
20843                 }
20844             }
20845             addNewlyScannedDirectives();
20846             return commentDirectives;
20847             function addNewlyScannedDirectives() {
20848                 if (addedNewlyScannedDirectives)
20849                     return;
20850                 addedNewlyScannedDirectives = true;
20851                 if (!commentDirectives) {
20852                     commentDirectives = newDirectives;
20853                 }
20854                 else if (newDirectives) {
20855                     commentDirectives.push.apply(commentDirectives, newDirectives);
20856                 }
20857             }
20858         }
20859         function moveElementEntirelyPastChangeRange(element, isArray, delta, oldText, newText, aggressiveChecks) {
20860             if (isArray) {
20861                 visitArray(element);
20862             }
20863             else {
20864                 visitNode(element);
20865             }
20866             return;
20867             function visitNode(node) {
20868                 var text = "";
20869                 if (aggressiveChecks && shouldCheckNode(node)) {
20870                     text = oldText.substring(node.pos, node.end);
20871                 }
20872                 if (node._children) {
20873                     node._children = undefined;
20874                 }
20875                 node.pos += delta;
20876                 node.end += delta;
20877                 if (aggressiveChecks && shouldCheckNode(node)) {
20878                     ts.Debug.assert(text === newText.substring(node.pos, node.end));
20879                 }
20880                 forEachChild(node, visitNode, visitArray);
20881                 if (ts.hasJSDocNodes(node)) {
20882                     for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
20883                         var jsDocComment = _a[_i];
20884                         visitNode(jsDocComment);
20885                     }
20886                 }
20887                 checkNodePositions(node, aggressiveChecks);
20888             }
20889             function visitArray(array) {
20890                 array._children = undefined;
20891                 array.pos += delta;
20892                 array.end += delta;
20893                 for (var _i = 0, array_8 = array; _i < array_8.length; _i++) {
20894                     var node = array_8[_i];
20895                     visitNode(node);
20896                 }
20897             }
20898         }
20899         function shouldCheckNode(node) {
20900             switch (node.kind) {
20901                 case 10:
20902                 case 8:
20903                 case 75:
20904                     return true;
20905             }
20906             return false;
20907         }
20908         function adjustIntersectingElement(element, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta) {
20909             ts.Debug.assert(element.end >= changeStart, "Adjusting an element that was entirely before the change range");
20910             ts.Debug.assert(element.pos <= changeRangeOldEnd, "Adjusting an element that was entirely after the change range");
20911             ts.Debug.assert(element.pos <= element.end);
20912             element.pos = Math.min(element.pos, changeRangeNewEnd);
20913             if (element.end >= changeRangeOldEnd) {
20914                 element.end += delta;
20915             }
20916             else {
20917                 element.end = Math.min(element.end, changeRangeNewEnd);
20918             }
20919             ts.Debug.assert(element.pos <= element.end);
20920             if (element.parent) {
20921                 ts.Debug.assert(element.pos >= element.parent.pos);
20922                 ts.Debug.assert(element.end <= element.parent.end);
20923             }
20924         }
20925         function checkNodePositions(node, aggressiveChecks) {
20926             if (aggressiveChecks) {
20927                 var pos_2 = node.pos;
20928                 var visitNode_1 = function (child) {
20929                     ts.Debug.assert(child.pos >= pos_2);
20930                     pos_2 = child.end;
20931                 };
20932                 if (ts.hasJSDocNodes(node)) {
20933                     for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
20934                         var jsDocComment = _a[_i];
20935                         visitNode_1(jsDocComment);
20936                     }
20937                 }
20938                 forEachChild(node, visitNode_1);
20939                 ts.Debug.assert(pos_2 <= node.end);
20940             }
20941         }
20942         function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) {
20943             visitNode(sourceFile);
20944             return;
20945             function visitNode(child) {
20946                 ts.Debug.assert(child.pos <= child.end);
20947                 if (child.pos > changeRangeOldEnd) {
20948                     moveElementEntirelyPastChangeRange(child, false, delta, oldText, newText, aggressiveChecks);
20949                     return;
20950                 }
20951                 var fullEnd = child.end;
20952                 if (fullEnd >= changeStart) {
20953                     child.intersectsChange = true;
20954                     child._children = undefined;
20955                     adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
20956                     forEachChild(child, visitNode, visitArray);
20957                     if (ts.hasJSDocNodes(child)) {
20958                         for (var _i = 0, _a = child.jsDoc; _i < _a.length; _i++) {
20959                             var jsDocComment = _a[_i];
20960                             visitNode(jsDocComment);
20961                         }
20962                     }
20963                     checkNodePositions(child, aggressiveChecks);
20964                     return;
20965                 }
20966                 ts.Debug.assert(fullEnd < changeStart);
20967             }
20968             function visitArray(array) {
20969                 ts.Debug.assert(array.pos <= array.end);
20970                 if (array.pos > changeRangeOldEnd) {
20971                     moveElementEntirelyPastChangeRange(array, true, delta, oldText, newText, aggressiveChecks);
20972                     return;
20973                 }
20974                 var fullEnd = array.end;
20975                 if (fullEnd >= changeStart) {
20976                     array.intersectsChange = true;
20977                     array._children = undefined;
20978                     adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
20979                     for (var _i = 0, array_9 = array; _i < array_9.length; _i++) {
20980                         var node = array_9[_i];
20981                         visitNode(node);
20982                     }
20983                     return;
20984                 }
20985                 ts.Debug.assert(fullEnd < changeStart);
20986             }
20987         }
20988         function extendToAffectedRange(sourceFile, changeRange) {
20989             var maxLookahead = 1;
20990             var start = changeRange.span.start;
20991             for (var i = 0; start > 0 && i <= maxLookahead; i++) {
20992                 var nearestNode = findNearestNodeStartingBeforeOrAtPosition(sourceFile, start);
20993                 ts.Debug.assert(nearestNode.pos <= start);
20994                 var position = nearestNode.pos;
20995                 start = Math.max(0, position - 1);
20996             }
20997             var finalSpan = ts.createTextSpanFromBounds(start, ts.textSpanEnd(changeRange.span));
20998             var finalLength = changeRange.newLength + (changeRange.span.start - start);
20999             return ts.createTextChangeRange(finalSpan, finalLength);
21000         }
21001         function findNearestNodeStartingBeforeOrAtPosition(sourceFile, position) {
21002             var bestResult = sourceFile;
21003             var lastNodeEntirelyBeforePosition;
21004             forEachChild(sourceFile, visit);
21005             if (lastNodeEntirelyBeforePosition) {
21006                 var lastChildOfLastEntireNodeBeforePosition = getLastDescendant(lastNodeEntirelyBeforePosition);
21007                 if (lastChildOfLastEntireNodeBeforePosition.pos > bestResult.pos) {
21008                     bestResult = lastChildOfLastEntireNodeBeforePosition;
21009                 }
21010             }
21011             return bestResult;
21012             function getLastDescendant(node) {
21013                 while (true) {
21014                     var lastChild = ts.getLastChild(node);
21015                     if (lastChild) {
21016                         node = lastChild;
21017                     }
21018                     else {
21019                         return node;
21020                     }
21021                 }
21022             }
21023             function visit(child) {
21024                 if (ts.nodeIsMissing(child)) {
21025                     return;
21026                 }
21027                 if (child.pos <= position) {
21028                     if (child.pos >= bestResult.pos) {
21029                         bestResult = child;
21030                     }
21031                     if (position < child.end) {
21032                         forEachChild(child, visit);
21033                         return true;
21034                     }
21035                     else {
21036                         ts.Debug.assert(child.end <= position);
21037                         lastNodeEntirelyBeforePosition = child;
21038                     }
21039                 }
21040                 else {
21041                     ts.Debug.assert(child.pos > position);
21042                     return true;
21043                 }
21044             }
21045         }
21046         function checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks) {
21047             var oldText = sourceFile.text;
21048             if (textChangeRange) {
21049                 ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length);
21050                 if (aggressiveChecks || ts.Debug.shouldAssert(3)) {
21051                     var oldTextPrefix = oldText.substr(0, textChangeRange.span.start);
21052                     var newTextPrefix = newText.substr(0, textChangeRange.span.start);
21053                     ts.Debug.assert(oldTextPrefix === newTextPrefix);
21054                     var oldTextSuffix = oldText.substring(ts.textSpanEnd(textChangeRange.span), oldText.length);
21055                     var newTextSuffix = newText.substring(ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange)), newText.length);
21056                     ts.Debug.assert(oldTextSuffix === newTextSuffix);
21057                 }
21058             }
21059         }
21060         function createSyntaxCursor(sourceFile) {
21061             var currentArray = sourceFile.statements;
21062             var currentArrayIndex = 0;
21063             ts.Debug.assert(currentArrayIndex < currentArray.length);
21064             var current = currentArray[currentArrayIndex];
21065             var lastQueriedPosition = -1;
21066             return {
21067                 currentNode: function (position) {
21068                     if (position !== lastQueriedPosition) {
21069                         if (current && current.end === position && currentArrayIndex < (currentArray.length - 1)) {
21070                             currentArrayIndex++;
21071                             current = currentArray[currentArrayIndex];
21072                         }
21073                         if (!current || current.pos !== position) {
21074                             findHighestListElementThatStartsAtPosition(position);
21075                         }
21076                     }
21077                     lastQueriedPosition = position;
21078                     ts.Debug.assert(!current || current.pos === position);
21079                     return current;
21080                 }
21081             };
21082             function findHighestListElementThatStartsAtPosition(position) {
21083                 currentArray = undefined;
21084                 currentArrayIndex = -1;
21085                 current = undefined;
21086                 forEachChild(sourceFile, visitNode, visitArray);
21087                 return;
21088                 function visitNode(node) {
21089                     if (position >= node.pos && position < node.end) {
21090                         forEachChild(node, visitNode, visitArray);
21091                         return true;
21092                     }
21093                     return false;
21094                 }
21095                 function visitArray(array) {
21096                     if (position >= array.pos && position < array.end) {
21097                         for (var i = 0; i < array.length; i++) {
21098                             var child = array[i];
21099                             if (child) {
21100                                 if (child.pos === position) {
21101                                     currentArray = array;
21102                                     currentArrayIndex = i;
21103                                     current = child;
21104                                     return true;
21105                                 }
21106                                 else {
21107                                     if (child.pos < position && position < child.end) {
21108                                         forEachChild(child, visitNode, visitArray);
21109                                         return true;
21110                                     }
21111                                 }
21112                             }
21113                         }
21114                     }
21115                     return false;
21116                 }
21117             }
21118         }
21119     })(IncrementalParser || (IncrementalParser = {}));
21120     function isDeclarationFileName(fileName) {
21121         return ts.fileExtensionIs(fileName, ".d.ts");
21122     }
21123     ts.isDeclarationFileName = isDeclarationFileName;
21124     function processCommentPragmas(context, sourceText) {
21125         var pragmas = [];
21126         for (var _i = 0, _a = ts.getLeadingCommentRanges(sourceText, 0) || ts.emptyArray; _i < _a.length; _i++) {
21127             var range = _a[_i];
21128             var comment = sourceText.substring(range.pos, range.end);
21129             extractPragmas(pragmas, range, comment);
21130         }
21131         context.pragmas = ts.createMap();
21132         for (var _b = 0, pragmas_1 = pragmas; _b < pragmas_1.length; _b++) {
21133             var pragma = pragmas_1[_b];
21134             if (context.pragmas.has(pragma.name)) {
21135                 var currentValue = context.pragmas.get(pragma.name);
21136                 if (currentValue instanceof Array) {
21137                     currentValue.push(pragma.args);
21138                 }
21139                 else {
21140                     context.pragmas.set(pragma.name, [currentValue, pragma.args]);
21141                 }
21142                 continue;
21143             }
21144             context.pragmas.set(pragma.name, pragma.args);
21145         }
21146     }
21147     ts.processCommentPragmas = processCommentPragmas;
21148     function processPragmasIntoFields(context, reportDiagnostic) {
21149         context.checkJsDirective = undefined;
21150         context.referencedFiles = [];
21151         context.typeReferenceDirectives = [];
21152         context.libReferenceDirectives = [];
21153         context.amdDependencies = [];
21154         context.hasNoDefaultLib = false;
21155         context.pragmas.forEach(function (entryOrList, key) {
21156             switch (key) {
21157                 case "reference": {
21158                     var referencedFiles_1 = context.referencedFiles;
21159                     var typeReferenceDirectives_1 = context.typeReferenceDirectives;
21160                     var libReferenceDirectives_1 = context.libReferenceDirectives;
21161                     ts.forEach(ts.toArray(entryOrList), function (arg) {
21162                         var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path;
21163                         if (arg.arguments["no-default-lib"]) {
21164                             context.hasNoDefaultLib = true;
21165                         }
21166                         else if (types) {
21167                             typeReferenceDirectives_1.push({ pos: types.pos, end: types.end, fileName: types.value });
21168                         }
21169                         else if (lib) {
21170                             libReferenceDirectives_1.push({ pos: lib.pos, end: lib.end, fileName: lib.value });
21171                         }
21172                         else if (path) {
21173                             referencedFiles_1.push({ pos: path.pos, end: path.end, fileName: path.value });
21174                         }
21175                         else {
21176                             reportDiagnostic(arg.range.pos, arg.range.end - arg.range.pos, ts.Diagnostics.Invalid_reference_directive_syntax);
21177                         }
21178                     });
21179                     break;
21180                 }
21181                 case "amd-dependency": {
21182                     context.amdDependencies = ts.map(ts.toArray(entryOrList), function (x) { return ({ name: x.arguments.name, path: x.arguments.path }); });
21183                     break;
21184                 }
21185                 case "amd-module": {
21186                     if (entryOrList instanceof Array) {
21187                         for (var _i = 0, entryOrList_1 = entryOrList; _i < entryOrList_1.length; _i++) {
21188                             var entry = entryOrList_1[_i];
21189                             if (context.moduleName) {
21190                                 reportDiagnostic(entry.range.pos, entry.range.end - entry.range.pos, ts.Diagnostics.An_AMD_module_cannot_have_multiple_name_assignments);
21191                             }
21192                             context.moduleName = entry.arguments.name;
21193                         }
21194                     }
21195                     else {
21196                         context.moduleName = entryOrList.arguments.name;
21197                     }
21198                     break;
21199                 }
21200                 case "ts-nocheck":
21201                 case "ts-check": {
21202                     ts.forEach(ts.toArray(entryOrList), function (entry) {
21203                         if (!context.checkJsDirective || entry.range.pos > context.checkJsDirective.pos) {
21204                             context.checkJsDirective = {
21205                                 enabled: key === "ts-check",
21206                                 end: entry.range.end,
21207                                 pos: entry.range.pos
21208                             };
21209                         }
21210                     });
21211                     break;
21212                 }
21213                 case "jsx": return;
21214                 default: ts.Debug.fail("Unhandled pragma kind");
21215             }
21216         });
21217     }
21218     ts.processPragmasIntoFields = processPragmasIntoFields;
21219     var namedArgRegExCache = ts.createMap();
21220     function getNamedArgRegEx(name) {
21221         if (namedArgRegExCache.has(name)) {
21222             return namedArgRegExCache.get(name);
21223         }
21224         var result = new RegExp("(\\s" + name + "\\s*=\\s*)('|\")(.+?)\\2", "im");
21225         namedArgRegExCache.set(name, result);
21226         return result;
21227     }
21228     var tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im;
21229     var singleLinePragmaRegEx = /^\/\/\/?\s*@(\S+)\s*(.*)\s*$/im;
21230     function extractPragmas(pragmas, range, text) {
21231         var tripleSlash = range.kind === 2 && tripleSlashXMLCommentStartRegEx.exec(text);
21232         if (tripleSlash) {
21233             var name = tripleSlash[1].toLowerCase();
21234             var pragma = ts.commentPragmas[name];
21235             if (!pragma || !(pragma.kind & 1)) {
21236                 return;
21237             }
21238             if (pragma.args) {
21239                 var argument = {};
21240                 for (var _i = 0, _a = pragma.args; _i < _a.length; _i++) {
21241                     var arg = _a[_i];
21242                     var matcher = getNamedArgRegEx(arg.name);
21243                     var matchResult = matcher.exec(text);
21244                     if (!matchResult && !arg.optional) {
21245                         return;
21246                     }
21247                     else if (matchResult) {
21248                         if (arg.captureSpan) {
21249                             var startPos = range.pos + matchResult.index + matchResult[1].length + matchResult[2].length;
21250                             argument[arg.name] = {
21251                                 value: matchResult[3],
21252                                 pos: startPos,
21253                                 end: startPos + matchResult[3].length
21254                             };
21255                         }
21256                         else {
21257                             argument[arg.name] = matchResult[3];
21258                         }
21259                     }
21260                 }
21261                 pragmas.push({ name: name, args: { arguments: argument, range: range } });
21262             }
21263             else {
21264                 pragmas.push({ name: name, args: { arguments: {}, range: range } });
21265             }
21266             return;
21267         }
21268         var singleLine = range.kind === 2 && singleLinePragmaRegEx.exec(text);
21269         if (singleLine) {
21270             return addPragmaForMatch(pragmas, range, 2, singleLine);
21271         }
21272         if (range.kind === 3) {
21273             var multiLinePragmaRegEx = /\s*@(\S+)\s*(.*)\s*$/gim;
21274             var multiLineMatch = void 0;
21275             while (multiLineMatch = multiLinePragmaRegEx.exec(text)) {
21276                 addPragmaForMatch(pragmas, range, 4, multiLineMatch);
21277             }
21278         }
21279     }
21280     function addPragmaForMatch(pragmas, range, kind, match) {
21281         if (!match)
21282             return;
21283         var name = match[1].toLowerCase();
21284         var pragma = ts.commentPragmas[name];
21285         if (!pragma || !(pragma.kind & kind)) {
21286             return;
21287         }
21288         var args = match[2];
21289         var argument = getNamedPragmaArguments(pragma, args);
21290         if (argument === "fail")
21291             return;
21292         pragmas.push({ name: name, args: { arguments: argument, range: range } });
21293         return;
21294     }
21295     function getNamedPragmaArguments(pragma, text) {
21296         if (!text)
21297             return {};
21298         if (!pragma.args)
21299             return {};
21300         var args = text.split(/\s+/);
21301         var argMap = {};
21302         for (var i = 0; i < pragma.args.length; i++) {
21303             var argument = pragma.args[i];
21304             if (!args[i] && !argument.optional) {
21305                 return "fail";
21306             }
21307             if (argument.captureSpan) {
21308                 return ts.Debug.fail("Capture spans not yet implemented for non-xml pragmas");
21309             }
21310             argMap[argument.name] = args[i];
21311         }
21312         return argMap;
21313     }
21314     function tagNamesAreEquivalent(lhs, rhs) {
21315         if (lhs.kind !== rhs.kind) {
21316             return false;
21317         }
21318         if (lhs.kind === 75) {
21319             return lhs.escapedText === rhs.escapedText;
21320         }
21321         if (lhs.kind === 104) {
21322             return true;
21323         }
21324         return lhs.name.escapedText === rhs.name.escapedText &&
21325             tagNamesAreEquivalent(lhs.expression, rhs.expression);
21326     }
21327     ts.tagNamesAreEquivalent = tagNamesAreEquivalent;
21328 })(ts || (ts = {}));
21329 var ts;
21330 (function (ts) {
21331     ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" };
21332     var libEntries = [
21333         ["es5", "lib.es5.d.ts"],
21334         ["es6", "lib.es2015.d.ts"],
21335         ["es2015", "lib.es2015.d.ts"],
21336         ["es7", "lib.es2016.d.ts"],
21337         ["es2016", "lib.es2016.d.ts"],
21338         ["es2017", "lib.es2017.d.ts"],
21339         ["es2018", "lib.es2018.d.ts"],
21340         ["es2019", "lib.es2019.d.ts"],
21341         ["es2020", "lib.es2020.d.ts"],
21342         ["esnext", "lib.esnext.d.ts"],
21343         ["dom", "lib.dom.d.ts"],
21344         ["dom.iterable", "lib.dom.iterable.d.ts"],
21345         ["webworker", "lib.webworker.d.ts"],
21346         ["webworker.importscripts", "lib.webworker.importscripts.d.ts"],
21347         ["scripthost", "lib.scripthost.d.ts"],
21348         ["es2015.core", "lib.es2015.core.d.ts"],
21349         ["es2015.collection", "lib.es2015.collection.d.ts"],
21350         ["es2015.generator", "lib.es2015.generator.d.ts"],
21351         ["es2015.iterable", "lib.es2015.iterable.d.ts"],
21352         ["es2015.promise", "lib.es2015.promise.d.ts"],
21353         ["es2015.proxy", "lib.es2015.proxy.d.ts"],
21354         ["es2015.reflect", "lib.es2015.reflect.d.ts"],
21355         ["es2015.symbol", "lib.es2015.symbol.d.ts"],
21356         ["es2015.symbol.wellknown", "lib.es2015.symbol.wellknown.d.ts"],
21357         ["es2016.array.include", "lib.es2016.array.include.d.ts"],
21358         ["es2017.object", "lib.es2017.object.d.ts"],
21359         ["es2017.sharedmemory", "lib.es2017.sharedmemory.d.ts"],
21360         ["es2017.string", "lib.es2017.string.d.ts"],
21361         ["es2017.intl", "lib.es2017.intl.d.ts"],
21362         ["es2017.typedarrays", "lib.es2017.typedarrays.d.ts"],
21363         ["es2018.asyncgenerator", "lib.es2018.asyncgenerator.d.ts"],
21364         ["es2018.asynciterable", "lib.es2018.asynciterable.d.ts"],
21365         ["es2018.intl", "lib.es2018.intl.d.ts"],
21366         ["es2018.promise", "lib.es2018.promise.d.ts"],
21367         ["es2018.regexp", "lib.es2018.regexp.d.ts"],
21368         ["es2019.array", "lib.es2019.array.d.ts"],
21369         ["es2019.object", "lib.es2019.object.d.ts"],
21370         ["es2019.string", "lib.es2019.string.d.ts"],
21371         ["es2019.symbol", "lib.es2019.symbol.d.ts"],
21372         ["es2020.bigint", "lib.es2020.bigint.d.ts"],
21373         ["es2020.promise", "lib.es2020.promise.d.ts"],
21374         ["es2020.string", "lib.es2020.string.d.ts"],
21375         ["es2020.symbol.wellknown", "lib.es2020.symbol.wellknown.d.ts"],
21376         ["esnext.array", "lib.es2019.array.d.ts"],
21377         ["esnext.symbol", "lib.es2019.symbol.d.ts"],
21378         ["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"],
21379         ["esnext.intl", "lib.esnext.intl.d.ts"],
21380         ["esnext.bigint", "lib.es2020.bigint.d.ts"],
21381         ["esnext.string", "lib.esnext.string.d.ts"],
21382         ["esnext.promise", "lib.esnext.promise.d.ts"]
21383     ];
21384     ts.libs = libEntries.map(function (entry) { return entry[0]; });
21385     ts.libMap = ts.createMapFromEntries(libEntries);
21386     ts.optionsForWatch = [
21387         {
21388             name: "watchFile",
21389             type: ts.createMapFromTemplate({
21390                 fixedpollinginterval: ts.WatchFileKind.FixedPollingInterval,
21391                 prioritypollinginterval: ts.WatchFileKind.PriorityPollingInterval,
21392                 dynamicprioritypolling: ts.WatchFileKind.DynamicPriorityPolling,
21393                 usefsevents: ts.WatchFileKind.UseFsEvents,
21394                 usefseventsonparentdirectory: ts.WatchFileKind.UseFsEventsOnParentDirectory,
21395             }),
21396             category: ts.Diagnostics.Advanced_Options,
21397             description: ts.Diagnostics.Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_UseFsEvents_UseFsEventsOnParentDirectory,
21398         },
21399         {
21400             name: "watchDirectory",
21401             type: ts.createMapFromTemplate({
21402                 usefsevents: ts.WatchDirectoryKind.UseFsEvents,
21403                 fixedpollinginterval: ts.WatchDirectoryKind.FixedPollingInterval,
21404                 dynamicprioritypolling: ts.WatchDirectoryKind.DynamicPriorityPolling,
21405             }),
21406             category: ts.Diagnostics.Advanced_Options,
21407             description: ts.Diagnostics.Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling,
21408         },
21409         {
21410             name: "fallbackPolling",
21411             type: ts.createMapFromTemplate({
21412                 fixedinterval: ts.PollingWatchKind.FixedInterval,
21413                 priorityinterval: ts.PollingWatchKind.PriorityInterval,
21414                 dynamicpriority: ts.PollingWatchKind.DynamicPriority,
21415             }),
21416             category: ts.Diagnostics.Advanced_Options,
21417             description: ts.Diagnostics.Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority,
21418         },
21419         {
21420             name: "synchronousWatchDirectory",
21421             type: "boolean",
21422             category: ts.Diagnostics.Advanced_Options,
21423             description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively,
21424         },
21425     ];
21426     ts.commonOptionsWithBuild = [
21427         {
21428             name: "help",
21429             shortName: "h",
21430             type: "boolean",
21431             showInSimplifiedHelpView: true,
21432             category: ts.Diagnostics.Command_line_Options,
21433             description: ts.Diagnostics.Print_this_message,
21434         },
21435         {
21436             name: "help",
21437             shortName: "?",
21438             type: "boolean"
21439         },
21440         {
21441             name: "watch",
21442             shortName: "w",
21443             type: "boolean",
21444             showInSimplifiedHelpView: true,
21445             category: ts.Diagnostics.Command_line_Options,
21446             description: ts.Diagnostics.Watch_input_files,
21447         },
21448         {
21449             name: "preserveWatchOutput",
21450             type: "boolean",
21451             showInSimplifiedHelpView: false,
21452             category: ts.Diagnostics.Command_line_Options,
21453             description: ts.Diagnostics.Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen,
21454         },
21455         {
21456             name: "listFiles",
21457             type: "boolean",
21458             category: ts.Diagnostics.Advanced_Options,
21459             description: ts.Diagnostics.Print_names_of_files_part_of_the_compilation
21460         },
21461         {
21462             name: "listEmittedFiles",
21463             type: "boolean",
21464             category: ts.Diagnostics.Advanced_Options,
21465             description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation
21466         },
21467         {
21468             name: "pretty",
21469             type: "boolean",
21470             showInSimplifiedHelpView: true,
21471             category: ts.Diagnostics.Command_line_Options,
21472             description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental
21473         },
21474         {
21475             name: "traceResolution",
21476             type: "boolean",
21477             category: ts.Diagnostics.Advanced_Options,
21478             description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process
21479         },
21480         {
21481             name: "diagnostics",
21482             type: "boolean",
21483             category: ts.Diagnostics.Advanced_Options,
21484             description: ts.Diagnostics.Show_diagnostic_information
21485         },
21486         {
21487             name: "extendedDiagnostics",
21488             type: "boolean",
21489             category: ts.Diagnostics.Advanced_Options,
21490             description: ts.Diagnostics.Show_verbose_diagnostic_information
21491         },
21492         {
21493             name: "generateCpuProfile",
21494             type: "string",
21495             isFilePath: true,
21496             paramType: ts.Diagnostics.FILE_OR_DIRECTORY,
21497             category: ts.Diagnostics.Advanced_Options,
21498             description: ts.Diagnostics.Generates_a_CPU_profile
21499         },
21500         {
21501             name: "incremental",
21502             shortName: "i",
21503             type: "boolean",
21504             category: ts.Diagnostics.Basic_Options,
21505             description: ts.Diagnostics.Enable_incremental_compilation,
21506             transpileOptionValue: undefined
21507         },
21508         {
21509             name: "assumeChangesOnlyAffectDirectDependencies",
21510             type: "boolean",
21511             affectsSemanticDiagnostics: true,
21512             affectsEmit: true,
21513             category: ts.Diagnostics.Advanced_Options,
21514             description: ts.Diagnostics.Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it
21515         },
21516         {
21517             name: "locale",
21518             type: "string",
21519             category: ts.Diagnostics.Advanced_Options,
21520             description: ts.Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us
21521         },
21522     ];
21523     ts.optionDeclarations = __spreadArrays(ts.commonOptionsWithBuild, [
21524         {
21525             name: "all",
21526             type: "boolean",
21527             showInSimplifiedHelpView: true,
21528             category: ts.Diagnostics.Command_line_Options,
21529             description: ts.Diagnostics.Show_all_compiler_options,
21530         },
21531         {
21532             name: "version",
21533             shortName: "v",
21534             type: "boolean",
21535             showInSimplifiedHelpView: true,
21536             category: ts.Diagnostics.Command_line_Options,
21537             description: ts.Diagnostics.Print_the_compiler_s_version,
21538         },
21539         {
21540             name: "init",
21541             type: "boolean",
21542             showInSimplifiedHelpView: true,
21543             category: ts.Diagnostics.Command_line_Options,
21544             description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file,
21545         },
21546         {
21547             name: "project",
21548             shortName: "p",
21549             type: "string",
21550             isFilePath: true,
21551             showInSimplifiedHelpView: true,
21552             category: ts.Diagnostics.Command_line_Options,
21553             paramType: ts.Diagnostics.FILE_OR_DIRECTORY,
21554             description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json,
21555         },
21556         {
21557             name: "build",
21558             type: "boolean",
21559             shortName: "b",
21560             showInSimplifiedHelpView: true,
21561             category: ts.Diagnostics.Command_line_Options,
21562             description: ts.Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date
21563         },
21564         {
21565             name: "showConfig",
21566             type: "boolean",
21567             category: ts.Diagnostics.Command_line_Options,
21568             isCommandLineOnly: true,
21569             description: ts.Diagnostics.Print_the_final_configuration_instead_of_building
21570         },
21571         {
21572             name: "listFilesOnly",
21573             type: "boolean",
21574             category: ts.Diagnostics.Command_line_Options,
21575             affectsSemanticDiagnostics: true,
21576             affectsEmit: true,
21577             isCommandLineOnly: true,
21578             description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing
21579         },
21580         {
21581             name: "target",
21582             shortName: "t",
21583             type: ts.createMapFromTemplate({
21584                 es3: 0,
21585                 es5: 1,
21586                 es6: 2,
21587                 es2015: 2,
21588                 es2016: 3,
21589                 es2017: 4,
21590                 es2018: 5,
21591                 es2019: 6,
21592                 es2020: 7,
21593                 esnext: 99,
21594             }),
21595             affectsSourceFile: true,
21596             affectsModuleResolution: true,
21597             affectsEmit: true,
21598             paramType: ts.Diagnostics.VERSION,
21599             showInSimplifiedHelpView: true,
21600             category: ts.Diagnostics.Basic_Options,
21601             description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_ESNEXT,
21602         },
21603         {
21604             name: "module",
21605             shortName: "m",
21606             type: ts.createMapFromTemplate({
21607                 none: ts.ModuleKind.None,
21608                 commonjs: ts.ModuleKind.CommonJS,
21609                 amd: ts.ModuleKind.AMD,
21610                 system: ts.ModuleKind.System,
21611                 umd: ts.ModuleKind.UMD,
21612                 es6: ts.ModuleKind.ES2015,
21613                 es2015: ts.ModuleKind.ES2015,
21614                 es2020: ts.ModuleKind.ES2020,
21615                 esnext: ts.ModuleKind.ESNext
21616             }),
21617             affectsModuleResolution: true,
21618             affectsEmit: true,
21619             paramType: ts.Diagnostics.KIND,
21620             showInSimplifiedHelpView: true,
21621             category: ts.Diagnostics.Basic_Options,
21622             description: ts.Diagnostics.Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext,
21623         },
21624         {
21625             name: "lib",
21626             type: "list",
21627             element: {
21628                 name: "lib",
21629                 type: ts.libMap
21630             },
21631             affectsModuleResolution: true,
21632             showInSimplifiedHelpView: true,
21633             category: ts.Diagnostics.Basic_Options,
21634             description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation,
21635             transpileOptionValue: undefined
21636         },
21637         {
21638             name: "allowJs",
21639             type: "boolean",
21640             affectsModuleResolution: true,
21641             showInSimplifiedHelpView: true,
21642             category: ts.Diagnostics.Basic_Options,
21643             description: ts.Diagnostics.Allow_javascript_files_to_be_compiled
21644         },
21645         {
21646             name: "checkJs",
21647             type: "boolean",
21648             category: ts.Diagnostics.Basic_Options,
21649             description: ts.Diagnostics.Report_errors_in_js_files
21650         },
21651         {
21652             name: "jsx",
21653             type: ts.createMapFromTemplate({
21654                 "preserve": 1,
21655                 "react-native": 3,
21656                 "react": 2
21657             }),
21658             affectsSourceFile: true,
21659             paramType: ts.Diagnostics.KIND,
21660             showInSimplifiedHelpView: true,
21661             category: ts.Diagnostics.Basic_Options,
21662             description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react,
21663         },
21664         {
21665             name: "declaration",
21666             shortName: "d",
21667             type: "boolean",
21668             affectsEmit: true,
21669             showInSimplifiedHelpView: true,
21670             category: ts.Diagnostics.Basic_Options,
21671             description: ts.Diagnostics.Generates_corresponding_d_ts_file,
21672             transpileOptionValue: undefined
21673         },
21674         {
21675             name: "declarationMap",
21676             type: "boolean",
21677             affectsEmit: true,
21678             showInSimplifiedHelpView: true,
21679             category: ts.Diagnostics.Basic_Options,
21680             description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file,
21681             transpileOptionValue: undefined
21682         },
21683         {
21684             name: "emitDeclarationOnly",
21685             type: "boolean",
21686             affectsEmit: true,
21687             category: ts.Diagnostics.Advanced_Options,
21688             description: ts.Diagnostics.Only_emit_d_ts_declaration_files,
21689             transpileOptionValue: undefined
21690         },
21691         {
21692             name: "sourceMap",
21693             type: "boolean",
21694             affectsEmit: true,
21695             showInSimplifiedHelpView: true,
21696             category: ts.Diagnostics.Basic_Options,
21697             description: ts.Diagnostics.Generates_corresponding_map_file,
21698         },
21699         {
21700             name: "outFile",
21701             type: "string",
21702             affectsEmit: true,
21703             isFilePath: true,
21704             paramType: ts.Diagnostics.FILE,
21705             showInSimplifiedHelpView: true,
21706             category: ts.Diagnostics.Basic_Options,
21707             description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file,
21708             transpileOptionValue: undefined
21709         },
21710         {
21711             name: "outDir",
21712             type: "string",
21713             affectsEmit: true,
21714             isFilePath: true,
21715             paramType: ts.Diagnostics.DIRECTORY,
21716             showInSimplifiedHelpView: true,
21717             category: ts.Diagnostics.Basic_Options,
21718             description: ts.Diagnostics.Redirect_output_structure_to_the_directory,
21719         },
21720         {
21721             name: "rootDir",
21722             type: "string",
21723             affectsEmit: true,
21724             isFilePath: true,
21725             paramType: ts.Diagnostics.LOCATION,
21726             category: ts.Diagnostics.Basic_Options,
21727             description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir,
21728         },
21729         {
21730             name: "composite",
21731             type: "boolean",
21732             affectsEmit: true,
21733             isTSConfigOnly: true,
21734             category: ts.Diagnostics.Basic_Options,
21735             description: ts.Diagnostics.Enable_project_compilation,
21736             transpileOptionValue: undefined
21737         },
21738         {
21739             name: "tsBuildInfoFile",
21740             type: "string",
21741             affectsEmit: true,
21742             isFilePath: true,
21743             paramType: ts.Diagnostics.FILE,
21744             category: ts.Diagnostics.Basic_Options,
21745             description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information,
21746             transpileOptionValue: undefined
21747         },
21748         {
21749             name: "removeComments",
21750             type: "boolean",
21751             affectsEmit: true,
21752             showInSimplifiedHelpView: true,
21753             category: ts.Diagnostics.Basic_Options,
21754             description: ts.Diagnostics.Do_not_emit_comments_to_output,
21755         },
21756         {
21757             name: "noEmit",
21758             type: "boolean",
21759             affectsEmit: true,
21760             showInSimplifiedHelpView: true,
21761             category: ts.Diagnostics.Basic_Options,
21762             description: ts.Diagnostics.Do_not_emit_outputs,
21763             transpileOptionValue: undefined
21764         },
21765         {
21766             name: "importHelpers",
21767             type: "boolean",
21768             affectsEmit: true,
21769             category: ts.Diagnostics.Basic_Options,
21770             description: ts.Diagnostics.Import_emit_helpers_from_tslib
21771         },
21772         {
21773             name: "importsNotUsedAsValues",
21774             type: ts.createMapFromTemplate({
21775                 remove: 0,
21776                 preserve: 1,
21777                 error: 2
21778             }),
21779             affectsEmit: true,
21780             affectsSemanticDiagnostics: true,
21781             category: ts.Diagnostics.Advanced_Options,
21782             description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types
21783         },
21784         {
21785             name: "downlevelIteration",
21786             type: "boolean",
21787             affectsEmit: true,
21788             category: ts.Diagnostics.Basic_Options,
21789             description: ts.Diagnostics.Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3
21790         },
21791         {
21792             name: "isolatedModules",
21793             type: "boolean",
21794             category: ts.Diagnostics.Basic_Options,
21795             description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule,
21796             transpileOptionValue: true
21797         },
21798         {
21799             name: "strict",
21800             type: "boolean",
21801             showInSimplifiedHelpView: true,
21802             category: ts.Diagnostics.Strict_Type_Checking_Options,
21803             description: ts.Diagnostics.Enable_all_strict_type_checking_options
21804         },
21805         {
21806             name: "noImplicitAny",
21807             type: "boolean",
21808             affectsSemanticDiagnostics: true,
21809             strictFlag: true,
21810             showInSimplifiedHelpView: true,
21811             category: ts.Diagnostics.Strict_Type_Checking_Options,
21812             description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type
21813         },
21814         {
21815             name: "strictNullChecks",
21816             type: "boolean",
21817             affectsSemanticDiagnostics: true,
21818             strictFlag: true,
21819             showInSimplifiedHelpView: true,
21820             category: ts.Diagnostics.Strict_Type_Checking_Options,
21821             description: ts.Diagnostics.Enable_strict_null_checks
21822         },
21823         {
21824             name: "strictFunctionTypes",
21825             type: "boolean",
21826             affectsSemanticDiagnostics: true,
21827             strictFlag: true,
21828             showInSimplifiedHelpView: true,
21829             category: ts.Diagnostics.Strict_Type_Checking_Options,
21830             description: ts.Diagnostics.Enable_strict_checking_of_function_types
21831         },
21832         {
21833             name: "strictBindCallApply",
21834             type: "boolean",
21835             strictFlag: true,
21836             showInSimplifiedHelpView: true,
21837             category: ts.Diagnostics.Strict_Type_Checking_Options,
21838             description: ts.Diagnostics.Enable_strict_bind_call_and_apply_methods_on_functions
21839         },
21840         {
21841             name: "strictPropertyInitialization",
21842             type: "boolean",
21843             affectsSemanticDiagnostics: true,
21844             strictFlag: true,
21845             showInSimplifiedHelpView: true,
21846             category: ts.Diagnostics.Strict_Type_Checking_Options,
21847             description: ts.Diagnostics.Enable_strict_checking_of_property_initialization_in_classes
21848         },
21849         {
21850             name: "noImplicitThis",
21851             type: "boolean",
21852             affectsSemanticDiagnostics: true,
21853             strictFlag: true,
21854             showInSimplifiedHelpView: true,
21855             category: ts.Diagnostics.Strict_Type_Checking_Options,
21856             description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type,
21857         },
21858         {
21859             name: "alwaysStrict",
21860             type: "boolean",
21861             affectsSourceFile: true,
21862             strictFlag: true,
21863             showInSimplifiedHelpView: true,
21864             category: ts.Diagnostics.Strict_Type_Checking_Options,
21865             description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file
21866         },
21867         {
21868             name: "noUnusedLocals",
21869             type: "boolean",
21870             affectsSemanticDiagnostics: true,
21871             showInSimplifiedHelpView: true,
21872             category: ts.Diagnostics.Additional_Checks,
21873             description: ts.Diagnostics.Report_errors_on_unused_locals,
21874         },
21875         {
21876             name: "noUnusedParameters",
21877             type: "boolean",
21878             affectsSemanticDiagnostics: true,
21879             showInSimplifiedHelpView: true,
21880             category: ts.Diagnostics.Additional_Checks,
21881             description: ts.Diagnostics.Report_errors_on_unused_parameters,
21882         },
21883         {
21884             name: "noImplicitReturns",
21885             type: "boolean",
21886             affectsSemanticDiagnostics: true,
21887             showInSimplifiedHelpView: true,
21888             category: ts.Diagnostics.Additional_Checks,
21889             description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value
21890         },
21891         {
21892             name: "noFallthroughCasesInSwitch",
21893             type: "boolean",
21894             affectsBindDiagnostics: true,
21895             affectsSemanticDiagnostics: true,
21896             showInSimplifiedHelpView: true,
21897             category: ts.Diagnostics.Additional_Checks,
21898             description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement
21899         },
21900         {
21901             name: "moduleResolution",
21902             type: ts.createMapFromTemplate({
21903                 node: ts.ModuleResolutionKind.NodeJs,
21904                 classic: ts.ModuleResolutionKind.Classic,
21905             }),
21906             affectsModuleResolution: true,
21907             paramType: ts.Diagnostics.STRATEGY,
21908             category: ts.Diagnostics.Module_Resolution_Options,
21909             description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6,
21910         },
21911         {
21912             name: "baseUrl",
21913             type: "string",
21914             affectsModuleResolution: true,
21915             isFilePath: true,
21916             category: ts.Diagnostics.Module_Resolution_Options,
21917             description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names
21918         },
21919         {
21920             name: "paths",
21921             type: "object",
21922             affectsModuleResolution: true,
21923             isTSConfigOnly: true,
21924             category: ts.Diagnostics.Module_Resolution_Options,
21925             description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl,
21926             transpileOptionValue: undefined
21927         },
21928         {
21929             name: "rootDirs",
21930             type: "list",
21931             isTSConfigOnly: true,
21932             element: {
21933                 name: "rootDirs",
21934                 type: "string",
21935                 isFilePath: true
21936             },
21937             affectsModuleResolution: true,
21938             category: ts.Diagnostics.Module_Resolution_Options,
21939             description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime,
21940             transpileOptionValue: undefined
21941         },
21942         {
21943             name: "typeRoots",
21944             type: "list",
21945             element: {
21946                 name: "typeRoots",
21947                 type: "string",
21948                 isFilePath: true
21949             },
21950             affectsModuleResolution: true,
21951             category: ts.Diagnostics.Module_Resolution_Options,
21952             description: ts.Diagnostics.List_of_folders_to_include_type_definitions_from
21953         },
21954         {
21955             name: "types",
21956             type: "list",
21957             element: {
21958                 name: "types",
21959                 type: "string"
21960             },
21961             affectsModuleResolution: true,
21962             showInSimplifiedHelpView: true,
21963             category: ts.Diagnostics.Module_Resolution_Options,
21964             description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation,
21965             transpileOptionValue: undefined
21966         },
21967         {
21968             name: "allowSyntheticDefaultImports",
21969             type: "boolean",
21970             affectsSemanticDiagnostics: true,
21971             category: ts.Diagnostics.Module_Resolution_Options,
21972             description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking
21973         },
21974         {
21975             name: "esModuleInterop",
21976             type: "boolean",
21977             affectsSemanticDiagnostics: true,
21978             affectsEmit: true,
21979             showInSimplifiedHelpView: true,
21980             category: ts.Diagnostics.Module_Resolution_Options,
21981             description: ts.Diagnostics.Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports
21982         },
21983         {
21984             name: "preserveSymlinks",
21985             type: "boolean",
21986             category: ts.Diagnostics.Module_Resolution_Options,
21987             description: ts.Diagnostics.Do_not_resolve_the_real_path_of_symlinks,
21988         },
21989         {
21990             name: "allowUmdGlobalAccess",
21991             type: "boolean",
21992             affectsSemanticDiagnostics: true,
21993             category: ts.Diagnostics.Module_Resolution_Options,
21994             description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
21995         },
21996         {
21997             name: "sourceRoot",
21998             type: "string",
21999             affectsEmit: true,
22000             paramType: ts.Diagnostics.LOCATION,
22001             category: ts.Diagnostics.Source_Map_Options,
22002             description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations,
22003         },
22004         {
22005             name: "mapRoot",
22006             type: "string",
22007             affectsEmit: true,
22008             paramType: ts.Diagnostics.LOCATION,
22009             category: ts.Diagnostics.Source_Map_Options,
22010             description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations,
22011         },
22012         {
22013             name: "inlineSourceMap",
22014             type: "boolean",
22015             affectsEmit: true,
22016             category: ts.Diagnostics.Source_Map_Options,
22017             description: ts.Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file
22018         },
22019         {
22020             name: "inlineSources",
22021             type: "boolean",
22022             affectsEmit: true,
22023             category: ts.Diagnostics.Source_Map_Options,
22024             description: ts.Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set
22025         },
22026         {
22027             name: "experimentalDecorators",
22028             type: "boolean",
22029             affectsSemanticDiagnostics: true,
22030             category: ts.Diagnostics.Experimental_Options,
22031             description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators
22032         },
22033         {
22034             name: "emitDecoratorMetadata",
22035             type: "boolean",
22036             affectsSemanticDiagnostics: true,
22037             affectsEmit: true,
22038             category: ts.Diagnostics.Experimental_Options,
22039             description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators
22040         },
22041         {
22042             name: "jsxFactory",
22043             type: "string",
22044             category: ts.Diagnostics.Advanced_Options,
22045             description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h
22046         },
22047         {
22048             name: "resolveJsonModule",
22049             type: "boolean",
22050             affectsModuleResolution: true,
22051             category: ts.Diagnostics.Advanced_Options,
22052             description: ts.Diagnostics.Include_modules_imported_with_json_extension
22053         },
22054         {
22055             name: "out",
22056             type: "string",
22057             affectsEmit: true,
22058             isFilePath: false,
22059             category: ts.Diagnostics.Advanced_Options,
22060             paramType: ts.Diagnostics.FILE,
22061             description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file,
22062             transpileOptionValue: undefined
22063         },
22064         {
22065             name: "reactNamespace",
22066             type: "string",
22067             affectsEmit: true,
22068             category: ts.Diagnostics.Advanced_Options,
22069             description: ts.Diagnostics.Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit
22070         },
22071         {
22072             name: "skipDefaultLibCheck",
22073             type: "boolean",
22074             category: ts.Diagnostics.Advanced_Options,
22075             description: ts.Diagnostics.Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files
22076         },
22077         {
22078             name: "charset",
22079             type: "string",
22080             category: ts.Diagnostics.Advanced_Options,
22081             description: ts.Diagnostics.The_character_set_of_the_input_files
22082         },
22083         {
22084             name: "emitBOM",
22085             type: "boolean",
22086             affectsEmit: true,
22087             category: ts.Diagnostics.Advanced_Options,
22088             description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files
22089         },
22090         {
22091             name: "newLine",
22092             type: ts.createMapFromTemplate({
22093                 crlf: 0,
22094                 lf: 1
22095             }),
22096             affectsEmit: true,
22097             paramType: ts.Diagnostics.NEWLINE,
22098             category: ts.Diagnostics.Advanced_Options,
22099             description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix,
22100         },
22101         {
22102             name: "noErrorTruncation",
22103             type: "boolean",
22104             affectsSemanticDiagnostics: true,
22105             category: ts.Diagnostics.Advanced_Options,
22106             description: ts.Diagnostics.Do_not_truncate_error_messages
22107         },
22108         {
22109             name: "noLib",
22110             type: "boolean",
22111             affectsModuleResolution: true,
22112             category: ts.Diagnostics.Advanced_Options,
22113             description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts,
22114             transpileOptionValue: true
22115         },
22116         {
22117             name: "noResolve",
22118             type: "boolean",
22119             affectsModuleResolution: true,
22120             category: ts.Diagnostics.Advanced_Options,
22121             description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files,
22122             transpileOptionValue: true
22123         },
22124         {
22125             name: "stripInternal",
22126             type: "boolean",
22127             affectsEmit: true,
22128             category: ts.Diagnostics.Advanced_Options,
22129             description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation,
22130         },
22131         {
22132             name: "disableSizeLimit",
22133             type: "boolean",
22134             affectsSourceFile: true,
22135             category: ts.Diagnostics.Advanced_Options,
22136             description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects
22137         },
22138         {
22139             name: "disableSourceOfProjectReferenceRedirect",
22140             type: "boolean",
22141             isTSConfigOnly: true,
22142             category: ts.Diagnostics.Advanced_Options,
22143             description: ts.Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects
22144         },
22145         {
22146             name: "disableSolutionSearching",
22147             type: "boolean",
22148             isTSConfigOnly: true,
22149             category: ts.Diagnostics.Advanced_Options,
22150             description: ts.Diagnostics.Disable_solution_searching_for_this_project
22151         },
22152         {
22153             name: "noImplicitUseStrict",
22154             type: "boolean",
22155             affectsSemanticDiagnostics: true,
22156             category: ts.Diagnostics.Advanced_Options,
22157             description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output
22158         },
22159         {
22160             name: "noEmitHelpers",
22161             type: "boolean",
22162             affectsEmit: true,
22163             category: ts.Diagnostics.Advanced_Options,
22164             description: ts.Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output
22165         },
22166         {
22167             name: "noEmitOnError",
22168             type: "boolean",
22169             affectsEmit: true,
22170             category: ts.Diagnostics.Advanced_Options,
22171             description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported,
22172             transpileOptionValue: undefined
22173         },
22174         {
22175             name: "preserveConstEnums",
22176             type: "boolean",
22177             affectsEmit: true,
22178             category: ts.Diagnostics.Advanced_Options,
22179             description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code
22180         },
22181         {
22182             name: "declarationDir",
22183             type: "string",
22184             affectsEmit: true,
22185             isFilePath: true,
22186             paramType: ts.Diagnostics.DIRECTORY,
22187             category: ts.Diagnostics.Advanced_Options,
22188             description: ts.Diagnostics.Output_directory_for_generated_declaration_files,
22189             transpileOptionValue: undefined
22190         },
22191         {
22192             name: "skipLibCheck",
22193             type: "boolean",
22194             category: ts.Diagnostics.Advanced_Options,
22195             description: ts.Diagnostics.Skip_type_checking_of_declaration_files,
22196         },
22197         {
22198             name: "allowUnusedLabels",
22199             type: "boolean",
22200             affectsBindDiagnostics: true,
22201             affectsSemanticDiagnostics: true,
22202             category: ts.Diagnostics.Advanced_Options,
22203             description: ts.Diagnostics.Do_not_report_errors_on_unused_labels
22204         },
22205         {
22206             name: "allowUnreachableCode",
22207             type: "boolean",
22208             affectsBindDiagnostics: true,
22209             affectsSemanticDiagnostics: true,
22210             category: ts.Diagnostics.Advanced_Options,
22211             description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code
22212         },
22213         {
22214             name: "suppressExcessPropertyErrors",
22215             type: "boolean",
22216             affectsSemanticDiagnostics: true,
22217             category: ts.Diagnostics.Advanced_Options,
22218             description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals,
22219         },
22220         {
22221             name: "suppressImplicitAnyIndexErrors",
22222             type: "boolean",
22223             affectsSemanticDiagnostics: true,
22224             category: ts.Diagnostics.Advanced_Options,
22225             description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures,
22226         },
22227         {
22228             name: "forceConsistentCasingInFileNames",
22229             type: "boolean",
22230             affectsModuleResolution: true,
22231             category: ts.Diagnostics.Advanced_Options,
22232             description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file
22233         },
22234         {
22235             name: "maxNodeModuleJsDepth",
22236             type: "number",
22237             affectsModuleResolution: true,
22238             category: ts.Diagnostics.Advanced_Options,
22239             description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files
22240         },
22241         {
22242             name: "noStrictGenericChecks",
22243             type: "boolean",
22244             affectsSemanticDiagnostics: true,
22245             category: ts.Diagnostics.Advanced_Options,
22246             description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types,
22247         },
22248         {
22249             name: "useDefineForClassFields",
22250             type: "boolean",
22251             affectsSemanticDiagnostics: true,
22252             affectsEmit: true,
22253             category: ts.Diagnostics.Advanced_Options,
22254             description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set,
22255         },
22256         {
22257             name: "keyofStringsOnly",
22258             type: "boolean",
22259             category: ts.Diagnostics.Advanced_Options,
22260             description: ts.Diagnostics.Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols,
22261         },
22262         {
22263             name: "plugins",
22264             type: "list",
22265             isTSConfigOnly: true,
22266             element: {
22267                 name: "plugin",
22268                 type: "object"
22269             },
22270             description: ts.Diagnostics.List_of_language_service_plugins
22271         },
22272     ]);
22273     ts.semanticDiagnosticsOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsSemanticDiagnostics; });
22274     ts.affectsEmitOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsEmit; });
22275     ts.moduleResolutionOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsModuleResolution; });
22276     ts.sourceFileAffectingCompilerOptions = ts.optionDeclarations.filter(function (option) {
22277         return !!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics;
22278     });
22279     ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) {
22280         return ts.hasProperty(option, "transpileOptionValue");
22281     });
22282     ts.buildOpts = __spreadArrays(ts.commonOptionsWithBuild, [
22283         {
22284             name: "verbose",
22285             shortName: "v",
22286             category: ts.Diagnostics.Command_line_Options,
22287             description: ts.Diagnostics.Enable_verbose_logging,
22288             type: "boolean"
22289         },
22290         {
22291             name: "dry",
22292             shortName: "d",
22293             category: ts.Diagnostics.Command_line_Options,
22294             description: ts.Diagnostics.Show_what_would_be_built_or_deleted_if_specified_with_clean,
22295             type: "boolean"
22296         },
22297         {
22298             name: "force",
22299             shortName: "f",
22300             category: ts.Diagnostics.Command_line_Options,
22301             description: ts.Diagnostics.Build_all_projects_including_those_that_appear_to_be_up_to_date,
22302             type: "boolean"
22303         },
22304         {
22305             name: "clean",
22306             category: ts.Diagnostics.Command_line_Options,
22307             description: ts.Diagnostics.Delete_the_outputs_of_all_projects,
22308             type: "boolean"
22309         }
22310     ]);
22311     ts.typeAcquisitionDeclarations = [
22312         {
22313             name: "enableAutoDiscovery",
22314             type: "boolean",
22315         },
22316         {
22317             name: "enable",
22318             type: "boolean",
22319         },
22320         {
22321             name: "include",
22322             type: "list",
22323             element: {
22324                 name: "include",
22325                 type: "string"
22326             }
22327         },
22328         {
22329             name: "exclude",
22330             type: "list",
22331             element: {
22332                 name: "exclude",
22333                 type: "string"
22334             }
22335         }
22336     ];
22337     function createOptionNameMap(optionDeclarations) {
22338         var optionsNameMap = ts.createMap();
22339         var shortOptionNames = ts.createMap();
22340         ts.forEach(optionDeclarations, function (option) {
22341             optionsNameMap.set(option.name.toLowerCase(), option);
22342             if (option.shortName) {
22343                 shortOptionNames.set(option.shortName, option.name);
22344             }
22345         });
22346         return { optionsNameMap: optionsNameMap, shortOptionNames: shortOptionNames };
22347     }
22348     ts.createOptionNameMap = createOptionNameMap;
22349     var optionsNameMapCache;
22350     function getOptionsNameMap() {
22351         return optionsNameMapCache || (optionsNameMapCache = createOptionNameMap(ts.optionDeclarations));
22352     }
22353     ts.getOptionsNameMap = getOptionsNameMap;
22354     ts.defaultInitCompilerOptions = {
22355         module: ts.ModuleKind.CommonJS,
22356         target: 1,
22357         strict: true,
22358         esModuleInterop: true,
22359         forceConsistentCasingInFileNames: true,
22360         skipLibCheck: true
22361     };
22362     function convertEnableAutoDiscoveryToEnable(typeAcquisition) {
22363         if (typeAcquisition && typeAcquisition.enableAutoDiscovery !== undefined && typeAcquisition.enable === undefined) {
22364             return {
22365                 enable: typeAcquisition.enableAutoDiscovery,
22366                 include: typeAcquisition.include || [],
22367                 exclude: typeAcquisition.exclude || []
22368             };
22369         }
22370         return typeAcquisition;
22371     }
22372     ts.convertEnableAutoDiscoveryToEnable = convertEnableAutoDiscoveryToEnable;
22373     function createCompilerDiagnosticForInvalidCustomType(opt) {
22374         return createDiagnosticForInvalidCustomType(opt, ts.createCompilerDiagnostic);
22375     }
22376     ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType;
22377     function createDiagnosticForInvalidCustomType(opt, createDiagnostic) {
22378         var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", ");
22379         return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType);
22380     }
22381     function parseCustomTypeOption(opt, value, errors) {
22382         return convertJsonOptionOfCustomType(opt, trimString(value || ""), errors);
22383     }
22384     ts.parseCustomTypeOption = parseCustomTypeOption;
22385     function parseListTypeOption(opt, value, errors) {
22386         if (value === void 0) { value = ""; }
22387         value = trimString(value);
22388         if (ts.startsWith(value, "-")) {
22389             return undefined;
22390         }
22391         if (value === "") {
22392             return [];
22393         }
22394         var values = value.split(",");
22395         switch (opt.element.type) {
22396             case "number":
22397                 return ts.map(values, parseInt);
22398             case "string":
22399                 return ts.map(values, function (v) { return v || ""; });
22400             default:
22401                 return ts.mapDefined(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); });
22402         }
22403     }
22404     ts.parseListTypeOption = parseListTypeOption;
22405     function getOptionName(option) {
22406         return option.name;
22407     }
22408     function createUnknownOptionError(unknownOption, diagnostics, createDiagnostics, unknownOptionErrorText) {
22409         var possibleOption = ts.getSpellingSuggestion(unknownOption, diagnostics.optionDeclarations, getOptionName);
22410         return possibleOption ?
22411             createDiagnostics(diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) :
22412             createDiagnostics(diagnostics.unknownOptionDiagnostic, unknownOptionErrorText || unknownOption);
22413     }
22414     function parseCommandLineWorker(diagnostics, commandLine, readFile) {
22415         var options = {};
22416         var watchOptions;
22417         var fileNames = [];
22418         var errors = [];
22419         parseStrings(commandLine);
22420         return {
22421             options: options,
22422             watchOptions: watchOptions,
22423             fileNames: fileNames,
22424             errors: errors
22425         };
22426         function parseStrings(args) {
22427             var i = 0;
22428             while (i < args.length) {
22429                 var s = args[i];
22430                 i++;
22431                 if (s.charCodeAt(0) === 64) {
22432                     parseResponseFile(s.slice(1));
22433                 }
22434                 else if (s.charCodeAt(0) === 45) {
22435                     var inputOptionName = s.slice(s.charCodeAt(1) === 45 ? 2 : 1);
22436                     var opt = getOptionDeclarationFromName(diagnostics.getOptionsNameMap, inputOptionName, true);
22437                     if (opt) {
22438                         i = parseOptionValue(args, i, diagnostics, opt, options, errors);
22439                     }
22440                     else {
22441                         var watchOpt = getOptionDeclarationFromName(watchOptionsDidYouMeanDiagnostics.getOptionsNameMap, inputOptionName, true);
22442                         if (watchOpt) {
22443                             i = parseOptionValue(args, i, watchOptionsDidYouMeanDiagnostics, watchOpt, watchOptions || (watchOptions = {}), errors);
22444                         }
22445                         else {
22446                             errors.push(createUnknownOptionError(inputOptionName, diagnostics, ts.createCompilerDiagnostic, s));
22447                         }
22448                     }
22449                 }
22450                 else {
22451                     fileNames.push(s);
22452                 }
22453             }
22454         }
22455         function parseResponseFile(fileName) {
22456             var text = tryReadFile(fileName, readFile || (function (fileName) { return ts.sys.readFile(fileName); }));
22457             if (!ts.isString(text)) {
22458                 errors.push(text);
22459                 return;
22460             }
22461             var args = [];
22462             var pos = 0;
22463             while (true) {
22464                 while (pos < text.length && text.charCodeAt(pos) <= 32)
22465                     pos++;
22466                 if (pos >= text.length)
22467                     break;
22468                 var start = pos;
22469                 if (text.charCodeAt(start) === 34) {
22470                     pos++;
22471                     while (pos < text.length && text.charCodeAt(pos) !== 34)
22472                         pos++;
22473                     if (pos < text.length) {
22474                         args.push(text.substring(start + 1, pos));
22475                         pos++;
22476                     }
22477                     else {
22478                         errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unterminated_quoted_string_in_response_file_0, fileName));
22479                     }
22480                 }
22481                 else {
22482                     while (text.charCodeAt(pos) > 32)
22483                         pos++;
22484                     args.push(text.substring(start, pos));
22485                 }
22486             }
22487             parseStrings(args);
22488         }
22489     }
22490     ts.parseCommandLineWorker = parseCommandLineWorker;
22491     function parseOptionValue(args, i, diagnostics, opt, options, errors) {
22492         if (opt.isTSConfigOnly) {
22493             var optValue = args[i];
22494             if (optValue === "null") {
22495                 options[opt.name] = undefined;
22496                 i++;
22497             }
22498             else if (opt.type === "boolean") {
22499                 if (optValue === "false") {
22500                     options[opt.name] = false;
22501                     i++;
22502                 }
22503                 else {
22504                     if (optValue === "true")
22505                         i++;
22506                     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));
22507                 }
22508             }
22509             else {
22510                 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));
22511                 if (optValue && !ts.startsWith(optValue, "-"))
22512                     i++;
22513             }
22514         }
22515         else {
22516             if (!args[i] && opt.type !== "boolean") {
22517                 errors.push(ts.createCompilerDiagnostic(diagnostics.optionTypeMismatchDiagnostic, opt.name, getCompilerOptionValueTypeString(opt)));
22518             }
22519             if (args[i] !== "null") {
22520                 switch (opt.type) {
22521                     case "number":
22522                         options[opt.name] = parseInt(args[i]);
22523                         i++;
22524                         break;
22525                     case "boolean":
22526                         var optValue = args[i];
22527                         options[opt.name] = optValue !== "false";
22528                         if (optValue === "false" || optValue === "true") {
22529                             i++;
22530                         }
22531                         break;
22532                     case "string":
22533                         options[opt.name] = args[i] || "";
22534                         i++;
22535                         break;
22536                     case "list":
22537                         var result = parseListTypeOption(opt, args[i], errors);
22538                         options[opt.name] = result || [];
22539                         if (result) {
22540                             i++;
22541                         }
22542                         break;
22543                     default:
22544                         options[opt.name] = parseCustomTypeOption(opt, args[i], errors);
22545                         i++;
22546                         break;
22547                 }
22548             }
22549             else {
22550                 options[opt.name] = undefined;
22551                 i++;
22552             }
22553         }
22554         return i;
22555     }
22556     ts.compilerOptionsDidYouMeanDiagnostics = {
22557         getOptionsNameMap: getOptionsNameMap,
22558         optionDeclarations: ts.optionDeclarations,
22559         unknownOptionDiagnostic: ts.Diagnostics.Unknown_compiler_option_0,
22560         unknownDidYouMeanDiagnostic: ts.Diagnostics.Unknown_compiler_option_0_Did_you_mean_1,
22561         optionTypeMismatchDiagnostic: ts.Diagnostics.Compiler_option_0_expects_an_argument
22562     };
22563     function parseCommandLine(commandLine, readFile) {
22564         return parseCommandLineWorker(ts.compilerOptionsDidYouMeanDiagnostics, commandLine, readFile);
22565     }
22566     ts.parseCommandLine = parseCommandLine;
22567     function getOptionFromName(optionName, allowShort) {
22568         return getOptionDeclarationFromName(getOptionsNameMap, optionName, allowShort);
22569     }
22570     ts.getOptionFromName = getOptionFromName;
22571     function getOptionDeclarationFromName(getOptionNameMap, optionName, allowShort) {
22572         if (allowShort === void 0) { allowShort = false; }
22573         optionName = optionName.toLowerCase();
22574         var _a = getOptionNameMap(), optionsNameMap = _a.optionsNameMap, shortOptionNames = _a.shortOptionNames;
22575         if (allowShort) {
22576             var short = shortOptionNames.get(optionName);
22577             if (short !== undefined) {
22578                 optionName = short;
22579             }
22580         }
22581         return optionsNameMap.get(optionName);
22582     }
22583     var buildOptionsNameMapCache;
22584     function getBuildOptionsNameMap() {
22585         return buildOptionsNameMapCache || (buildOptionsNameMapCache = createOptionNameMap(ts.buildOpts));
22586     }
22587     var buildOptionsDidYouMeanDiagnostics = {
22588         getOptionsNameMap: getBuildOptionsNameMap,
22589         optionDeclarations: ts.buildOpts,
22590         unknownOptionDiagnostic: ts.Diagnostics.Unknown_build_option_0,
22591         unknownDidYouMeanDiagnostic: ts.Diagnostics.Unknown_build_option_0_Did_you_mean_1,
22592         optionTypeMismatchDiagnostic: ts.Diagnostics.Build_option_0_requires_a_value_of_type_1
22593     };
22594     function parseBuildCommand(args) {
22595         var _a = parseCommandLineWorker(buildOptionsDidYouMeanDiagnostics, args), options = _a.options, watchOptions = _a.watchOptions, projects = _a.fileNames, errors = _a.errors;
22596         var buildOptions = options;
22597         if (projects.length === 0) {
22598             projects.push(".");
22599         }
22600         if (buildOptions.clean && buildOptions.force) {
22601             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "force"));
22602         }
22603         if (buildOptions.clean && buildOptions.verbose) {
22604             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "verbose"));
22605         }
22606         if (buildOptions.clean && buildOptions.watch) {
22607             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "watch"));
22608         }
22609         if (buildOptions.watch && buildOptions.dry) {
22610             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "watch", "dry"));
22611         }
22612         return { buildOptions: buildOptions, watchOptions: watchOptions, projects: projects, errors: errors };
22613     }
22614     ts.parseBuildCommand = parseBuildCommand;
22615     function getDiagnosticText(_message) {
22616         var _args = [];
22617         for (var _i = 1; _i < arguments.length; _i++) {
22618             _args[_i - 1] = arguments[_i];
22619         }
22620         var diagnostic = ts.createCompilerDiagnostic.apply(undefined, arguments);
22621         return diagnostic.messageText;
22622     }
22623     ts.getDiagnosticText = getDiagnosticText;
22624     function getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, extendedConfigCache, watchOptionsToExtend, extraFileExtensions) {
22625         var configFileText = tryReadFile(configFileName, function (fileName) { return host.readFile(fileName); });
22626         if (!ts.isString(configFileText)) {
22627             host.onUnRecoverableConfigFileDiagnostic(configFileText);
22628             return undefined;
22629         }
22630         var result = ts.parseJsonText(configFileName, configFileText);
22631         var cwd = host.getCurrentDirectory();
22632         result.path = ts.toPath(configFileName, cwd, ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames));
22633         result.resolvedPath = result.path;
22634         result.originalFileName = result.fileName;
22635         return parseJsonSourceFileConfigFileContent(result, host, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), cwd), optionsToExtend, ts.getNormalizedAbsolutePath(configFileName, cwd), undefined, extraFileExtensions, extendedConfigCache, watchOptionsToExtend);
22636     }
22637     ts.getParsedCommandLineOfConfigFile = getParsedCommandLineOfConfigFile;
22638     function readConfigFile(fileName, readFile) {
22639         var textOrDiagnostic = tryReadFile(fileName, readFile);
22640         return ts.isString(textOrDiagnostic) ? parseConfigFileTextToJson(fileName, textOrDiagnostic) : { config: {}, error: textOrDiagnostic };
22641     }
22642     ts.readConfigFile = readConfigFile;
22643     function parseConfigFileTextToJson(fileName, jsonText) {
22644         var jsonSourceFile = ts.parseJsonText(fileName, jsonText);
22645         return {
22646             config: convertToObject(jsonSourceFile, jsonSourceFile.parseDiagnostics),
22647             error: jsonSourceFile.parseDiagnostics.length ? jsonSourceFile.parseDiagnostics[0] : undefined
22648         };
22649     }
22650     ts.parseConfigFileTextToJson = parseConfigFileTextToJson;
22651     function readJsonConfigFile(fileName, readFile) {
22652         var textOrDiagnostic = tryReadFile(fileName, readFile);
22653         return ts.isString(textOrDiagnostic) ? ts.parseJsonText(fileName, textOrDiagnostic) : { parseDiagnostics: [textOrDiagnostic] };
22654     }
22655     ts.readJsonConfigFile = readJsonConfigFile;
22656     function tryReadFile(fileName, readFile) {
22657         var text;
22658         try {
22659             text = readFile(fileName);
22660         }
22661         catch (e) {
22662             return ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message);
22663         }
22664         return text === undefined ? ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0, fileName) : text;
22665     }
22666     ts.tryReadFile = tryReadFile;
22667     function commandLineOptionsToMap(options) {
22668         return ts.arrayToMap(options, getOptionName);
22669     }
22670     var typeAcquisitionDidYouMeanDiagnostics = {
22671         optionDeclarations: ts.typeAcquisitionDeclarations,
22672         unknownOptionDiagnostic: ts.Diagnostics.Unknown_type_acquisition_option_0,
22673         unknownDidYouMeanDiagnostic: ts.Diagnostics.Unknown_type_acquisition_option_0_Did_you_mean_1,
22674     };
22675     var watchOptionsNameMapCache;
22676     function getWatchOptionsNameMap() {
22677         return watchOptionsNameMapCache || (watchOptionsNameMapCache = createOptionNameMap(ts.optionsForWatch));
22678     }
22679     var watchOptionsDidYouMeanDiagnostics = {
22680         getOptionsNameMap: getWatchOptionsNameMap,
22681         optionDeclarations: ts.optionsForWatch,
22682         unknownOptionDiagnostic: ts.Diagnostics.Unknown_watch_option_0,
22683         unknownDidYouMeanDiagnostic: ts.Diagnostics.Unknown_watch_option_0_Did_you_mean_1,
22684         optionTypeMismatchDiagnostic: ts.Diagnostics.Watch_option_0_requires_a_value_of_type_1
22685     };
22686     var commandLineCompilerOptionsMapCache;
22687     function getCommandLineCompilerOptionsMap() {
22688         return commandLineCompilerOptionsMapCache || (commandLineCompilerOptionsMapCache = commandLineOptionsToMap(ts.optionDeclarations));
22689     }
22690     var commandLineWatchOptionsMapCache;
22691     function getCommandLineWatchOptionsMap() {
22692         return commandLineWatchOptionsMapCache || (commandLineWatchOptionsMapCache = commandLineOptionsToMap(ts.optionsForWatch));
22693     }
22694     var commandLineTypeAcquisitionMapCache;
22695     function getCommandLineTypeAcquisitionMap() {
22696         return commandLineTypeAcquisitionMapCache || (commandLineTypeAcquisitionMapCache = commandLineOptionsToMap(ts.typeAcquisitionDeclarations));
22697     }
22698     var _tsconfigRootOptions;
22699     function getTsconfigRootOptionsMap() {
22700         if (_tsconfigRootOptions === undefined) {
22701             _tsconfigRootOptions = {
22702                 name: undefined,
22703                 type: "object",
22704                 elementOptions: commandLineOptionsToMap([
22705                     {
22706                         name: "compilerOptions",
22707                         type: "object",
22708                         elementOptions: getCommandLineCompilerOptionsMap(),
22709                         extraKeyDiagnostics: ts.compilerOptionsDidYouMeanDiagnostics,
22710                     },
22711                     {
22712                         name: "watchOptions",
22713                         type: "object",
22714                         elementOptions: getCommandLineWatchOptionsMap(),
22715                         extraKeyDiagnostics: watchOptionsDidYouMeanDiagnostics,
22716                     },
22717                     {
22718                         name: "typingOptions",
22719                         type: "object",
22720                         elementOptions: getCommandLineTypeAcquisitionMap(),
22721                         extraKeyDiagnostics: typeAcquisitionDidYouMeanDiagnostics,
22722                     },
22723                     {
22724                         name: "typeAcquisition",
22725                         type: "object",
22726                         elementOptions: getCommandLineTypeAcquisitionMap(),
22727                         extraKeyDiagnostics: typeAcquisitionDidYouMeanDiagnostics
22728                     },
22729                     {
22730                         name: "extends",
22731                         type: "string"
22732                     },
22733                     {
22734                         name: "references",
22735                         type: "list",
22736                         element: {
22737                             name: "references",
22738                             type: "object"
22739                         }
22740                     },
22741                     {
22742                         name: "files",
22743                         type: "list",
22744                         element: {
22745                             name: "files",
22746                             type: "string"
22747                         }
22748                     },
22749                     {
22750                         name: "include",
22751                         type: "list",
22752                         element: {
22753                             name: "include",
22754                             type: "string"
22755                         }
22756                     },
22757                     {
22758                         name: "exclude",
22759                         type: "list",
22760                         element: {
22761                             name: "exclude",
22762                             type: "string"
22763                         }
22764                     },
22765                     ts.compileOnSaveCommandLineOption
22766                 ])
22767             };
22768         }
22769         return _tsconfigRootOptions;
22770     }
22771     function convertToObject(sourceFile, errors) {
22772         return convertToObjectWorker(sourceFile, errors, true, undefined, undefined);
22773     }
22774     ts.convertToObject = convertToObject;
22775     function convertToObjectWorker(sourceFile, errors, returnValue, knownRootOptions, jsonConversionNotifier) {
22776         if (!sourceFile.statements.length) {
22777             return returnValue ? {} : undefined;
22778         }
22779         return convertPropertyValueToJson(sourceFile.statements[0].expression, knownRootOptions);
22780         function isRootOptionMap(knownOptions) {
22781             return knownRootOptions && knownRootOptions.elementOptions === knownOptions;
22782         }
22783         function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) {
22784             var result = returnValue ? {} : undefined;
22785             var _loop_3 = function (element) {
22786                 if (element.kind !== 281) {
22787                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected));
22788                     return "continue";
22789                 }
22790                 if (element.questionToken) {
22791                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.questionToken, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?"));
22792                 }
22793                 if (!isDoubleQuotedString(element.name)) {
22794                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, ts.Diagnostics.String_literal_with_double_quotes_expected));
22795                 }
22796                 var textOfKey = ts.isComputedNonLiteralName(element.name) ? undefined : ts.getTextOfPropertyName(element.name);
22797                 var keyText = textOfKey && ts.unescapeLeadingUnderscores(textOfKey);
22798                 var option = keyText && knownOptions ? knownOptions.get(keyText) : undefined;
22799                 if (keyText && extraKeyDiagnostics && !option) {
22800                     if (knownOptions) {
22801                         errors.push(createUnknownOptionError(keyText, extraKeyDiagnostics, function (message, arg0, arg1) { return ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, message, arg0, arg1); }));
22802                     }
22803                     else {
22804                         errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, extraKeyDiagnostics.unknownOptionDiagnostic, keyText));
22805                     }
22806                 }
22807                 var value = convertPropertyValueToJson(element.initializer, option);
22808                 if (typeof keyText !== "undefined") {
22809                     if (returnValue) {
22810                         result[keyText] = value;
22811                     }
22812                     if (jsonConversionNotifier &&
22813                         (parentOption || isRootOptionMap(knownOptions))) {
22814                         var isValidOptionValue = isCompilerOptionsValue(option, value);
22815                         if (parentOption) {
22816                             if (isValidOptionValue) {
22817                                 jsonConversionNotifier.onSetValidOptionKeyValueInParent(parentOption, option, value);
22818                             }
22819                         }
22820                         else if (isRootOptionMap(knownOptions)) {
22821                             if (isValidOptionValue) {
22822                                 jsonConversionNotifier.onSetValidOptionKeyValueInRoot(keyText, element.name, value, element.initializer);
22823                             }
22824                             else if (!option) {
22825                                 jsonConversionNotifier.onSetUnknownOptionKeyValueInRoot(keyText, element.name, value, element.initializer);
22826                             }
22827                         }
22828                     }
22829                 }
22830             };
22831             for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
22832                 var element = _a[_i];
22833                 _loop_3(element);
22834             }
22835             return result;
22836         }
22837         function convertArrayLiteralExpressionToJson(elements, elementOption) {
22838             if (!returnValue) {
22839                 return elements.forEach(function (element) { return convertPropertyValueToJson(element, elementOption); });
22840             }
22841             return ts.filter(elements.map(function (element) { return convertPropertyValueToJson(element, elementOption); }), function (v) { return v !== undefined; });
22842         }
22843         function convertPropertyValueToJson(valueExpression, option) {
22844             switch (valueExpression.kind) {
22845                 case 106:
22846                     reportInvalidOptionValue(option && option.type !== "boolean");
22847                     return true;
22848                 case 91:
22849                     reportInvalidOptionValue(option && option.type !== "boolean");
22850                     return false;
22851                 case 100:
22852                     reportInvalidOptionValue(option && option.name === "extends");
22853                     return null;
22854                 case 10:
22855                     if (!isDoubleQuotedString(valueExpression)) {
22856                         errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected));
22857                     }
22858                     reportInvalidOptionValue(option && (ts.isString(option.type) && option.type !== "string"));
22859                     var text = valueExpression.text;
22860                     if (option && !ts.isString(option.type)) {
22861                         var customOption = option;
22862                         if (!customOption.type.has(text.toLowerCase())) {
22863                             errors.push(createDiagnosticForInvalidCustomType(customOption, function (message, arg0, arg1) { return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, message, arg0, arg1); }));
22864                         }
22865                     }
22866                     return text;
22867                 case 8:
22868                     reportInvalidOptionValue(option && option.type !== "number");
22869                     return Number(valueExpression.text);
22870                 case 207:
22871                     if (valueExpression.operator !== 40 || valueExpression.operand.kind !== 8) {
22872                         break;
22873                     }
22874                     reportInvalidOptionValue(option && option.type !== "number");
22875                     return -Number(valueExpression.operand.text);
22876                 case 193:
22877                     reportInvalidOptionValue(option && option.type !== "object");
22878                     var objectLiteralExpression = valueExpression;
22879                     if (option) {
22880                         var _a = option, elementOptions = _a.elementOptions, extraKeyDiagnostics = _a.extraKeyDiagnostics, optionName = _a.name;
22881                         return convertObjectLiteralExpressionToJson(objectLiteralExpression, elementOptions, extraKeyDiagnostics, optionName);
22882                     }
22883                     else {
22884                         return convertObjectLiteralExpressionToJson(objectLiteralExpression, undefined, undefined, undefined);
22885                     }
22886                 case 192:
22887                     reportInvalidOptionValue(option && option.type !== "list");
22888                     return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element);
22889             }
22890             if (option) {
22891                 reportInvalidOptionValue(true);
22892             }
22893             else {
22894                 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));
22895             }
22896             return undefined;
22897             function reportInvalidOptionValue(isError) {
22898                 if (isError) {
22899                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, option.name, getCompilerOptionValueTypeString(option)));
22900                 }
22901             }
22902         }
22903         function isDoubleQuotedString(node) {
22904             return ts.isStringLiteral(node) && ts.isStringDoubleQuoted(node, sourceFile);
22905         }
22906     }
22907     ts.convertToObjectWorker = convertToObjectWorker;
22908     function getCompilerOptionValueTypeString(option) {
22909         return option.type === "list" ?
22910             "Array" :
22911             ts.isString(option.type) ? option.type : "string";
22912     }
22913     function isCompilerOptionsValue(option, value) {
22914         if (option) {
22915             if (isNullOrUndefined(value))
22916                 return true;
22917             if (option.type === "list") {
22918                 return ts.isArray(value);
22919             }
22920             var expectedType = ts.isString(option.type) ? option.type : "string";
22921             return typeof value === expectedType;
22922         }
22923         return false;
22924     }
22925     function convertToTSConfig(configParseResult, configFileName, host) {
22926         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames);
22927         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); });
22928         var optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames });
22929         var watchOptionMap = configParseResult.watchOptions && serializeWatchOptions(configParseResult.watchOptions);
22930         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 ? {
22931             include: filterSameAsDefaultInclude(configParseResult.configFileSpecs.validatedIncludeSpecs),
22932             exclude: configParseResult.configFileSpecs.validatedExcludeSpecs
22933         } : {})), { compileOnSave: !!configParseResult.compileOnSave ? true : undefined });
22934         return config;
22935     }
22936     ts.convertToTSConfig = convertToTSConfig;
22937     function optionMapToObject(optionMap) {
22938         return __assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) {
22939             var _a;
22940             return (__assign(__assign({}, prev), (_a = {}, _a[cur[0]] = cur[1], _a)));
22941         }, {}));
22942     }
22943     function filterSameAsDefaultInclude(specs) {
22944         if (!ts.length(specs))
22945             return undefined;
22946         if (ts.length(specs) !== 1)
22947             return specs;
22948         if (specs[0] === "**/*")
22949             return undefined;
22950         return specs;
22951     }
22952     function matchesSpecs(path, includeSpecs, excludeSpecs, host) {
22953         if (!includeSpecs)
22954             return function (_) { return true; };
22955         var patterns = ts.getFileMatcherPatterns(path, excludeSpecs, includeSpecs, host.useCaseSensitiveFileNames, host.getCurrentDirectory());
22956         var excludeRe = patterns.excludePattern && ts.getRegexFromPattern(patterns.excludePattern, host.useCaseSensitiveFileNames);
22957         var includeRe = patterns.includeFilePattern && ts.getRegexFromPattern(patterns.includeFilePattern, host.useCaseSensitiveFileNames);
22958         if (includeRe) {
22959             if (excludeRe) {
22960                 return function (path) { return !(includeRe.test(path) && !excludeRe.test(path)); };
22961             }
22962             return function (path) { return !includeRe.test(path); };
22963         }
22964         if (excludeRe) {
22965             return function (path) { return excludeRe.test(path); };
22966         }
22967         return function (_) { return true; };
22968     }
22969     function getCustomTypeMapOfCommandLineOption(optionDefinition) {
22970         if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean" || optionDefinition.type === "object") {
22971             return undefined;
22972         }
22973         else if (optionDefinition.type === "list") {
22974             return getCustomTypeMapOfCommandLineOption(optionDefinition.element);
22975         }
22976         else {
22977             return optionDefinition.type;
22978         }
22979     }
22980     function getNameOfCompilerOptionValue(value, customTypeMap) {
22981         return ts.forEachEntry(customTypeMap, function (mapValue, key) {
22982             if (mapValue === value) {
22983                 return key;
22984             }
22985         });
22986     }
22987     function serializeCompilerOptions(options, pathOptions) {
22988         return serializeOptionBaseObject(options, getOptionsNameMap(), pathOptions);
22989     }
22990     function serializeWatchOptions(options) {
22991         return serializeOptionBaseObject(options, getWatchOptionsNameMap());
22992     }
22993     function serializeOptionBaseObject(options, _a, pathOptions) {
22994         var optionsNameMap = _a.optionsNameMap;
22995         var result = ts.createMap();
22996         var getCanonicalFileName = pathOptions && ts.createGetCanonicalFileName(pathOptions.useCaseSensitiveFileNames);
22997         var _loop_4 = function (name) {
22998             if (ts.hasProperty(options, name)) {
22999                 if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) {
23000                     return "continue";
23001                 }
23002                 var value = options[name];
23003                 var optionDefinition = optionsNameMap.get(name.toLowerCase());
23004                 if (optionDefinition) {
23005                     var customTypeMap_1 = getCustomTypeMapOfCommandLineOption(optionDefinition);
23006                     if (!customTypeMap_1) {
23007                         if (pathOptions && optionDefinition.isFilePath) {
23008                             result.set(name, ts.getRelativePathFromFile(pathOptions.configFilePath, ts.getNormalizedAbsolutePath(value, ts.getDirectoryPath(pathOptions.configFilePath)), getCanonicalFileName));
23009                         }
23010                         else {
23011                             result.set(name, value);
23012                         }
23013                     }
23014                     else {
23015                         if (optionDefinition.type === "list") {
23016                             result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); }));
23017                         }
23018                         else {
23019                             result.set(name, getNameOfCompilerOptionValue(value, customTypeMap_1));
23020                         }
23021                     }
23022                 }
23023             }
23024         };
23025         for (var name in options) {
23026             _loop_4(name);
23027         }
23028         return result;
23029     }
23030     function generateTSConfig(options, fileNames, newLine) {
23031         var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions);
23032         var compilerOptionsMap = serializeCompilerOptions(compilerOptions);
23033         return writeConfigurations();
23034         function getDefaultValueForOption(option) {
23035             switch (option.type) {
23036                 case "number":
23037                     return 1;
23038                 case "boolean":
23039                     return true;
23040                 case "string":
23041                     return option.isFilePath ? "./" : "";
23042                 case "list":
23043                     return [];
23044                 case "object":
23045                     return {};
23046                 default:
23047                     var iterResult = option.type.keys().next();
23048                     if (!iterResult.done)
23049                         return iterResult.value;
23050                     return ts.Debug.fail("Expected 'option.type' to have entries.");
23051             }
23052         }
23053         function makePadding(paddingLength) {
23054             return Array(paddingLength + 1).join(" ");
23055         }
23056         function isAllowedOption(_a) {
23057             var category = _a.category, name = _a.name;
23058             return category !== undefined
23059                 && category !== ts.Diagnostics.Command_line_Options
23060                 && (category !== ts.Diagnostics.Advanced_Options || compilerOptionsMap.has(name));
23061         }
23062         function writeConfigurations() {
23063             var categorizedOptions = ts.createMultiMap();
23064             for (var _i = 0, optionDeclarations_1 = ts.optionDeclarations; _i < optionDeclarations_1.length; _i++) {
23065                 var option = optionDeclarations_1[_i];
23066                 var category = option.category;
23067                 if (isAllowedOption(option)) {
23068                     categorizedOptions.add(ts.getLocaleSpecificMessage(category), option);
23069                 }
23070             }
23071             var marginLength = 0;
23072             var seenKnownKeys = 0;
23073             var entries = [];
23074             categorizedOptions.forEach(function (options, category) {
23075                 if (entries.length !== 0) {
23076                     entries.push({ value: "" });
23077                 }
23078                 entries.push({ value: "/* " + category + " */" });
23079                 for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
23080                     var option = options_1[_i];
23081                     var optionName = void 0;
23082                     if (compilerOptionsMap.has(option.name)) {
23083                         optionName = "\"" + option.name + "\": " + JSON.stringify(compilerOptionsMap.get(option.name)) + ((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ",");
23084                     }
23085                     else {
23086                         optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ",";
23087                     }
23088                     entries.push({
23089                         value: optionName,
23090                         description: "/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */"
23091                     });
23092                     marginLength = Math.max(optionName.length, marginLength);
23093                 }
23094             });
23095             var tab = makePadding(2);
23096             var result = [];
23097             result.push("{");
23098             result.push(tab + "\"compilerOptions\": {");
23099             result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_json_to_read_more_about_this_file) + " */");
23100             result.push("");
23101             for (var _a = 0, entries_3 = entries; _a < entries_3.length; _a++) {
23102                 var entry = entries_3[_a];
23103                 var value = entry.value, _b = entry.description, description = _b === void 0 ? "" : _b;
23104                 result.push(value && "" + tab + tab + value + (description && (makePadding(marginLength - value.length + 2) + description)));
23105             }
23106             if (fileNames.length) {
23107                 result.push(tab + "},");
23108                 result.push(tab + "\"files\": [");
23109                 for (var i = 0; i < fileNames.length; i++) {
23110                     result.push("" + tab + tab + JSON.stringify(fileNames[i]) + (i === fileNames.length - 1 ? "" : ","));
23111                 }
23112                 result.push(tab + "]");
23113             }
23114             else {
23115                 result.push(tab + "}");
23116             }
23117             result.push("}");
23118             return result.join(newLine) + newLine;
23119         }
23120     }
23121     ts.generateTSConfig = generateTSConfig;
23122     function convertToOptionsWithAbsolutePaths(options, toAbsolutePath) {
23123         var result = {};
23124         var optionsNameMap = getOptionsNameMap().optionsNameMap;
23125         for (var name in options) {
23126             if (ts.hasProperty(options, name)) {
23127                 result[name] = convertToOptionValueWithAbsolutePaths(optionsNameMap.get(name.toLowerCase()), options[name], toAbsolutePath);
23128             }
23129         }
23130         if (result.configFilePath) {
23131             result.configFilePath = toAbsolutePath(result.configFilePath);
23132         }
23133         return result;
23134     }
23135     ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths;
23136     function convertToOptionValueWithAbsolutePaths(option, value, toAbsolutePath) {
23137         if (option && !isNullOrUndefined(value)) {
23138             if (option.type === "list") {
23139                 var values = value;
23140                 if (option.element.isFilePath && values.length) {
23141                     return values.map(toAbsolutePath);
23142                 }
23143             }
23144             else if (option.isFilePath) {
23145                 return toAbsolutePath(value);
23146             }
23147         }
23148         return value;
23149     }
23150     function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) {
23151         return parseJsonConfigFileContentWorker(json, undefined, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache);
23152     }
23153     ts.parseJsonConfigFileContent = parseJsonConfigFileContent;
23154     function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) {
23155         return parseJsonConfigFileContentWorker(undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache);
23156     }
23157     ts.parseJsonSourceFileConfigFileContent = parseJsonSourceFileConfigFileContent;
23158     function setConfigFileInOptions(options, configFile) {
23159         if (configFile) {
23160             Object.defineProperty(options, "configFile", { enumerable: false, writable: false, value: configFile });
23161         }
23162     }
23163     ts.setConfigFileInOptions = setConfigFileInOptions;
23164     function isNullOrUndefined(x) {
23165         return x === undefined || x === null;
23166     }
23167     function directoryOfCombinedPath(fileName, basePath) {
23168         return ts.getDirectoryPath(ts.getNormalizedAbsolutePath(fileName, basePath));
23169     }
23170     function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache) {
23171         if (existingOptions === void 0) { existingOptions = {}; }
23172         if (resolutionStack === void 0) { resolutionStack = []; }
23173         if (extraFileExtensions === void 0) { extraFileExtensions = []; }
23174         ts.Debug.assert((json === undefined && sourceFile !== undefined) || (json !== undefined && sourceFile === undefined));
23175         var errors = [];
23176         var parsedConfig = parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors, extendedConfigCache);
23177         var raw = parsedConfig.raw;
23178         var options = ts.extend(existingOptions, parsedConfig.options || {});
23179         var watchOptions = existingWatchOptions && parsedConfig.watchOptions ?
23180             ts.extend(existingWatchOptions, parsedConfig.watchOptions) :
23181             parsedConfig.watchOptions || existingWatchOptions;
23182         options.configFilePath = configFileName && ts.normalizeSlashes(configFileName);
23183         setConfigFileInOptions(options, sourceFile);
23184         var projectReferences;
23185         var _a = getFileNames(), fileNames = _a.fileNames, wildcardDirectories = _a.wildcardDirectories, spec = _a.spec;
23186         return {
23187             options: options,
23188             watchOptions: watchOptions,
23189             fileNames: fileNames,
23190             projectReferences: projectReferences,
23191             typeAcquisition: parsedConfig.typeAcquisition || getDefaultTypeAcquisition(),
23192             raw: raw,
23193             errors: errors,
23194             wildcardDirectories: wildcardDirectories,
23195             compileOnSave: !!raw.compileOnSave,
23196             configFileSpecs: spec
23197         };
23198         function getFileNames() {
23199             var filesSpecs;
23200             if (ts.hasProperty(raw, "files") && !isNullOrUndefined(raw.files)) {
23201                 if (ts.isArray(raw.files)) {
23202                     filesSpecs = raw.files;
23203                     var hasReferences = ts.hasProperty(raw, "references") && !isNullOrUndefined(raw.references);
23204                     var hasZeroOrNoReferences = !hasReferences || raw.references.length === 0;
23205                     var hasExtends = ts.hasProperty(raw, "extends");
23206                     if (filesSpecs.length === 0 && hasZeroOrNoReferences && !hasExtends) {
23207                         if (sourceFile) {
23208                             var fileName = configFileName || "tsconfig.json";
23209                             var diagnosticMessage = ts.Diagnostics.The_files_list_in_config_file_0_is_empty;
23210                             var nodeValue = ts.firstDefined(ts.getTsConfigPropArray(sourceFile, "files"), function (property) { return property.initializer; });
23211                             var error = nodeValue
23212                                 ? ts.createDiagnosticForNodeInSourceFile(sourceFile, nodeValue, diagnosticMessage, fileName)
23213                                 : ts.createCompilerDiagnostic(diagnosticMessage, fileName);
23214                             errors.push(error);
23215                         }
23216                         else {
23217                             createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json");
23218                         }
23219                     }
23220                 }
23221                 else {
23222                     createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array");
23223                 }
23224             }
23225             var includeSpecs;
23226             if (ts.hasProperty(raw, "include") && !isNullOrUndefined(raw.include)) {
23227                 if (ts.isArray(raw.include)) {
23228                     includeSpecs = raw.include;
23229                 }
23230                 else {
23231                     createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "include", "Array");
23232                 }
23233             }
23234             var excludeSpecs;
23235             if (ts.hasProperty(raw, "exclude") && !isNullOrUndefined(raw.exclude)) {
23236                 if (ts.isArray(raw.exclude)) {
23237                     excludeSpecs = raw.exclude;
23238                 }
23239                 else {
23240                     createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array");
23241                 }
23242             }
23243             else if (raw.compilerOptions) {
23244                 var outDir = raw.compilerOptions.outDir;
23245                 var declarationDir = raw.compilerOptions.declarationDir;
23246                 if (outDir || declarationDir) {
23247                     excludeSpecs = [outDir, declarationDir].filter(function (d) { return !!d; });
23248                 }
23249             }
23250             if (filesSpecs === undefined && includeSpecs === undefined) {
23251                 includeSpecs = ["**/*"];
23252             }
23253             var result = matchFileNames(filesSpecs, includeSpecs, excludeSpecs, configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath, options, host, errors, extraFileExtensions, sourceFile);
23254             if (shouldReportNoInputFiles(result, canJsonReportNoInutFiles(raw), resolutionStack)) {
23255                 errors.push(getErrorForNoInputFiles(result.spec, configFileName));
23256             }
23257             if (ts.hasProperty(raw, "references") && !isNullOrUndefined(raw.references)) {
23258                 if (ts.isArray(raw.references)) {
23259                     for (var _i = 0, _a = raw.references; _i < _a.length; _i++) {
23260                         var ref = _a[_i];
23261                         if (typeof ref.path !== "string") {
23262                             createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "reference.path", "string");
23263                         }
23264                         else {
23265                             (projectReferences || (projectReferences = [])).push({
23266                                 path: ts.getNormalizedAbsolutePath(ref.path, basePath),
23267                                 originalPath: ref.path,
23268                                 prepend: ref.prepend,
23269                                 circular: ref.circular
23270                             });
23271                         }
23272                     }
23273                 }
23274                 else {
23275                     createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "references", "Array");
23276                 }
23277             }
23278             return result;
23279         }
23280         function createCompilerDiagnosticOnlyIfJson(message, arg0, arg1) {
23281             if (!sourceFile) {
23282                 errors.push(ts.createCompilerDiagnostic(message, arg0, arg1));
23283             }
23284         }
23285     }
23286     function isErrorNoInputFiles(error) {
23287         return error.code === ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2.code;
23288     }
23289     function getErrorForNoInputFiles(_a, configFileName) {
23290         var includeSpecs = _a.includeSpecs, excludeSpecs = _a.excludeSpecs;
23291         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 || []));
23292     }
23293     function shouldReportNoInputFiles(result, canJsonReportNoInutFiles, resolutionStack) {
23294         return result.fileNames.length === 0 && canJsonReportNoInutFiles && (!resolutionStack || resolutionStack.length === 0);
23295     }
23296     function canJsonReportNoInutFiles(raw) {
23297         return !ts.hasProperty(raw, "files") && !ts.hasProperty(raw, "references");
23298     }
23299     ts.canJsonReportNoInutFiles = canJsonReportNoInutFiles;
23300     function updateErrorForNoInputFiles(result, configFileName, configFileSpecs, configParseDiagnostics, canJsonReportNoInutFiles) {
23301         var existingErrors = configParseDiagnostics.length;
23302         if (shouldReportNoInputFiles(result, canJsonReportNoInutFiles)) {
23303             configParseDiagnostics.push(getErrorForNoInputFiles(configFileSpecs, configFileName));
23304         }
23305         else {
23306             ts.filterMutate(configParseDiagnostics, function (error) { return !isErrorNoInputFiles(error); });
23307         }
23308         return existingErrors !== configParseDiagnostics.length;
23309     }
23310     ts.updateErrorForNoInputFiles = updateErrorForNoInputFiles;
23311     function isSuccessfulParsedTsconfig(value) {
23312         return !!value.options;
23313     }
23314     function parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors, extendedConfigCache) {
23315         basePath = ts.normalizeSlashes(basePath);
23316         var resolvedPath = ts.getNormalizedAbsolutePath(configFileName || "", basePath);
23317         if (resolutionStack.indexOf(resolvedPath) >= 0) {
23318             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, __spreadArrays(resolutionStack, [resolvedPath]).join(" -> ")));
23319             return { raw: json || convertToObject(sourceFile, errors) };
23320         }
23321         var ownConfig = json ?
23322             parseOwnConfigOfJson(json, host, basePath, configFileName, errors) :
23323             parseOwnConfigOfJsonSourceFile(sourceFile, host, basePath, configFileName, errors);
23324         if (ownConfig.extendedConfigPath) {
23325             resolutionStack = resolutionStack.concat([resolvedPath]);
23326             var extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache);
23327             if (extendedConfig && isSuccessfulParsedTsconfig(extendedConfig)) {
23328                 var baseRaw_1 = extendedConfig.raw;
23329                 var raw_1 = ownConfig.raw;
23330                 var setPropertyInRawIfNotUndefined = function (propertyName) {
23331                     var value = raw_1[propertyName] || baseRaw_1[propertyName];
23332                     if (value) {
23333                         raw_1[propertyName] = value;
23334                     }
23335                 };
23336                 setPropertyInRawIfNotUndefined("include");
23337                 setPropertyInRawIfNotUndefined("exclude");
23338                 setPropertyInRawIfNotUndefined("files");
23339                 if (raw_1.compileOnSave === undefined) {
23340                     raw_1.compileOnSave = baseRaw_1.compileOnSave;
23341                 }
23342                 ownConfig.options = ts.assign({}, extendedConfig.options, ownConfig.options);
23343                 ownConfig.watchOptions = ownConfig.watchOptions && extendedConfig.watchOptions ?
23344                     ts.assign({}, extendedConfig.watchOptions, ownConfig.watchOptions) :
23345                     ownConfig.watchOptions || extendedConfig.watchOptions;
23346             }
23347         }
23348         return ownConfig;
23349     }
23350     function parseOwnConfigOfJson(json, host, basePath, configFileName, errors) {
23351         if (ts.hasProperty(json, "excludes")) {
23352             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude));
23353         }
23354         var options = convertCompilerOptionsFromJsonWorker(json.compilerOptions, basePath, errors, configFileName);
23355         var typeAcquisition = convertTypeAcquisitionFromJsonWorker(json.typeAcquisition || json.typingOptions, basePath, errors, configFileName);
23356         var watchOptions = convertWatchOptionsFromJsonWorker(json.watchOptions, basePath, errors);
23357         json.compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors);
23358         var extendedConfigPath;
23359         if (json.extends) {
23360             if (!ts.isString(json.extends)) {
23361                 errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string"));
23362             }
23363             else {
23364                 var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath;
23365                 extendedConfigPath = getExtendsConfigPath(json.extends, host, newBase, errors, ts.createCompilerDiagnostic);
23366             }
23367         }
23368         return { raw: json, options: options, watchOptions: watchOptions, typeAcquisition: typeAcquisition, extendedConfigPath: extendedConfigPath };
23369     }
23370     function parseOwnConfigOfJsonSourceFile(sourceFile, host, basePath, configFileName, errors) {
23371         var options = getDefaultCompilerOptions(configFileName);
23372         var typeAcquisition, typingOptionstypeAcquisition;
23373         var watchOptions;
23374         var extendedConfigPath;
23375         var optionsIterator = {
23376             onSetValidOptionKeyValueInParent: function (parentOption, option, value) {
23377                 var currentOption;
23378                 switch (parentOption) {
23379                     case "compilerOptions":
23380                         currentOption = options;
23381                         break;
23382                     case "watchOptions":
23383                         currentOption = (watchOptions || (watchOptions = {}));
23384                         break;
23385                     case "typeAcquisition":
23386                         currentOption = (typeAcquisition || (typeAcquisition = getDefaultTypeAcquisition(configFileName)));
23387                         break;
23388                     case "typingOptions":
23389                         currentOption = (typingOptionstypeAcquisition || (typingOptionstypeAcquisition = getDefaultTypeAcquisition(configFileName)));
23390                         break;
23391                     default:
23392                         ts.Debug.fail("Unknown option");
23393                 }
23394                 currentOption[option.name] = normalizeOptionValue(option, basePath, value);
23395             },
23396             onSetValidOptionKeyValueInRoot: function (key, _keyNode, value, valueNode) {
23397                 switch (key) {
23398                     case "extends":
23399                         var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath;
23400                         extendedConfigPath = getExtendsConfigPath(value, host, newBase, errors, function (message, arg0) {
23401                             return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueNode, message, arg0);
23402                         });
23403                         return;
23404                 }
23405             },
23406             onSetUnknownOptionKeyValueInRoot: function (key, keyNode, _value, _valueNode) {
23407                 if (key === "excludes") {
23408                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, keyNode, ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude));
23409                 }
23410             }
23411         };
23412         var json = convertToObjectWorker(sourceFile, errors, true, getTsconfigRootOptionsMap(), optionsIterator);
23413         if (!typeAcquisition) {
23414             if (typingOptionstypeAcquisition) {
23415                 typeAcquisition = (typingOptionstypeAcquisition.enableAutoDiscovery !== undefined) ?
23416                     {
23417                         enable: typingOptionstypeAcquisition.enableAutoDiscovery,
23418                         include: typingOptionstypeAcquisition.include,
23419                         exclude: typingOptionstypeAcquisition.exclude
23420                     } :
23421                     typingOptionstypeAcquisition;
23422             }
23423             else {
23424                 typeAcquisition = getDefaultTypeAcquisition(configFileName);
23425             }
23426         }
23427         return { raw: json, options: options, watchOptions: watchOptions, typeAcquisition: typeAcquisition, extendedConfigPath: extendedConfigPath };
23428     }
23429     function getExtendsConfigPath(extendedConfig, host, basePath, errors, createDiagnostic) {
23430         extendedConfig = ts.normalizeSlashes(extendedConfig);
23431         if (ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../")) {
23432             var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath);
23433             if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) {
23434                 extendedConfigPath = extendedConfigPath + ".json";
23435                 if (!host.fileExists(extendedConfigPath)) {
23436                     errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig));
23437                     return undefined;
23438                 }
23439             }
23440             return extendedConfigPath;
23441         }
23442         var resolved = ts.nodeModuleNameResolver(extendedConfig, ts.combinePaths(basePath, "tsconfig.json"), { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, undefined, undefined, true);
23443         if (resolved.resolvedModule) {
23444             return resolved.resolvedModule.resolvedFileName;
23445         }
23446         errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig));
23447         return undefined;
23448     }
23449     function getExtendedConfig(sourceFile, extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache) {
23450         var _a;
23451         var path = host.useCaseSensitiveFileNames ? extendedConfigPath : ts.toFileNameLowerCase(extendedConfigPath);
23452         var value;
23453         var extendedResult;
23454         var extendedConfig;
23455         if (extendedConfigCache && (value = extendedConfigCache.get(path))) {
23456             (extendedResult = value.extendedResult, extendedConfig = value.extendedConfig);
23457         }
23458         else {
23459             extendedResult = readJsonConfigFile(extendedConfigPath, function (path) { return host.readFile(path); });
23460             if (!extendedResult.parseDiagnostics.length) {
23461                 var extendedDirname = ts.getDirectoryPath(extendedConfigPath);
23462                 extendedConfig = parseConfig(undefined, extendedResult, host, extendedDirname, ts.getBaseFileName(extendedConfigPath), resolutionStack, errors, extendedConfigCache);
23463                 if (isSuccessfulParsedTsconfig(extendedConfig)) {
23464                     var relativeDifference_1 = ts.convertToRelativePath(extendedDirname, basePath, ts.identity);
23465                     var updatePath_1 = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference_1, path); };
23466                     var mapPropertiesInRawIfNotUndefined = function (propertyName) {
23467                         if (raw_2[propertyName]) {
23468                             raw_2[propertyName] = ts.map(raw_2[propertyName], updatePath_1);
23469                         }
23470                     };
23471                     var raw_2 = extendedConfig.raw;
23472                     mapPropertiesInRawIfNotUndefined("include");
23473                     mapPropertiesInRawIfNotUndefined("exclude");
23474                     mapPropertiesInRawIfNotUndefined("files");
23475                 }
23476             }
23477             if (extendedConfigCache) {
23478                 extendedConfigCache.set(path, { extendedResult: extendedResult, extendedConfig: extendedConfig });
23479             }
23480         }
23481         if (sourceFile) {
23482             sourceFile.extendedSourceFiles = [extendedResult.fileName];
23483             if (extendedResult.extendedSourceFiles) {
23484                 (_a = sourceFile.extendedSourceFiles).push.apply(_a, extendedResult.extendedSourceFiles);
23485             }
23486         }
23487         if (extendedResult.parseDiagnostics.length) {
23488             errors.push.apply(errors, extendedResult.parseDiagnostics);
23489             return undefined;
23490         }
23491         return extendedConfig;
23492     }
23493     function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) {
23494         if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) {
23495             return false;
23496         }
23497         var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption.compileOnSave, basePath, errors);
23498         return typeof result === "boolean" && result;
23499     }
23500     function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) {
23501         var errors = [];
23502         var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName);
23503         return { options: options, errors: errors };
23504     }
23505     ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson;
23506     function convertTypeAcquisitionFromJson(jsonOptions, basePath, configFileName) {
23507         var errors = [];
23508         var options = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName);
23509         return { options: options, errors: errors };
23510     }
23511     ts.convertTypeAcquisitionFromJson = convertTypeAcquisitionFromJson;
23512     function getDefaultCompilerOptions(configFileName) {
23513         var options = configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json"
23514             ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true, noEmit: true }
23515             : {};
23516         return options;
23517     }
23518     function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) {
23519         var options = getDefaultCompilerOptions(configFileName);
23520         convertOptionsFromJson(getCommandLineCompilerOptionsMap(), jsonOptions, basePath, options, ts.compilerOptionsDidYouMeanDiagnostics, errors);
23521         if (configFileName) {
23522             options.configFilePath = ts.normalizeSlashes(configFileName);
23523         }
23524         return options;
23525     }
23526     function getDefaultTypeAcquisition(configFileName) {
23527         return { enable: !!configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] };
23528     }
23529     function convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName) {
23530         var options = getDefaultTypeAcquisition(configFileName);
23531         var typeAcquisition = convertEnableAutoDiscoveryToEnable(jsonOptions);
23532         convertOptionsFromJson(getCommandLineTypeAcquisitionMap(), typeAcquisition, basePath, options, typeAcquisitionDidYouMeanDiagnostics, errors);
23533         return options;
23534     }
23535     function convertWatchOptionsFromJsonWorker(jsonOptions, basePath, errors) {
23536         return convertOptionsFromJson(getCommandLineWatchOptionsMap(), jsonOptions, basePath, undefined, watchOptionsDidYouMeanDiagnostics, errors);
23537     }
23538     function convertOptionsFromJson(optionsNameMap, jsonOptions, basePath, defaultOptions, diagnostics, errors) {
23539         if (!jsonOptions) {
23540             return;
23541         }
23542         for (var id in jsonOptions) {
23543             var opt = optionsNameMap.get(id);
23544             if (opt) {
23545                 (defaultOptions || (defaultOptions = {}))[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors);
23546             }
23547             else {
23548                 errors.push(createUnknownOptionError(id, diagnostics, ts.createCompilerDiagnostic));
23549             }
23550         }
23551         return defaultOptions;
23552     }
23553     function convertJsonOption(opt, value, basePath, errors) {
23554         if (isCompilerOptionsValue(opt, value)) {
23555             var optType = opt.type;
23556             if (optType === "list" && ts.isArray(value)) {
23557                 return convertJsonOptionOfListType(opt, value, basePath, errors);
23558             }
23559             else if (!ts.isString(optType)) {
23560                 return convertJsonOptionOfCustomType(opt, value, errors);
23561             }
23562             return normalizeNonListOptionValue(opt, basePath, value);
23563         }
23564         else {
23565             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, getCompilerOptionValueTypeString(opt)));
23566         }
23567     }
23568     function normalizeOptionValue(option, basePath, value) {
23569         if (isNullOrUndefined(value))
23570             return undefined;
23571         if (option.type === "list") {
23572             var listOption_1 = option;
23573             if (listOption_1.element.isFilePath || !ts.isString(listOption_1.element.type)) {
23574                 return ts.filter(ts.map(value, function (v) { return normalizeOptionValue(listOption_1.element, basePath, v); }), function (v) { return !!v; });
23575             }
23576             return value;
23577         }
23578         else if (!ts.isString(option.type)) {
23579             return option.type.get(ts.isString(value) ? value.toLowerCase() : value);
23580         }
23581         return normalizeNonListOptionValue(option, basePath, value);
23582     }
23583     function normalizeNonListOptionValue(option, basePath, value) {
23584         if (option.isFilePath) {
23585             value = ts.getNormalizedAbsolutePath(value, basePath);
23586             if (value === "") {
23587                 value = ".";
23588             }
23589         }
23590         return value;
23591     }
23592     function convertJsonOptionOfCustomType(opt, value, errors) {
23593         if (isNullOrUndefined(value))
23594             return undefined;
23595         var key = value.toLowerCase();
23596         var val = opt.type.get(key);
23597         if (val !== undefined) {
23598             return val;
23599         }
23600         else {
23601             errors.push(createCompilerDiagnosticForInvalidCustomType(opt));
23602         }
23603     }
23604     function convertJsonOptionOfListType(option, values, basePath, errors) {
23605         return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; });
23606     }
23607     function trimString(s) {
23608         return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, "");
23609     }
23610     var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/;
23611     var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/;
23612     var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//;
23613     var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/;
23614     function matchFileNames(filesSpecs, includeSpecs, excludeSpecs, basePath, options, host, errors, extraFileExtensions, jsonSourceFile) {
23615         basePath = ts.normalizePath(basePath);
23616         var validatedIncludeSpecs, validatedExcludeSpecs;
23617         if (includeSpecs) {
23618             validatedIncludeSpecs = validateSpecs(includeSpecs, errors, false, jsonSourceFile, "include");
23619         }
23620         if (excludeSpecs) {
23621             validatedExcludeSpecs = validateSpecs(excludeSpecs, errors, true, jsonSourceFile, "exclude");
23622         }
23623         var wildcardDirectories = getWildcardDirectories(validatedIncludeSpecs, validatedExcludeSpecs, basePath, host.useCaseSensitiveFileNames);
23624         var spec = { filesSpecs: filesSpecs, includeSpecs: includeSpecs, excludeSpecs: excludeSpecs, validatedIncludeSpecs: validatedIncludeSpecs, validatedExcludeSpecs: validatedExcludeSpecs, wildcardDirectories: wildcardDirectories };
23625         return getFileNamesFromConfigSpecs(spec, basePath, options, host, extraFileExtensions);
23626     }
23627     function getFileNamesFromConfigSpecs(spec, basePath, options, host, extraFileExtensions) {
23628         if (extraFileExtensions === void 0) { extraFileExtensions = []; }
23629         basePath = ts.normalizePath(basePath);
23630         var keyMapper = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames);
23631         var literalFileMap = ts.createMap();
23632         var wildcardFileMap = ts.createMap();
23633         var wildCardJsonFileMap = ts.createMap();
23634         var filesSpecs = spec.filesSpecs, validatedIncludeSpecs = spec.validatedIncludeSpecs, validatedExcludeSpecs = spec.validatedExcludeSpecs, wildcardDirectories = spec.wildcardDirectories;
23635         var supportedExtensions = ts.getSupportedExtensions(options, extraFileExtensions);
23636         var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
23637         if (filesSpecs) {
23638             for (var _i = 0, filesSpecs_1 = filesSpecs; _i < filesSpecs_1.length; _i++) {
23639                 var fileName = filesSpecs_1[_i];
23640                 var file = ts.getNormalizedAbsolutePath(fileName, basePath);
23641                 literalFileMap.set(keyMapper(file), file);
23642             }
23643         }
23644         var jsonOnlyIncludeRegexes;
23645         if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) {
23646             var _loop_5 = function (file) {
23647                 if (ts.fileExtensionIs(file, ".json")) {
23648                     if (!jsonOnlyIncludeRegexes) {
23649                         var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json"); });
23650                         var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^" + pattern + "$"; });
23651                         jsonOnlyIncludeRegexes = includeFilePatterns ? includeFilePatterns.map(function (pattern) { return ts.getRegexFromPattern(pattern, host.useCaseSensitiveFileNames); }) : ts.emptyArray;
23652                     }
23653                     var includeIndex = ts.findIndex(jsonOnlyIncludeRegexes, function (re) { return re.test(file); });
23654                     if (includeIndex !== -1) {
23655                         var key_1 = keyMapper(file);
23656                         if (!literalFileMap.has(key_1) && !wildCardJsonFileMap.has(key_1)) {
23657                             wildCardJsonFileMap.set(key_1, file);
23658                         }
23659                     }
23660                     return "continue";
23661                 }
23662                 if (hasFileWithHigherPriorityExtension(file, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) {
23663                     return "continue";
23664                 }
23665                 removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper);
23666                 var key = keyMapper(file);
23667                 if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) {
23668                     wildcardFileMap.set(key, file);
23669                 }
23670             };
23671             for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensionsWithJsonIfResolveJsonModule, validatedExcludeSpecs, validatedIncludeSpecs, undefined); _a < _b.length; _a++) {
23672                 var file = _b[_a];
23673                 _loop_5(file);
23674             }
23675         }
23676         var literalFiles = ts.arrayFrom(literalFileMap.values());
23677         var wildcardFiles = ts.arrayFrom(wildcardFileMap.values());
23678         return {
23679             fileNames: literalFiles.concat(wildcardFiles, ts.arrayFrom(wildCardJsonFileMap.values())),
23680             wildcardDirectories: wildcardDirectories,
23681             spec: spec
23682         };
23683     }
23684     ts.getFileNamesFromConfigSpecs = getFileNamesFromConfigSpecs;
23685     function validateSpecs(specs, errors, allowTrailingRecursion, jsonSourceFile, specKey) {
23686         return specs.filter(function (spec) {
23687             var diag = specToDiagnostic(spec, allowTrailingRecursion);
23688             if (diag !== undefined) {
23689                 errors.push(createDiagnostic(diag, spec));
23690             }
23691             return diag === undefined;
23692         });
23693         function createDiagnostic(message, spec) {
23694             var element = ts.getTsConfigPropArrayElementValue(jsonSourceFile, specKey, spec);
23695             return element ?
23696                 ts.createDiagnosticForNodeInSourceFile(jsonSourceFile, element, message, spec) :
23697                 ts.createCompilerDiagnostic(message, spec);
23698         }
23699     }
23700     function specToDiagnostic(spec, allowTrailingRecursion) {
23701         if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) {
23702             return ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0;
23703         }
23704         else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) {
23705             return ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0;
23706         }
23707     }
23708     function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) {
23709         var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude");
23710         var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i");
23711         var wildcardDirectories = {};
23712         if (include !== undefined) {
23713             var recursiveKeys = [];
23714             for (var _i = 0, include_1 = include; _i < include_1.length; _i++) {
23715                 var file = include_1[_i];
23716                 var spec = ts.normalizePath(ts.combinePaths(path, file));
23717                 if (excludeRegex && excludeRegex.test(spec)) {
23718                     continue;
23719                 }
23720                 var match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames);
23721                 if (match) {
23722                     var key = match.key, flags = match.flags;
23723                     var existingFlags = wildcardDirectories[key];
23724                     if (existingFlags === undefined || existingFlags < flags) {
23725                         wildcardDirectories[key] = flags;
23726                         if (flags === 1) {
23727                             recursiveKeys.push(key);
23728                         }
23729                     }
23730                 }
23731             }
23732             for (var key in wildcardDirectories) {
23733                 if (ts.hasProperty(wildcardDirectories, key)) {
23734                     for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) {
23735                         var recursiveKey = recursiveKeys_1[_a];
23736                         if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) {
23737                             delete wildcardDirectories[key];
23738                         }
23739                     }
23740                 }
23741             }
23742         }
23743         return wildcardDirectories;
23744     }
23745     function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames) {
23746         var match = wildcardDirectoryPattern.exec(spec);
23747         if (match) {
23748             return {
23749                 key: useCaseSensitiveFileNames ? match[0] : ts.toFileNameLowerCase(match[0]),
23750                 flags: watchRecursivePattern.test(spec) ? 1 : 0
23751             };
23752         }
23753         if (ts.isImplicitGlob(spec)) {
23754             return { key: spec, flags: 1 };
23755         }
23756         return undefined;
23757     }
23758     function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) {
23759         var extensionPriority = ts.getExtensionPriority(file, extensions);
23760         var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority, extensions);
23761         for (var i = 0; i < adjustedExtensionPriority; i++) {
23762             var higherPriorityExtension = extensions[i];
23763             var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension));
23764             if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) {
23765                 return true;
23766             }
23767         }
23768         return false;
23769     }
23770     function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) {
23771         var extensionPriority = ts.getExtensionPriority(file, extensions);
23772         var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority, extensions);
23773         for (var i = nextExtensionPriority; i < extensions.length; i++) {
23774             var lowerPriorityExtension = extensions[i];
23775             var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension));
23776             wildcardFiles.delete(lowerPriorityPath);
23777         }
23778     }
23779     function convertCompilerOptionsForTelemetry(opts) {
23780         var out = {};
23781         for (var key in opts) {
23782             if (opts.hasOwnProperty(key)) {
23783                 var type = getOptionFromName(key);
23784                 if (type !== undefined) {
23785                     out[key] = getOptionValueWithEmptyStrings(opts[key], type);
23786                 }
23787             }
23788         }
23789         return out;
23790     }
23791     ts.convertCompilerOptionsForTelemetry = convertCompilerOptionsForTelemetry;
23792     function getOptionValueWithEmptyStrings(value, option) {
23793         switch (option.type) {
23794             case "object":
23795                 return "";
23796             case "string":
23797                 return "";
23798             case "number":
23799                 return typeof value === "number" ? value : "";
23800             case "boolean":
23801                 return typeof value === "boolean" ? value : "";
23802             case "list":
23803                 var elementType_1 = option.element;
23804                 return ts.isArray(value) ? value.map(function (v) { return getOptionValueWithEmptyStrings(v, elementType_1); }) : "";
23805             default:
23806                 return ts.forEachEntry(option.type, function (optionEnumValue, optionStringValue) {
23807                     if (optionEnumValue === value) {
23808                         return optionStringValue;
23809                     }
23810                 });
23811         }
23812     }
23813 })(ts || (ts = {}));
23814 var ts;
23815 (function (ts) {
23816     function trace(host) {
23817         host.trace(ts.formatMessage.apply(undefined, arguments));
23818     }
23819     ts.trace = trace;
23820     function isTraceEnabled(compilerOptions, host) {
23821         return !!compilerOptions.traceResolution && host.trace !== undefined;
23822     }
23823     ts.isTraceEnabled = isTraceEnabled;
23824     function withPackageId(packageInfo, r) {
23825         var packageId;
23826         if (r && packageInfo) {
23827             var packageJsonContent = packageInfo.packageJsonContent;
23828             if (typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string") {
23829                 packageId = {
23830                     name: packageJsonContent.name,
23831                     subModuleName: r.path.slice(packageInfo.packageDirectory.length + ts.directorySeparator.length),
23832                     version: packageJsonContent.version
23833                 };
23834             }
23835         }
23836         return r && { path: r.path, extension: r.ext, packageId: packageId };
23837     }
23838     function noPackageId(r) {
23839         return withPackageId(undefined, r);
23840     }
23841     function removeIgnoredPackageId(r) {
23842         if (r) {
23843             ts.Debug.assert(r.packageId === undefined);
23844             return { path: r.path, ext: r.extension };
23845         }
23846     }
23847     var Extensions;
23848     (function (Extensions) {
23849         Extensions[Extensions["TypeScript"] = 0] = "TypeScript";
23850         Extensions[Extensions["JavaScript"] = 1] = "JavaScript";
23851         Extensions[Extensions["Json"] = 2] = "Json";
23852         Extensions[Extensions["TSConfig"] = 3] = "TSConfig";
23853         Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
23854     })(Extensions || (Extensions = {}));
23855     function resolvedTypeScriptOnly(resolved) {
23856         if (!resolved) {
23857             return undefined;
23858         }
23859         ts.Debug.assert(ts.extensionIsTS(resolved.extension));
23860         return { fileName: resolved.path, packageId: resolved.packageId };
23861     }
23862     function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, resultFromCache) {
23863         var _a;
23864         if (resultFromCache) {
23865             (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
23866             return resultFromCache;
23867         }
23868         return {
23869             resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
23870             failedLookupLocations: failedLookupLocations
23871         };
23872     }
23873     function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
23874         if (!ts.hasProperty(jsonContent, fieldName)) {
23875             if (state.traceEnabled) {
23876                 trace(state.host, ts.Diagnostics.package_json_does_not_have_a_0_field, fieldName);
23877             }
23878             return;
23879         }
23880         var value = jsonContent[fieldName];
23881         if (typeof value !== typeOfTag || value === null) {
23882             if (state.traceEnabled) {
23883                 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);
23884             }
23885             return;
23886         }
23887         return value;
23888     }
23889     function readPackageJsonPathField(jsonContent, fieldName, baseDirectory, state) {
23890         var fileName = readPackageJsonField(jsonContent, fieldName, "string", state);
23891         if (fileName === undefined) {
23892             return;
23893         }
23894         if (!fileName) {
23895             if (state.traceEnabled) {
23896                 trace(state.host, ts.Diagnostics.package_json_had_a_falsy_0_field, fieldName);
23897             }
23898             return;
23899         }
23900         var path = ts.normalizePath(ts.combinePaths(baseDirectory, fileName));
23901         if (state.traceEnabled) {
23902             trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path);
23903         }
23904         return path;
23905     }
23906     function readPackageJsonTypesFields(jsonContent, baseDirectory, state) {
23907         return readPackageJsonPathField(jsonContent, "typings", baseDirectory, state)
23908             || readPackageJsonPathField(jsonContent, "types", baseDirectory, state);
23909     }
23910     function readPackageJsonTSConfigField(jsonContent, baseDirectory, state) {
23911         return readPackageJsonPathField(jsonContent, "tsconfig", baseDirectory, state);
23912     }
23913     function readPackageJsonMainField(jsonContent, baseDirectory, state) {
23914         return readPackageJsonPathField(jsonContent, "main", baseDirectory, state);
23915     }
23916     function readPackageJsonTypesVersionsField(jsonContent, state) {
23917         var typesVersions = readPackageJsonField(jsonContent, "typesVersions", "object", state);
23918         if (typesVersions === undefined)
23919             return;
23920         if (state.traceEnabled) {
23921             trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_field_with_version_specific_path_mappings);
23922         }
23923         return typesVersions;
23924     }
23925     function readPackageJsonTypesVersionPaths(jsonContent, state) {
23926         var typesVersions = readPackageJsonTypesVersionsField(jsonContent, state);
23927         if (typesVersions === undefined)
23928             return;
23929         if (state.traceEnabled) {
23930             for (var key in typesVersions) {
23931                 if (ts.hasProperty(typesVersions, key) && !ts.VersionRange.tryParse(key)) {
23932                     trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_is_not_a_valid_semver_range, key);
23933                 }
23934             }
23935         }
23936         var result = getPackageJsonTypesVersionsPaths(typesVersions);
23937         if (!result) {
23938             if (state.traceEnabled) {
23939                 trace(state.host, ts.Diagnostics.package_json_does_not_have_a_typesVersions_entry_that_matches_version_0, ts.versionMajorMinor);
23940             }
23941             return;
23942         }
23943         var bestVersionKey = result.version, bestVersionPaths = result.paths;
23944         if (typeof bestVersionPaths !== "object") {
23945             if (state.traceEnabled) {
23946                 trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['" + bestVersionKey + "']", "object", typeof bestVersionPaths);
23947             }
23948             return;
23949         }
23950         return result;
23951     }
23952     var typeScriptVersion;
23953     function getPackageJsonTypesVersionsPaths(typesVersions) {
23954         if (!typeScriptVersion)
23955             typeScriptVersion = new ts.Version(ts.version);
23956         for (var key in typesVersions) {
23957             if (!ts.hasProperty(typesVersions, key))
23958                 continue;
23959             var keyRange = ts.VersionRange.tryParse(key);
23960             if (keyRange === undefined) {
23961                 continue;
23962             }
23963             if (keyRange.test(typeScriptVersion)) {
23964                 return { version: key, paths: typesVersions[key] };
23965             }
23966         }
23967     }
23968     ts.getPackageJsonTypesVersionsPaths = getPackageJsonTypesVersionsPaths;
23969     function getEffectiveTypeRoots(options, host) {
23970         if (options.typeRoots) {
23971             return options.typeRoots;
23972         }
23973         var currentDirectory;
23974         if (options.configFilePath) {
23975             currentDirectory = ts.getDirectoryPath(options.configFilePath);
23976         }
23977         else if (host.getCurrentDirectory) {
23978             currentDirectory = host.getCurrentDirectory();
23979         }
23980         if (currentDirectory !== undefined) {
23981             return getDefaultTypeRoots(currentDirectory, host);
23982         }
23983     }
23984     ts.getEffectiveTypeRoots = getEffectiveTypeRoots;
23985     function getDefaultTypeRoots(currentDirectory, host) {
23986         if (!host.directoryExists) {
23987             return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)];
23988         }
23989         var typeRoots;
23990         ts.forEachAncestorDirectory(ts.normalizePath(currentDirectory), function (directory) {
23991             var atTypes = ts.combinePaths(directory, nodeModulesAtTypes);
23992             if (host.directoryExists(atTypes)) {
23993                 (typeRoots || (typeRoots = [])).push(atTypes);
23994             }
23995             return undefined;
23996         });
23997         return typeRoots;
23998     }
23999     var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types");
24000     function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) {
24001         var traceEnabled = isTraceEnabled(options, host);
24002         if (redirectedReference) {
24003             options = redirectedReference.commandLine.options;
24004         }
24005         var failedLookupLocations = [];
24006         var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations };
24007         var typeRoots = getEffectiveTypeRoots(options, host);
24008         if (traceEnabled) {
24009             if (containingFile === undefined) {
24010                 if (typeRoots === undefined) {
24011                     trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName);
24012                 }
24013                 else {
24014                     trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots);
24015                 }
24016             }
24017             else {
24018                 if (typeRoots === undefined) {
24019                     trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile);
24020                 }
24021                 else {
24022                     trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots);
24023                 }
24024             }
24025             if (redirectedReference) {
24026                 trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName);
24027             }
24028         }
24029         var resolved = primaryLookup();
24030         var primary = true;
24031         if (!resolved) {
24032             resolved = secondaryLookup();
24033             primary = false;
24034         }
24035         var resolvedTypeReferenceDirective;
24036         if (resolved) {
24037             var fileName = resolved.fileName, packageId = resolved.packageId;
24038             var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled);
24039             if (traceEnabled) {
24040                 if (packageId) {
24041                     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);
24042                 }
24043                 else {
24044                     trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary);
24045                 }
24046             }
24047             resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) };
24048         }
24049         return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
24050         function primaryLookup() {
24051             if (typeRoots && typeRoots.length) {
24052                 if (traceEnabled) {
24053                     trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", "));
24054                 }
24055                 return ts.firstDefined(typeRoots, function (typeRoot) {
24056                     var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName);
24057                     var candidateDirectory = ts.getDirectoryPath(candidate);
24058                     var directoryExists = ts.directoryProbablyExists(candidateDirectory, host);
24059                     if (!directoryExists && traceEnabled) {
24060                         trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory);
24061                     }
24062                     return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, !directoryExists, moduleResolutionState));
24063                 });
24064             }
24065             else {
24066                 if (traceEnabled) {
24067                     trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths);
24068                 }
24069             }
24070         }
24071         function secondaryLookup() {
24072             var initialLocationForSecondaryLookup = containingFile && ts.getDirectoryPath(containingFile);
24073             if (initialLocationForSecondaryLookup !== undefined) {
24074                 if (traceEnabled) {
24075                     trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup);
24076                 }
24077                 var result = void 0;
24078                 if (!ts.isExternalModuleNameRelative(typeReferenceDirectiveName)) {
24079                     var searchResult = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, undefined, undefined);
24080                     result = searchResult && searchResult.value;
24081                 }
24082                 else {
24083                     var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path;
24084                     result = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, false, moduleResolutionState, true);
24085                 }
24086                 var resolvedFile = resolvedTypeScriptOnly(result);
24087                 if (!resolvedFile && traceEnabled) {
24088                     trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName);
24089                 }
24090                 return resolvedFile;
24091             }
24092             else {
24093                 if (traceEnabled) {
24094                     trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder);
24095                 }
24096             }
24097         }
24098     }
24099     ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective;
24100     function getAutomaticTypeDirectiveNames(options, host) {
24101         if (options.types) {
24102             return options.types;
24103         }
24104         var result = [];
24105         if (host.directoryExists && host.getDirectories) {
24106             var typeRoots = getEffectiveTypeRoots(options, host);
24107             if (typeRoots) {
24108                 for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) {
24109                     var root = typeRoots_1[_i];
24110                     if (host.directoryExists(root)) {
24111                         for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) {
24112                             var typeDirectivePath = _b[_a];
24113                             var normalized = ts.normalizePath(typeDirectivePath);
24114                             var packageJsonPath = ts.combinePaths(root, normalized, "package.json");
24115                             var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null;
24116                             if (!isNotNeededPackage) {
24117                                 var baseFileName = ts.getBaseFileName(normalized);
24118                                 if (baseFileName.charCodeAt(0) !== 46) {
24119                                     result.push(baseFileName);
24120                                 }
24121                             }
24122                         }
24123                     }
24124                 }
24125             }
24126         }
24127         return result;
24128     }
24129     ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames;
24130     function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) {
24131         return createModuleResolutionCacheWithMaps(createCacheWithRedirects(options), createCacheWithRedirects(options), currentDirectory, getCanonicalFileName);
24132     }
24133     ts.createModuleResolutionCache = createModuleResolutionCache;
24134     function createCacheWithRedirects(options) {
24135         var ownMap = ts.createMap();
24136         var redirectsMap = ts.createMap();
24137         return {
24138             ownMap: ownMap,
24139             redirectsMap: redirectsMap,
24140             getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects,
24141             clear: clear,
24142             setOwnOptions: setOwnOptions,
24143             setOwnMap: setOwnMap
24144         };
24145         function setOwnOptions(newOptions) {
24146             options = newOptions;
24147         }
24148         function setOwnMap(newOwnMap) {
24149             ownMap = newOwnMap;
24150         }
24151         function getOrCreateMapOfCacheRedirects(redirectedReference) {
24152             if (!redirectedReference) {
24153                 return ownMap;
24154             }
24155             var path = redirectedReference.sourceFile.path;
24156             var redirects = redirectsMap.get(path);
24157             if (!redirects) {
24158                 redirects = !options || ts.optionsHaveModuleResolutionChanges(options, redirectedReference.commandLine.options) ? ts.createMap() : ownMap;
24159                 redirectsMap.set(path, redirects);
24160             }
24161             return redirects;
24162         }
24163         function clear() {
24164             ownMap.clear();
24165             redirectsMap.clear();
24166         }
24167     }
24168     ts.createCacheWithRedirects = createCacheWithRedirects;
24169     function createModuleResolutionCacheWithMaps(directoryToModuleNameMap, moduleNameToDirectoryMap, currentDirectory, getCanonicalFileName) {
24170         return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, directoryToModuleNameMap: directoryToModuleNameMap, moduleNameToDirectoryMap: moduleNameToDirectoryMap };
24171         function getOrCreateCacheForDirectory(directoryName, redirectedReference) {
24172             var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
24173             return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, ts.createMap);
24174         }
24175         function getOrCreateCacheForModuleName(nonRelativeModuleName, redirectedReference) {
24176             ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
24177             return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, nonRelativeModuleName, createPerModuleNameCache);
24178         }
24179         function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) {
24180             var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
24181             var result = cache.get(key);
24182             if (!result) {
24183                 result = create();
24184                 cache.set(key, result);
24185             }
24186             return result;
24187         }
24188         function createPerModuleNameCache() {
24189             var directoryPathMap = ts.createMap();
24190             return { get: get, set: set };
24191             function get(directory) {
24192                 return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName));
24193             }
24194             function set(directory, result) {
24195                 var path = ts.toPath(directory, currentDirectory, getCanonicalFileName);
24196                 if (directoryPathMap.has(path)) {
24197                     return;
24198                 }
24199                 directoryPathMap.set(path, result);
24200                 var resolvedFileName = result.resolvedModule &&
24201                     (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
24202                 var commonPrefix = resolvedFileName && getCommonPrefix(path, resolvedFileName);
24203                 var current = path;
24204                 while (current !== commonPrefix) {
24205                     var parent = ts.getDirectoryPath(current);
24206                     if (parent === current || directoryPathMap.has(parent)) {
24207                         break;
24208                     }
24209                     directoryPathMap.set(parent, result);
24210                     current = parent;
24211                 }
24212             }
24213             function getCommonPrefix(directory, resolution) {
24214                 var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName);
24215                 var i = 0;
24216                 var limit = Math.min(directory.length, resolutionDirectory.length);
24217                 while (i < limit && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) {
24218                     i++;
24219                 }
24220                 if (i === directory.length && (resolutionDirectory.length === i || resolutionDirectory[i] === ts.directorySeparator)) {
24221                     return directory;
24222                 }
24223                 var rootLength = ts.getRootLength(directory);
24224                 if (i < rootLength) {
24225                     return undefined;
24226                 }
24227                 var sep = directory.lastIndexOf(ts.directorySeparator, i - 1);
24228                 if (sep === -1) {
24229                     return undefined;
24230                 }
24231                 return directory.substr(0, Math.max(sep, rootLength));
24232             }
24233         }
24234     }
24235     ts.createModuleResolutionCacheWithMaps = createModuleResolutionCacheWithMaps;
24236     function resolveModuleNameFromCache(moduleName, containingFile, cache) {
24237         var containingDirectory = ts.getDirectoryPath(containingFile);
24238         var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory);
24239         return perFolderCache && perFolderCache.get(moduleName);
24240     }
24241     ts.resolveModuleNameFromCache = resolveModuleNameFromCache;
24242     function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
24243         var traceEnabled = isTraceEnabled(compilerOptions, host);
24244         if (redirectedReference) {
24245             compilerOptions = redirectedReference.commandLine.options;
24246         }
24247         if (traceEnabled) {
24248             trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile);
24249             if (redirectedReference) {
24250                 trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName);
24251             }
24252         }
24253         var containingDirectory = ts.getDirectoryPath(containingFile);
24254         var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference);
24255         var result = perFolderCache && perFolderCache.get(moduleName);
24256         if (result) {
24257             if (traceEnabled) {
24258                 trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
24259             }
24260         }
24261         else {
24262             var moduleResolution = compilerOptions.moduleResolution;
24263             if (moduleResolution === undefined) {
24264                 moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic;
24265                 if (traceEnabled) {
24266                     trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]);
24267                 }
24268             }
24269             else {
24270                 if (traceEnabled) {
24271                     trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]);
24272                 }
24273             }
24274             ts.perfLogger.logStartResolveModule(moduleName);
24275             switch (moduleResolution) {
24276                 case ts.ModuleResolutionKind.NodeJs:
24277                     result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference);
24278                     break;
24279                 case ts.ModuleResolutionKind.Classic:
24280                     result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference);
24281                     break;
24282                 default:
24283                     return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution);
24284             }
24285             if (result && result.resolvedModule)
24286                 ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\"");
24287             ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null");
24288             if (perFolderCache) {
24289                 perFolderCache.set(moduleName, result);
24290                 if (!ts.isExternalModuleNameRelative(moduleName)) {
24291                     cache.getOrCreateCacheForModuleName(moduleName, redirectedReference).set(containingDirectory, result);
24292                 }
24293             }
24294         }
24295         if (traceEnabled) {
24296             if (result.resolvedModule) {
24297                 if (result.resolvedModule.packageId) {
24298                     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));
24299                 }
24300                 else {
24301                     trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName);
24302                 }
24303             }
24304             else {
24305                 trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName);
24306             }
24307         }
24308         return result;
24309     }
24310     ts.resolveModuleName = resolveModuleName;
24311     function tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state) {
24312         var resolved = tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state);
24313         if (resolved)
24314             return resolved.value;
24315         if (!ts.isExternalModuleNameRelative(moduleName)) {
24316             return tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, state);
24317         }
24318         else {
24319             return tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state);
24320         }
24321     }
24322     function tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state) {
24323         var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths;
24324         if (baseUrl && paths && !ts.pathIsRelative(moduleName)) {
24325             if (state.traceEnabled) {
24326                 trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName);
24327                 trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName);
24328             }
24329             return tryLoadModuleUsingPaths(extensions, moduleName, baseUrl, paths, loader, false, state);
24330         }
24331     }
24332     function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state) {
24333         if (!state.compilerOptions.rootDirs) {
24334             return undefined;
24335         }
24336         if (state.traceEnabled) {
24337             trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName);
24338         }
24339         var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName));
24340         var matchedRootDir;
24341         var matchedNormalizedPrefix;
24342         for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) {
24343             var rootDir = _a[_i];
24344             var normalizedRoot = ts.normalizePath(rootDir);
24345             if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) {
24346                 normalizedRoot += ts.directorySeparator;
24347             }
24348             var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) &&
24349                 (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length);
24350             if (state.traceEnabled) {
24351                 trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix);
24352             }
24353             if (isLongestMatchingPrefix) {
24354                 matchedNormalizedPrefix = normalizedRoot;
24355                 matchedRootDir = rootDir;
24356             }
24357         }
24358         if (matchedNormalizedPrefix) {
24359             if (state.traceEnabled) {
24360                 trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix);
24361             }
24362             var suffix = candidate.substr(matchedNormalizedPrefix.length);
24363             if (state.traceEnabled) {
24364                 trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate);
24365             }
24366             var resolvedFileName = loader(extensions, candidate, !ts.directoryProbablyExists(containingDirectory, state.host), state);
24367             if (resolvedFileName) {
24368                 return resolvedFileName;
24369             }
24370             if (state.traceEnabled) {
24371                 trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs);
24372             }
24373             for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) {
24374                 var rootDir = _c[_b];
24375                 if (rootDir === matchedRootDir) {
24376                     continue;
24377                 }
24378                 var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix);
24379                 if (state.traceEnabled) {
24380                     trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1);
24381                 }
24382                 var baseDirectory = ts.getDirectoryPath(candidate_1);
24383                 var resolvedFileName_1 = loader(extensions, candidate_1, !ts.directoryProbablyExists(baseDirectory, state.host), state);
24384                 if (resolvedFileName_1) {
24385                     return resolvedFileName_1;
24386                 }
24387             }
24388             if (state.traceEnabled) {
24389                 trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed);
24390             }
24391         }
24392         return undefined;
24393     }
24394     function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, state) {
24395         var baseUrl = state.compilerOptions.baseUrl;
24396         if (!baseUrl) {
24397             return undefined;
24398         }
24399         if (state.traceEnabled) {
24400             trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName);
24401         }
24402         var candidate = ts.normalizePath(ts.combinePaths(baseUrl, moduleName));
24403         if (state.traceEnabled) {
24404             trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, baseUrl, candidate);
24405         }
24406         return loader(extensions, candidate, !ts.directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state);
24407     }
24408     function resolveJSModule(moduleName, initialDir, host) {
24409         var _a = tryResolveJSModuleWorker(moduleName, initialDir, host), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations;
24410         if (!resolvedModule) {
24411             throw new Error("Could not resolve JS module '" + moduleName + "' starting at '" + initialDir + "'. Looked in: " + failedLookupLocations.join(", "));
24412         }
24413         return resolvedModule.resolvedFileName;
24414     }
24415     ts.resolveJSModule = resolveJSModule;
24416     function tryResolveJSModule(moduleName, initialDir, host) {
24417         var resolvedModule = tryResolveJSModuleWorker(moduleName, initialDir, host).resolvedModule;
24418         return resolvedModule && resolvedModule.resolvedFileName;
24419     }
24420     ts.tryResolveJSModule = tryResolveJSModule;
24421     var jsOnlyExtensions = [Extensions.JavaScript];
24422     var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
24423     var tsPlusJsonExtensions = __spreadArrays(tsExtensions, [Extensions.Json]);
24424     var tsconfigExtensions = [Extensions.TSConfig];
24425     function tryResolveJSModuleWorker(moduleName, initialDir, host) {
24426         return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, undefined, jsOnlyExtensions, undefined);
24427     }
24428     function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
24429         return nodeModuleNameResolverWorker(moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
24430     }
24431     ts.nodeModuleNameResolver = nodeModuleNameResolver;
24432     function nodeModuleNameResolverWorker(moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
24433         var _a, _b;
24434         var traceEnabled = isTraceEnabled(compilerOptions, host);
24435         var failedLookupLocations = [];
24436         var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations };
24437         var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
24438         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);
24439         function tryResolve(extensions) {
24440             var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, true); };
24441             var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
24442             if (resolved) {
24443                 return toSearchResult({ resolved: resolved, isExternalLibraryImport: pathContainsNodeModules(resolved.path) });
24444             }
24445             if (!ts.isExternalModuleNameRelative(moduleName)) {
24446                 if (traceEnabled) {
24447                     trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]);
24448                 }
24449                 var resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
24450                 if (!resolved_1)
24451                     return undefined;
24452                 var resolvedValue = resolved_1.value;
24453                 if (!compilerOptions.preserveSymlinks && resolvedValue && !resolvedValue.originalPath) {
24454                     var path = realPath(resolvedValue.path, host, traceEnabled);
24455                     var originalPath = path === resolvedValue.path ? undefined : resolvedValue.path;
24456                     resolvedValue = __assign(__assign({}, resolvedValue), { path: path, originalPath: originalPath });
24457                 }
24458                 return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } };
24459             }
24460             else {
24461                 var _a = ts.normalizePathAndParts(ts.combinePaths(containingDirectory, moduleName)), candidate = _a.path, parts = _a.parts;
24462                 var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, false, state, true);
24463                 return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: ts.contains(parts, "node_modules") });
24464             }
24465         }
24466     }
24467     function realPath(path, host, traceEnabled) {
24468         if (!host.realpath) {
24469             return path;
24470         }
24471         var real = ts.normalizePath(host.realpath(path));
24472         if (traceEnabled) {
24473             trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real);
24474         }
24475         ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real);
24476         return real;
24477     }
24478     function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) {
24479         if (state.traceEnabled) {
24480             trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]);
24481         }
24482         if (!ts.hasTrailingDirectorySeparator(candidate)) {
24483             if (!onlyRecordFailures) {
24484                 var parentOfCandidate = ts.getDirectoryPath(candidate);
24485                 if (!ts.directoryProbablyExists(parentOfCandidate, state.host)) {
24486                     if (state.traceEnabled) {
24487                         trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate);
24488                     }
24489                     onlyRecordFailures = true;
24490                 }
24491             }
24492             var resolvedFromFile = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state);
24493             if (resolvedFromFile) {
24494                 var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined;
24495                 var packageInfo = packageDirectory ? getPackageJsonInfo(packageDirectory, false, state) : undefined;
24496                 return withPackageId(packageInfo, resolvedFromFile);
24497             }
24498         }
24499         if (!onlyRecordFailures) {
24500             var candidateExists = ts.directoryProbablyExists(candidate, state.host);
24501             if (!candidateExists) {
24502                 if (state.traceEnabled) {
24503                     trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate);
24504                 }
24505                 onlyRecordFailures = true;
24506             }
24507         }
24508         return loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson);
24509     }
24510     ts.nodeModulesPathPart = "/node_modules/";
24511     function pathContainsNodeModules(path) {
24512         return ts.stringContains(path, ts.nodeModulesPathPart);
24513     }
24514     ts.pathContainsNodeModules = pathContainsNodeModules;
24515     function parseNodeModuleFromPath(resolved) {
24516         var path = ts.normalizePath(resolved.path);
24517         var idx = path.lastIndexOf(ts.nodeModulesPathPart);
24518         if (idx === -1) {
24519             return undefined;
24520         }
24521         var indexAfterNodeModules = idx + ts.nodeModulesPathPart.length;
24522         var indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules);
24523         if (path.charCodeAt(indexAfterNodeModules) === 64) {
24524             indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName);
24525         }
24526         return path.slice(0, indexAfterPackageName);
24527     }
24528     function moveToNextDirectorySeparatorIfAvailable(path, prevSeparatorIndex) {
24529         var nextSeparatorIndex = path.indexOf(ts.directorySeparator, prevSeparatorIndex + 1);
24530         return nextSeparatorIndex === -1 ? prevSeparatorIndex : nextSeparatorIndex;
24531     }
24532     function loadModuleFromFileNoPackageId(extensions, candidate, onlyRecordFailures, state) {
24533         return noPackageId(loadModuleFromFile(extensions, candidate, onlyRecordFailures, state));
24534     }
24535     function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) {
24536         if (extensions === Extensions.Json || extensions === Extensions.TSConfig) {
24537             var extensionLess = ts.tryRemoveExtension(candidate, ".json");
24538             return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, onlyRecordFailures, state);
24539         }
24540         var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, onlyRecordFailures, state);
24541         if (resolvedByAddingExtension) {
24542             return resolvedByAddingExtension;
24543         }
24544         if (ts.hasJSFileExtension(candidate)) {
24545             var extensionless = ts.removeFileExtension(candidate);
24546             if (state.traceEnabled) {
24547                 var extension = candidate.substring(extensionless.length);
24548                 trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension);
24549             }
24550             return tryAddingExtensions(extensionless, extensions, onlyRecordFailures, state);
24551         }
24552     }
24553     function tryAddingExtensions(candidate, extensions, onlyRecordFailures, state) {
24554         if (!onlyRecordFailures) {
24555             var directory = ts.getDirectoryPath(candidate);
24556             if (directory) {
24557                 onlyRecordFailures = !ts.directoryProbablyExists(directory, state.host);
24558             }
24559         }
24560         switch (extensions) {
24561             case Extensions.DtsOnly:
24562                 return tryExtension(".d.ts");
24563             case Extensions.TypeScript:
24564                 return tryExtension(".ts") || tryExtension(".tsx") || tryExtension(".d.ts");
24565             case Extensions.JavaScript:
24566                 return tryExtension(".js") || tryExtension(".jsx");
24567             case Extensions.TSConfig:
24568             case Extensions.Json:
24569                 return tryExtension(".json");
24570         }
24571         function tryExtension(ext) {
24572             var path = tryFile(candidate + ext, onlyRecordFailures, state);
24573             return path === undefined ? undefined : { path: path, ext: ext };
24574         }
24575     }
24576     function tryFile(fileName, onlyRecordFailures, state) {
24577         if (!onlyRecordFailures) {
24578             if (state.host.fileExists(fileName)) {
24579                 if (state.traceEnabled) {
24580                     trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName);
24581                 }
24582                 return fileName;
24583             }
24584             else {
24585                 if (state.traceEnabled) {
24586                     trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName);
24587                 }
24588             }
24589         }
24590         state.failedLookupLocations.push(fileName);
24591         return undefined;
24592     }
24593     function loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson) {
24594         if (considerPackageJson === void 0) { considerPackageJson = true; }
24595         var packageInfo = considerPackageJson ? getPackageJsonInfo(candidate, onlyRecordFailures, state) : undefined;
24596         var packageJsonContent = packageInfo && packageInfo.packageJsonContent;
24597         var versionPaths = packageInfo && packageInfo.versionPaths;
24598         return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
24599     }
24600     function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
24601         var host = state.host, traceEnabled = state.traceEnabled;
24602         var directoryExists = !onlyRecordFailures && ts.directoryProbablyExists(packageDirectory, host);
24603         var packageJsonPath = ts.combinePaths(packageDirectory, "package.json");
24604         if (directoryExists && host.fileExists(packageJsonPath)) {
24605             var packageJsonContent = ts.readJson(packageJsonPath, host);
24606             if (traceEnabled) {
24607                 trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
24608             }
24609             var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
24610             return { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths };
24611         }
24612         else {
24613             if (directoryExists && traceEnabled) {
24614                 trace(host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath);
24615             }
24616             state.failedLookupLocations.push(packageJsonPath);
24617         }
24618     }
24619     function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) {
24620         var packageFile;
24621         if (jsonContent) {
24622             switch (extensions) {
24623                 case Extensions.JavaScript:
24624                 case Extensions.Json:
24625                     packageFile = readPackageJsonMainField(jsonContent, candidate, state);
24626                     break;
24627                 case Extensions.TypeScript:
24628                     packageFile = readPackageJsonTypesFields(jsonContent, candidate, state) || readPackageJsonMainField(jsonContent, candidate, state);
24629                     break;
24630                 case Extensions.DtsOnly:
24631                     packageFile = readPackageJsonTypesFields(jsonContent, candidate, state);
24632                     break;
24633                 case Extensions.TSConfig:
24634                     packageFile = readPackageJsonTSConfigField(jsonContent, candidate, state);
24635                     break;
24636                 default:
24637                     return ts.Debug.assertNever(extensions);
24638             }
24639         }
24640         var loader = function (extensions, candidate, onlyRecordFailures, state) {
24641             var fromFile = tryFile(candidate, onlyRecordFailures, state);
24642             if (fromFile) {
24643                 var resolved = resolvedIfExtensionMatches(extensions, fromFile);
24644                 if (resolved) {
24645                     return noPackageId(resolved);
24646                 }
24647                 if (state.traceEnabled) {
24648                     trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromFile);
24649                 }
24650             }
24651             var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions;
24652             return nodeLoadModuleByRelativeName(nextExtensions, candidate, onlyRecordFailures, state, false);
24653         };
24654         var onlyRecordFailuresForPackageFile = packageFile ? !ts.directoryProbablyExists(ts.getDirectoryPath(packageFile), state.host) : undefined;
24655         var onlyRecordFailuresForIndex = onlyRecordFailures || !ts.directoryProbablyExists(candidate, state.host);
24656         var indexPath = ts.combinePaths(candidate, extensions === Extensions.TSConfig ? "tsconfig" : "index");
24657         if (versionPaths && (!packageFile || ts.containsPath(candidate, packageFile))) {
24658             var moduleName = ts.getRelativePathFromDirectory(candidate, packageFile || indexPath, false);
24659             if (state.traceEnabled) {
24660                 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);
24661             }
24662             var result = tryLoadModuleUsingPaths(extensions, moduleName, candidate, versionPaths.paths, loader, onlyRecordFailuresForPackageFile || onlyRecordFailuresForIndex, state);
24663             if (result) {
24664                 return removeIgnoredPackageId(result.value);
24665             }
24666         }
24667         var packageFileResult = packageFile && removeIgnoredPackageId(loader(extensions, packageFile, onlyRecordFailuresForPackageFile, state));
24668         if (packageFileResult)
24669             return packageFileResult;
24670         return loadModuleFromFile(extensions, indexPath, onlyRecordFailuresForIndex, state);
24671     }
24672     function resolvedIfExtensionMatches(extensions, path) {
24673         var ext = ts.tryGetExtensionFromPath(path);
24674         return ext !== undefined && extensionIsOk(extensions, ext) ? { path: path, ext: ext } : undefined;
24675     }
24676     function extensionIsOk(extensions, extension) {
24677         switch (extensions) {
24678             case Extensions.JavaScript:
24679                 return extension === ".js" || extension === ".jsx";
24680             case Extensions.TSConfig:
24681             case Extensions.Json:
24682                 return extension === ".json";
24683             case Extensions.TypeScript:
24684                 return extension === ".ts" || extension === ".tsx" || extension === ".d.ts";
24685             case Extensions.DtsOnly:
24686                 return extension === ".d.ts";
24687         }
24688     }
24689     function parsePackageName(moduleName) {
24690         var idx = moduleName.indexOf(ts.directorySeparator);
24691         if (moduleName[0] === "@") {
24692             idx = moduleName.indexOf(ts.directorySeparator, idx + 1);
24693         }
24694         return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) };
24695     }
24696     ts.parsePackageName = parsePackageName;
24697     function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) {
24698         return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, false, cache, redirectedReference);
24699     }
24700     function loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, directory, state) {
24701         return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, true, undefined, undefined);
24702     }
24703     function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
24704         var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference);
24705         return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) {
24706             if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
24707                 var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state);
24708                 if (resolutionFromCache) {
24709                     return resolutionFromCache;
24710                 }
24711                 return toSearchResult(loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, ancestorDirectory, state, typesScopeOnly));
24712             }
24713         });
24714     }
24715     function loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, directory, state, typesScopeOnly) {
24716         var nodeModulesFolder = ts.combinePaths(directory, "node_modules");
24717         var nodeModulesFolderExists = ts.directoryProbablyExists(nodeModulesFolder, state.host);
24718         if (!nodeModulesFolderExists && state.traceEnabled) {
24719             trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder);
24720         }
24721         var packageResult = typesScopeOnly ? undefined : loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, state);
24722         if (packageResult) {
24723             return packageResult;
24724         }
24725         if (extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) {
24726             var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types");
24727             var nodeModulesAtTypesExists = nodeModulesFolderExists;
24728             if (nodeModulesFolderExists && !ts.directoryProbablyExists(nodeModulesAtTypes_1, state.host)) {
24729                 if (state.traceEnabled) {
24730                     trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1);
24731                 }
24732                 nodeModulesAtTypesExists = false;
24733             }
24734             return loadModuleFromSpecificNodeModulesDirectory(Extensions.DtsOnly, mangleScopedPackageNameWithTrace(moduleName, state), nodeModulesAtTypes_1, nodeModulesAtTypesExists, state);
24735         }
24736     }
24737     function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state) {
24738         var candidate = ts.normalizePath(ts.combinePaths(nodeModulesDirectory, moduleName));
24739         var packageInfo = getPackageJsonInfo(candidate, !nodeModulesDirectoryExists, state);
24740         if (packageInfo) {
24741             var fromFile = loadModuleFromFile(extensions, candidate, !nodeModulesDirectoryExists, state);
24742             if (fromFile) {
24743                 return noPackageId(fromFile);
24744             }
24745             var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageInfo.packageJsonContent, packageInfo.versionPaths);
24746             return withPackageId(packageInfo, fromDirectory);
24747         }
24748         var loader = function (extensions, candidate, onlyRecordFailures, state) {
24749             var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
24750                 loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
24751             return withPackageId(packageInfo, pathAndExtension);
24752         };
24753         var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
24754         if (rest !== "") {
24755             var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
24756             packageInfo = getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state);
24757             if (packageInfo && packageInfo.versionPaths) {
24758                 if (state.traceEnabled) {
24759                     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);
24760                 }
24761                 var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host);
24762                 var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, loader, !packageDirectoryExists, state);
24763                 if (fromPaths) {
24764                     return fromPaths.value;
24765                 }
24766             }
24767         }
24768         return loader(extensions, candidate, !nodeModulesDirectoryExists, state);
24769     }
24770     function tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, loader, onlyRecordFailures, state) {
24771         var matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(paths), moduleName);
24772         if (matchedPattern) {
24773             var matchedStar_1 = ts.isString(matchedPattern) ? undefined : ts.matchedText(matchedPattern, moduleName);
24774             var matchedPatternText = ts.isString(matchedPattern) ? matchedPattern : ts.patternText(matchedPattern);
24775             if (state.traceEnabled) {
24776                 trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText);
24777             }
24778             var resolved = ts.forEach(paths[matchedPatternText], function (subst) {
24779                 var path = matchedStar_1 ? subst.replace("*", matchedStar_1) : subst;
24780                 var candidate = ts.normalizePath(ts.combinePaths(baseDirectory, path));
24781                 if (state.traceEnabled) {
24782                     trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path);
24783                 }
24784                 var extension = ts.tryGetExtensionFromPath(candidate);
24785                 if (extension !== undefined) {
24786                     var path_1 = tryFile(candidate, onlyRecordFailures, state);
24787                     if (path_1 !== undefined) {
24788                         return noPackageId({ path: path_1, ext: extension });
24789                     }
24790                 }
24791                 return loader(extensions, candidate, onlyRecordFailures || !ts.directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state);
24792             });
24793             return { value: resolved };
24794         }
24795     }
24796     var mangledScopedPackageSeparator = "__";
24797     function mangleScopedPackageNameWithTrace(packageName, state) {
24798         var mangled = mangleScopedPackageName(packageName);
24799         if (state.traceEnabled && mangled !== packageName) {
24800             trace(state.host, ts.Diagnostics.Scoped_package_detected_looking_in_0, mangled);
24801         }
24802         return mangled;
24803     }
24804     function getTypesPackageName(packageName) {
24805         return "@types/" + mangleScopedPackageName(packageName);
24806     }
24807     ts.getTypesPackageName = getTypesPackageName;
24808     function mangleScopedPackageName(packageName) {
24809         if (ts.startsWith(packageName, "@")) {
24810             var replaceSlash = packageName.replace(ts.directorySeparator, mangledScopedPackageSeparator);
24811             if (replaceSlash !== packageName) {
24812                 return replaceSlash.slice(1);
24813             }
24814         }
24815         return packageName;
24816     }
24817     ts.mangleScopedPackageName = mangleScopedPackageName;
24818     function getPackageNameFromTypesPackageName(mangledName) {
24819         var withoutAtTypePrefix = ts.removePrefix(mangledName, "@types/");
24820         if (withoutAtTypePrefix !== mangledName) {
24821             return unmangleScopedPackageName(withoutAtTypePrefix);
24822         }
24823         return mangledName;
24824     }
24825     ts.getPackageNameFromTypesPackageName = getPackageNameFromTypesPackageName;
24826     function unmangleScopedPackageName(typesPackageName) {
24827         return ts.stringContains(typesPackageName, mangledScopedPackageSeparator) ?
24828             "@" + typesPackageName.replace(mangledScopedPackageSeparator, ts.directorySeparator) :
24829             typesPackageName;
24830     }
24831     ts.unmangleScopedPackageName = unmangleScopedPackageName;
24832     function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, state) {
24833         var result = cache && cache.get(containingDirectory);
24834         if (result) {
24835             if (state.traceEnabled) {
24836                 trace(state.host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
24837             }
24838             state.resultFromCache = result;
24839             return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, originalPath: result.resolvedModule.originalPath || true, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId } };
24840         }
24841     }
24842     function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
24843         var traceEnabled = isTraceEnabled(compilerOptions, host);
24844         var failedLookupLocations = [];
24845         var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations };
24846         var containingDirectory = ts.getDirectoryPath(containingFile);
24847         var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
24848         return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations, state.resultFromCache);
24849         function tryResolve(extensions) {
24850             var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
24851             if (resolvedUsingSettings) {
24852                 return { value: resolvedUsingSettings };
24853             }
24854             if (!ts.isExternalModuleNameRelative(moduleName)) {
24855                 var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference);
24856                 var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) {
24857                     var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache_1, moduleName, directory, state);
24858                     if (resolutionFromCache) {
24859                         return resolutionFromCache;
24860                     }
24861                     var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName));
24862                     return toSearchResult(loadModuleFromFileNoPackageId(extensions, searchName, false, state));
24863                 });
24864                 if (resolved_3) {
24865                     return resolved_3;
24866                 }
24867                 if (extensions === Extensions.TypeScript) {
24868                     return loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, containingDirectory, state);
24869                 }
24870             }
24871             else {
24872                 var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName));
24873                 return toSearchResult(loadModuleFromFileNoPackageId(extensions, candidate, false, state));
24874             }
24875         }
24876     }
24877     ts.classicNameResolver = classicNameResolver;
24878     function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache) {
24879         var traceEnabled = isTraceEnabled(compilerOptions, host);
24880         if (traceEnabled) {
24881             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);
24882         }
24883         var failedLookupLocations = [];
24884         var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations };
24885         var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, false);
24886         return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations, state.resultFromCache);
24887     }
24888     ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
24889     function toSearchResult(value) {
24890         return value !== undefined ? { value: value } : undefined;
24891     }
24892 })(ts || (ts = {}));
24893 var ts;
24894 (function (ts) {
24895     function getModuleInstanceState(node, visited) {
24896         if (node.body && !node.body.parent) {
24897             setParentPointers(node, node.body);
24898         }
24899         return node.body ? getModuleInstanceStateCached(node.body, visited) : 1;
24900     }
24901     ts.getModuleInstanceState = getModuleInstanceState;
24902     function getModuleInstanceStateCached(node, visited) {
24903         if (visited === void 0) { visited = ts.createMap(); }
24904         var nodeId = "" + ts.getNodeId(node);
24905         if (visited.has(nodeId)) {
24906             return visited.get(nodeId) || 0;
24907         }
24908         visited.set(nodeId, undefined);
24909         var result = getModuleInstanceStateWorker(node, visited);
24910         visited.set(nodeId, result);
24911         return result;
24912     }
24913     function getModuleInstanceStateWorker(node, visited) {
24914         switch (node.kind) {
24915             case 246:
24916             case 247:
24917                 return 0;
24918             case 248:
24919                 if (ts.isEnumConst(node)) {
24920                     return 2;
24921                 }
24922                 break;
24923             case 254:
24924             case 253:
24925                 if (!(ts.hasModifier(node, 1))) {
24926                     return 0;
24927                 }
24928                 break;
24929             case 260:
24930                 var exportDeclaration = node;
24931                 if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 261) {
24932                     var state = 0;
24933                     for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) {
24934                         var specifier = _a[_i];
24935                         var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited);
24936                         if (specifierState > state) {
24937                             state = specifierState;
24938                         }
24939                         if (state === 1) {
24940                             return state;
24941                         }
24942                     }
24943                     return state;
24944                 }
24945                 break;
24946             case 250: {
24947                 var state_1 = 0;
24948                 ts.forEachChild(node, function (n) {
24949                     var childState = getModuleInstanceStateCached(n, visited);
24950                     switch (childState) {
24951                         case 0:
24952                             return;
24953                         case 2:
24954                             state_1 = 2;
24955                             return;
24956                         case 1:
24957                             state_1 = 1;
24958                             return true;
24959                         default:
24960                             ts.Debug.assertNever(childState);
24961                     }
24962                 });
24963                 return state_1;
24964             }
24965             case 249:
24966                 return getModuleInstanceState(node, visited);
24967             case 75:
24968                 if (node.isInJSDocNamespace) {
24969                     return 0;
24970                 }
24971         }
24972         return 1;
24973     }
24974     function getModuleInstanceStateForAliasTarget(specifier, visited) {
24975         var name = specifier.propertyName || specifier.name;
24976         var p = specifier.parent;
24977         while (p) {
24978             if (ts.isBlock(p) || ts.isModuleBlock(p) || ts.isSourceFile(p)) {
24979                 var statements = p.statements;
24980                 var found = void 0;
24981                 for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) {
24982                     var statement = statements_1[_i];
24983                     if (ts.nodeHasName(statement, name)) {
24984                         if (!statement.parent) {
24985                             setParentPointers(p, statement);
24986                         }
24987                         var state = getModuleInstanceStateCached(statement, visited);
24988                         if (found === undefined || state > found) {
24989                             found = state;
24990                         }
24991                         if (found === 1) {
24992                             return found;
24993                         }
24994                     }
24995                 }
24996                 if (found !== undefined) {
24997                     return found;
24998                 }
24999             }
25000             p = p.parent;
25001         }
25002         return 1;
25003     }
25004     function initFlowNode(node) {
25005         ts.Debug.attachFlowNodeDebugInfo(node);
25006         return node;
25007     }
25008     var binder = createBinder();
25009     function bindSourceFile(file, options) {
25010         ts.performance.mark("beforeBind");
25011         ts.perfLogger.logStartBindFile("" + file.fileName);
25012         binder(file, options);
25013         ts.perfLogger.logStopBindFile();
25014         ts.performance.mark("afterBind");
25015         ts.performance.measure("Bind", "beforeBind", "afterBind");
25016     }
25017     ts.bindSourceFile = bindSourceFile;
25018     function createBinder() {
25019         var file;
25020         var options;
25021         var languageVersion;
25022         var parent;
25023         var container;
25024         var thisParentContainer;
25025         var blockScopeContainer;
25026         var lastContainer;
25027         var delayedTypeAliases;
25028         var seenThisKeyword;
25029         var currentFlow;
25030         var currentBreakTarget;
25031         var currentContinueTarget;
25032         var currentReturnTarget;
25033         var currentTrueTarget;
25034         var currentFalseTarget;
25035         var currentExceptionTarget;
25036         var preSwitchCaseFlow;
25037         var activeLabelList;
25038         var hasExplicitReturn;
25039         var emitFlags;
25040         var inStrictMode;
25041         var symbolCount = 0;
25042         var Symbol;
25043         var classifiableNames;
25044         var unreachableFlow = { flags: 1 };
25045         var reportedUnreachableFlow = { flags: 1 };
25046         var subtreeTransformFlags = 0;
25047         var skipTransformFlagAggregation;
25048         function createDiagnosticForNode(node, message, arg0, arg1, arg2) {
25049             return ts.createDiagnosticForNodeInSourceFile(ts.getSourceFileOfNode(node) || file, node, message, arg0, arg1, arg2);
25050         }
25051         function bindSourceFile(f, opts) {
25052             file = f;
25053             options = opts;
25054             languageVersion = ts.getEmitScriptTarget(options);
25055             inStrictMode = bindInStrictMode(file, opts);
25056             classifiableNames = ts.createUnderscoreEscapedMap();
25057             symbolCount = 0;
25058             skipTransformFlagAggregation = file.isDeclarationFile;
25059             Symbol = ts.objectAllocator.getSymbolConstructor();
25060             ts.Debug.attachFlowNodeDebugInfo(unreachableFlow);
25061             ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow);
25062             if (!file.locals) {
25063                 bind(file);
25064                 file.symbolCount = symbolCount;
25065                 file.classifiableNames = classifiableNames;
25066                 delayedBindJSDocTypedefTag();
25067             }
25068             file = undefined;
25069             options = undefined;
25070             languageVersion = undefined;
25071             parent = undefined;
25072             container = undefined;
25073             thisParentContainer = undefined;
25074             blockScopeContainer = undefined;
25075             lastContainer = undefined;
25076             delayedTypeAliases = undefined;
25077             seenThisKeyword = false;
25078             currentFlow = undefined;
25079             currentBreakTarget = undefined;
25080             currentContinueTarget = undefined;
25081             currentReturnTarget = undefined;
25082             currentTrueTarget = undefined;
25083             currentFalseTarget = undefined;
25084             currentExceptionTarget = undefined;
25085             activeLabelList = undefined;
25086             hasExplicitReturn = false;
25087             emitFlags = 0;
25088             subtreeTransformFlags = 0;
25089         }
25090         return bindSourceFile;
25091         function bindInStrictMode(file, opts) {
25092             if (ts.getStrictOptionValue(opts, "alwaysStrict") && !file.isDeclarationFile) {
25093                 return true;
25094             }
25095             else {
25096                 return !!file.externalModuleIndicator;
25097             }
25098         }
25099         function createSymbol(flags, name) {
25100             symbolCount++;
25101             return new Symbol(flags, name);
25102         }
25103         function addDeclarationToSymbol(symbol, node, symbolFlags) {
25104             symbol.flags |= symbolFlags;
25105             node.symbol = symbol;
25106             symbol.declarations = ts.appendIfUnique(symbol.declarations, node);
25107             if (symbolFlags & (32 | 384 | 1536 | 3) && !symbol.exports) {
25108                 symbol.exports = ts.createSymbolTable();
25109             }
25110             if (symbolFlags & (32 | 64 | 2048 | 4096) && !symbol.members) {
25111                 symbol.members = ts.createSymbolTable();
25112             }
25113             if (symbol.constEnumOnlyModule && (symbol.flags & (16 | 32 | 256))) {
25114                 symbol.constEnumOnlyModule = false;
25115             }
25116             if (symbolFlags & 111551) {
25117                 ts.setValueDeclaration(symbol, node);
25118             }
25119         }
25120         function getDeclarationName(node) {
25121             if (node.kind === 259) {
25122                 return node.isExportEquals ? "export=" : "default";
25123             }
25124             var name = ts.getNameOfDeclaration(node);
25125             if (name) {
25126                 if (ts.isAmbientModule(node)) {
25127                     var moduleName = ts.getTextOfIdentifierOrLiteral(name);
25128                     return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\"");
25129                 }
25130                 if (name.kind === 154) {
25131                     var nameExpression = name.expression;
25132                     if (ts.isStringOrNumericLiteralLike(nameExpression)) {
25133                         return ts.escapeLeadingUnderscores(nameExpression.text);
25134                     }
25135                     if (ts.isSignedNumericLiteral(nameExpression)) {
25136                         return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text;
25137                     }
25138                     ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression));
25139                     return ts.getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name));
25140                 }
25141                 if (ts.isWellKnownSymbolSyntactically(name)) {
25142                     return ts.getPropertyNameForKnownSymbolName(ts.idText(name.name));
25143                 }
25144                 if (ts.isPrivateIdentifier(name)) {
25145                     var containingClass = ts.getContainingClass(node);
25146                     if (!containingClass) {
25147                         return undefined;
25148                     }
25149                     var containingClassSymbol = containingClass.symbol;
25150                     return ts.getSymbolNameForPrivateIdentifier(containingClassSymbol, name.escapedText);
25151                 }
25152                 return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined;
25153             }
25154             switch (node.kind) {
25155                 case 162:
25156                     return "__constructor";
25157                 case 170:
25158                 case 165:
25159                 case 305:
25160                     return "__call";
25161                 case 171:
25162                 case 166:
25163                     return "__new";
25164                 case 167:
25165                     return "__index";
25166                 case 260:
25167                     return "__export";
25168                 case 290:
25169                     return "export=";
25170                 case 209:
25171                     if (ts.getAssignmentDeclarationKind(node) === 2) {
25172                         return "export=";
25173                     }
25174                     ts.Debug.fail("Unknown binary declaration kind");
25175                     break;
25176                 case 300:
25177                     return (ts.isJSDocConstructSignature(node) ? "__new" : "__call");
25178                 case 156:
25179                     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"; });
25180                     var functionType = node.parent;
25181                     var index = functionType.parameters.indexOf(node);
25182                     return "arg" + index;
25183             }
25184         }
25185         function getDisplayName(node) {
25186             return ts.isNamedDeclaration(node) ? ts.declarationNameToString(node.name) : ts.unescapeLeadingUnderscores(ts.Debug.checkDefined(getDeclarationName(node)));
25187         }
25188         function declareSymbol(symbolTable, parent, node, includes, excludes, isReplaceableByMethod) {
25189             ts.Debug.assert(!ts.hasDynamicName(node));
25190             var isDefaultExport = ts.hasModifier(node, 512) || ts.isExportSpecifier(node) && node.name.escapedText === "default";
25191             var name = isDefaultExport && parent ? "default" : getDeclarationName(node);
25192             var symbol;
25193             if (name === undefined) {
25194                 symbol = createSymbol(0, "__missing");
25195             }
25196             else {
25197                 symbol = symbolTable.get(name);
25198                 if (includes & 2885600) {
25199                     classifiableNames.set(name, true);
25200                 }
25201                 if (!symbol) {
25202                     symbolTable.set(name, symbol = createSymbol(0, name));
25203                     if (isReplaceableByMethod)
25204                         symbol.isReplaceableByMethod = true;
25205                 }
25206                 else if (isReplaceableByMethod && !symbol.isReplaceableByMethod) {
25207                     return symbol;
25208                 }
25209                 else if (symbol.flags & excludes) {
25210                     if (symbol.isReplaceableByMethod) {
25211                         symbolTable.set(name, symbol = createSymbol(0, name));
25212                     }
25213                     else if (!(includes & 3 && symbol.flags & 67108864)) {
25214                         if (ts.isNamedDeclaration(node)) {
25215                             node.name.parent = node;
25216                         }
25217                         var message_1 = symbol.flags & 2
25218                             ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
25219                             : ts.Diagnostics.Duplicate_identifier_0;
25220                         var messageNeedsName_1 = true;
25221                         if (symbol.flags & 384 || includes & 384) {
25222                             message_1 = ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations;
25223                             messageNeedsName_1 = false;
25224                         }
25225                         var multipleDefaultExports_1 = false;
25226                         if (ts.length(symbol.declarations)) {
25227                             if (isDefaultExport) {
25228                                 message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports;
25229                                 messageNeedsName_1 = false;
25230                                 multipleDefaultExports_1 = true;
25231                             }
25232                             else {
25233                                 if (symbol.declarations && symbol.declarations.length &&
25234                                     (node.kind === 259 && !node.isExportEquals)) {
25235                                     message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports;
25236                                     messageNeedsName_1 = false;
25237                                     multipleDefaultExports_1 = true;
25238                                 }
25239                             }
25240                         }
25241                         var relatedInformation_1 = [];
25242                         if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasModifier(node, 1) && symbol.flags & (2097152 | 788968 | 1920)) {
25243                             relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { " + ts.unescapeLeadingUnderscores(node.name.escapedText) + " }"));
25244                         }
25245                         var declarationName_1 = ts.getNameOfDeclaration(node) || node;
25246                         ts.forEach(symbol.declarations, function (declaration, index) {
25247                             var decl = ts.getNameOfDeclaration(declaration) || declaration;
25248                             var diag = createDiagnosticForNode(decl, message_1, messageNeedsName_1 ? getDisplayName(declaration) : undefined);
25249                             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);
25250                             if (multipleDefaultExports_1) {
25251                                 relatedInformation_1.push(createDiagnosticForNode(decl, ts.Diagnostics.The_first_export_default_is_here));
25252                             }
25253                         });
25254                         var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined);
25255                         file.bindDiagnostics.push(ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInformation_1)));
25256                         symbol = createSymbol(0, name);
25257                     }
25258                 }
25259             }
25260             addDeclarationToSymbol(symbol, node, includes);
25261             if (symbol.parent) {
25262                 ts.Debug.assert(symbol.parent === parent, "Existing symbol parent should match new one");
25263             }
25264             else {
25265                 symbol.parent = parent;
25266             }
25267             return symbol;
25268         }
25269         function declareModuleMember(node, symbolFlags, symbolExcludes) {
25270             var hasExportModifier = ts.getCombinedModifierFlags(node) & 1;
25271             if (symbolFlags & 2097152) {
25272                 if (node.kind === 263 || (node.kind === 253 && hasExportModifier)) {
25273                     return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
25274                 }
25275                 else {
25276                     return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes);
25277                 }
25278             }
25279             else {
25280                 if (ts.isJSDocTypeAlias(node))
25281                     ts.Debug.assert(ts.isInJSFile(node));
25282                 if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64)) || ts.isJSDocTypeAlias(node)) {
25283                     if (!container.locals || (ts.hasModifier(node, 512) && !getDeclarationName(node))) {
25284                         return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
25285                     }
25286                     var exportKind = symbolFlags & 111551 ? 1048576 : 0;
25287                     var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes);
25288                     local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
25289                     node.localSymbol = local;
25290                     return local;
25291                 }
25292                 else {
25293                     return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes);
25294                 }
25295             }
25296         }
25297         function bindContainer(node, containerFlags) {
25298             var saveContainer = container;
25299             var saveThisParentContainer = thisParentContainer;
25300             var savedBlockScopeContainer = blockScopeContainer;
25301             if (containerFlags & 1) {
25302                 if (node.kind !== 202) {
25303                     thisParentContainer = container;
25304                 }
25305                 container = blockScopeContainer = node;
25306                 if (containerFlags & 32) {
25307                     container.locals = ts.createSymbolTable();
25308                 }
25309                 addToContainerChain(container);
25310             }
25311             else if (containerFlags & 2) {
25312                 blockScopeContainer = node;
25313                 blockScopeContainer.locals = undefined;
25314             }
25315             if (containerFlags & 4) {
25316                 var saveCurrentFlow = currentFlow;
25317                 var saveBreakTarget = currentBreakTarget;
25318                 var saveContinueTarget = currentContinueTarget;
25319                 var saveReturnTarget = currentReturnTarget;
25320                 var saveExceptionTarget = currentExceptionTarget;
25321                 var saveActiveLabelList = activeLabelList;
25322                 var saveHasExplicitReturn = hasExplicitReturn;
25323                 var isIIFE = containerFlags & 16 && !ts.hasModifier(node, 256) &&
25324                     !node.asteriskToken && !!ts.getImmediatelyInvokedFunctionExpression(node);
25325                 if (!isIIFE) {
25326                     currentFlow = initFlowNode({ flags: 2 });
25327                     if (containerFlags & (16 | 128)) {
25328                         currentFlow.node = node;
25329                     }
25330                 }
25331                 currentReturnTarget = isIIFE || node.kind === 162 ? createBranchLabel() : undefined;
25332                 currentExceptionTarget = undefined;
25333                 currentBreakTarget = undefined;
25334                 currentContinueTarget = undefined;
25335                 activeLabelList = undefined;
25336                 hasExplicitReturn = false;
25337                 bindChildren(node);
25338                 node.flags &= ~2816;
25339                 if (!(currentFlow.flags & 1) && containerFlags & 8 && ts.nodeIsPresent(node.body)) {
25340                     node.flags |= 256;
25341                     if (hasExplicitReturn)
25342                         node.flags |= 512;
25343                     node.endFlowNode = currentFlow;
25344                 }
25345                 if (node.kind === 290) {
25346                     node.flags |= emitFlags;
25347                 }
25348                 if (currentReturnTarget) {
25349                     addAntecedent(currentReturnTarget, currentFlow);
25350                     currentFlow = finishFlowLabel(currentReturnTarget);
25351                     if (node.kind === 162) {
25352                         node.returnFlowNode = currentFlow;
25353                     }
25354                 }
25355                 if (!isIIFE) {
25356                     currentFlow = saveCurrentFlow;
25357                 }
25358                 currentBreakTarget = saveBreakTarget;
25359                 currentContinueTarget = saveContinueTarget;
25360                 currentReturnTarget = saveReturnTarget;
25361                 currentExceptionTarget = saveExceptionTarget;
25362                 activeLabelList = saveActiveLabelList;
25363                 hasExplicitReturn = saveHasExplicitReturn;
25364             }
25365             else if (containerFlags & 64) {
25366                 seenThisKeyword = false;
25367                 bindChildren(node);
25368                 node.flags = seenThisKeyword ? node.flags | 128 : node.flags & ~128;
25369             }
25370             else {
25371                 bindChildren(node);
25372             }
25373             container = saveContainer;
25374             thisParentContainer = saveThisParentContainer;
25375             blockScopeContainer = savedBlockScopeContainer;
25376         }
25377         function bindChildren(node) {
25378             if (skipTransformFlagAggregation) {
25379                 bindChildrenWorker(node);
25380             }
25381             else if (node.transformFlags & 536870912) {
25382                 skipTransformFlagAggregation = true;
25383                 bindChildrenWorker(node);
25384                 skipTransformFlagAggregation = false;
25385                 subtreeTransformFlags |= node.transformFlags & ~getTransformFlagsSubtreeExclusions(node.kind);
25386             }
25387             else {
25388                 var savedSubtreeTransformFlags = subtreeTransformFlags;
25389                 subtreeTransformFlags = 0;
25390                 bindChildrenWorker(node);
25391                 subtreeTransformFlags = savedSubtreeTransformFlags | computeTransformFlagsForNode(node, subtreeTransformFlags);
25392             }
25393         }
25394         function bindEachFunctionsFirst(nodes) {
25395             bindEach(nodes, function (n) { return n.kind === 244 ? bind(n) : undefined; });
25396             bindEach(nodes, function (n) { return n.kind !== 244 ? bind(n) : undefined; });
25397         }
25398         function bindEach(nodes, bindFunction) {
25399             if (bindFunction === void 0) { bindFunction = bind; }
25400             if (nodes === undefined) {
25401                 return;
25402             }
25403             if (skipTransformFlagAggregation) {
25404                 ts.forEach(nodes, bindFunction);
25405             }
25406             else {
25407                 var savedSubtreeTransformFlags = subtreeTransformFlags;
25408                 subtreeTransformFlags = 0;
25409                 var nodeArrayFlags = 0;
25410                 for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) {
25411                     var node = nodes_2[_i];
25412                     bindFunction(node);
25413                     nodeArrayFlags |= node.transformFlags & ~536870912;
25414                 }
25415                 nodes.transformFlags = nodeArrayFlags | 536870912;
25416                 subtreeTransformFlags |= savedSubtreeTransformFlags;
25417             }
25418         }
25419         function bindEachChild(node) {
25420             ts.forEachChild(node, bind, bindEach);
25421         }
25422         function bindChildrenWorker(node) {
25423             if (checkUnreachable(node)) {
25424                 bindEachChild(node);
25425                 bindJSDoc(node);
25426                 return;
25427             }
25428             if (node.kind >= 225 && node.kind <= 241 && !options.allowUnreachableCode) {
25429                 node.flowNode = currentFlow;
25430             }
25431             switch (node.kind) {
25432                 case 229:
25433                     bindWhileStatement(node);
25434                     break;
25435                 case 228:
25436                     bindDoStatement(node);
25437                     break;
25438                 case 230:
25439                     bindForStatement(node);
25440                     break;
25441                 case 231:
25442                 case 232:
25443                     bindForInOrForOfStatement(node);
25444                     break;
25445                 case 227:
25446                     bindIfStatement(node);
25447                     break;
25448                 case 235:
25449                 case 239:
25450                     bindReturnOrThrow(node);
25451                     break;
25452                 case 234:
25453                 case 233:
25454                     bindBreakOrContinueStatement(node);
25455                     break;
25456                 case 240:
25457                     bindTryStatement(node);
25458                     break;
25459                 case 237:
25460                     bindSwitchStatement(node);
25461                     break;
25462                 case 251:
25463                     bindCaseBlock(node);
25464                     break;
25465                 case 277:
25466                     bindCaseClause(node);
25467                     break;
25468                 case 226:
25469                     bindExpressionStatement(node);
25470                     break;
25471                 case 238:
25472                     bindLabeledStatement(node);
25473                     break;
25474                 case 207:
25475                     bindPrefixUnaryExpressionFlow(node);
25476                     break;
25477                 case 208:
25478                     bindPostfixUnaryExpressionFlow(node);
25479                     break;
25480                 case 209:
25481                     bindBinaryExpressionFlow(node);
25482                     break;
25483                 case 203:
25484                     bindDeleteExpressionFlow(node);
25485                     break;
25486                 case 210:
25487                     bindConditionalExpressionFlow(node);
25488                     break;
25489                 case 242:
25490                     bindVariableDeclarationFlow(node);
25491                     break;
25492                 case 194:
25493                 case 195:
25494                     bindAccessExpressionFlow(node);
25495                     break;
25496                 case 196:
25497                     bindCallExpressionFlow(node);
25498                     break;
25499                 case 218:
25500                     bindNonNullExpressionFlow(node);
25501                     break;
25502                 case 322:
25503                 case 315:
25504                 case 316:
25505                     bindJSDocTypeAlias(node);
25506                     break;
25507                 case 290: {
25508                     bindEachFunctionsFirst(node.statements);
25509                     bind(node.endOfFileToken);
25510                     break;
25511                 }
25512                 case 223:
25513                 case 250:
25514                     bindEachFunctionsFirst(node.statements);
25515                     break;
25516                 default:
25517                     bindEachChild(node);
25518                     break;
25519             }
25520             bindJSDoc(node);
25521         }
25522         function isNarrowingExpression(expr) {
25523             switch (expr.kind) {
25524                 case 75:
25525                 case 104:
25526                 case 194:
25527                 case 195:
25528                     return containsNarrowableReference(expr);
25529                 case 196:
25530                     return hasNarrowableArgument(expr);
25531                 case 200:
25532                     return isNarrowingExpression(expr.expression);
25533                 case 209:
25534                     return isNarrowingBinaryExpression(expr);
25535                 case 207:
25536                     return expr.operator === 53 && isNarrowingExpression(expr.operand);
25537                 case 204:
25538                     return isNarrowingExpression(expr.expression);
25539             }
25540             return false;
25541         }
25542         function isNarrowableReference(expr) {
25543             return expr.kind === 75 || expr.kind === 104 || expr.kind === 102 ||
25544                 (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) ||
25545                 ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression);
25546         }
25547         function containsNarrowableReference(expr) {
25548             return isNarrowableReference(expr) || ts.isOptionalChain(expr) && containsNarrowableReference(expr.expression);
25549         }
25550         function hasNarrowableArgument(expr) {
25551             if (expr.arguments) {
25552                 for (var _i = 0, _a = expr.arguments; _i < _a.length; _i++) {
25553                     var argument = _a[_i];
25554                     if (containsNarrowableReference(argument)) {
25555                         return true;
25556                     }
25557                 }
25558             }
25559             if (expr.expression.kind === 194 &&
25560                 containsNarrowableReference(expr.expression.expression)) {
25561                 return true;
25562             }
25563             return false;
25564         }
25565         function isNarrowingTypeofOperands(expr1, expr2) {
25566             return ts.isTypeOfExpression(expr1) && isNarrowableOperand(expr1.expression) && ts.isStringLiteralLike(expr2);
25567         }
25568         function isNarrowableInOperands(left, right) {
25569             return ts.isStringLiteralLike(left) && isNarrowingExpression(right);
25570         }
25571         function isNarrowingBinaryExpression(expr) {
25572             switch (expr.operatorToken.kind) {
25573                 case 62:
25574                     return containsNarrowableReference(expr.left);
25575                 case 34:
25576                 case 35:
25577                 case 36:
25578                 case 37:
25579                     return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) ||
25580                         isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right);
25581                 case 98:
25582                     return isNarrowableOperand(expr.left);
25583                 case 97:
25584                     return isNarrowableInOperands(expr.left, expr.right);
25585                 case 27:
25586                     return isNarrowingExpression(expr.right);
25587             }
25588             return false;
25589         }
25590         function isNarrowableOperand(expr) {
25591             switch (expr.kind) {
25592                 case 200:
25593                     return isNarrowableOperand(expr.expression);
25594                 case 209:
25595                     switch (expr.operatorToken.kind) {
25596                         case 62:
25597                             return isNarrowableOperand(expr.left);
25598                         case 27:
25599                             return isNarrowableOperand(expr.right);
25600                     }
25601             }
25602             return containsNarrowableReference(expr);
25603         }
25604         function createBranchLabel() {
25605             return initFlowNode({ flags: 4, antecedents: undefined });
25606         }
25607         function createLoopLabel() {
25608             return initFlowNode({ flags: 8, antecedents: undefined });
25609         }
25610         function createReduceLabel(target, antecedents, antecedent) {
25611             return initFlowNode({ flags: 1024, target: target, antecedents: antecedents, antecedent: antecedent });
25612         }
25613         function setFlowNodeReferenced(flow) {
25614             flow.flags |= flow.flags & 2048 ? 4096 : 2048;
25615         }
25616         function addAntecedent(label, antecedent) {
25617             if (!(antecedent.flags & 1) && !ts.contains(label.antecedents, antecedent)) {
25618                 (label.antecedents || (label.antecedents = [])).push(antecedent);
25619                 setFlowNodeReferenced(antecedent);
25620             }
25621         }
25622         function createFlowCondition(flags, antecedent, expression) {
25623             if (antecedent.flags & 1) {
25624                 return antecedent;
25625             }
25626             if (!expression) {
25627                 return flags & 32 ? antecedent : unreachableFlow;
25628             }
25629             if ((expression.kind === 106 && flags & 64 ||
25630                 expression.kind === 91 && flags & 32) &&
25631                 !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) {
25632                 return unreachableFlow;
25633             }
25634             if (!isNarrowingExpression(expression)) {
25635                 return antecedent;
25636             }
25637             setFlowNodeReferenced(antecedent);
25638             return initFlowNode({ flags: flags, antecedent: antecedent, node: expression });
25639         }
25640         function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) {
25641             setFlowNodeReferenced(antecedent);
25642             return initFlowNode({ flags: 128, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd });
25643         }
25644         function createFlowMutation(flags, antecedent, node) {
25645             setFlowNodeReferenced(antecedent);
25646             var result = initFlowNode({ flags: flags, antecedent: antecedent, node: node });
25647             if (currentExceptionTarget) {
25648                 addAntecedent(currentExceptionTarget, result);
25649             }
25650             return result;
25651         }
25652         function createFlowCall(antecedent, node) {
25653             setFlowNodeReferenced(antecedent);
25654             return initFlowNode({ flags: 512, antecedent: antecedent, node: node });
25655         }
25656         function finishFlowLabel(flow) {
25657             var antecedents = flow.antecedents;
25658             if (!antecedents) {
25659                 return unreachableFlow;
25660             }
25661             if (antecedents.length === 1) {
25662                 return antecedents[0];
25663             }
25664             return flow;
25665         }
25666         function isStatementCondition(node) {
25667             var parent = node.parent;
25668             switch (parent.kind) {
25669                 case 227:
25670                 case 229:
25671                 case 228:
25672                     return parent.expression === node;
25673                 case 230:
25674                 case 210:
25675                     return parent.condition === node;
25676             }
25677             return false;
25678         }
25679         function isLogicalExpression(node) {
25680             while (true) {
25681                 if (node.kind === 200) {
25682                     node = node.expression;
25683                 }
25684                 else if (node.kind === 207 && node.operator === 53) {
25685                     node = node.operand;
25686                 }
25687                 else {
25688                     return node.kind === 209 && (node.operatorToken.kind === 55 ||
25689                         node.operatorToken.kind === 56 ||
25690                         node.operatorToken.kind === 60);
25691                 }
25692             }
25693         }
25694         function isTopLevelLogicalExpression(node) {
25695             while (ts.isParenthesizedExpression(node.parent) ||
25696                 ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53) {
25697                 node = node.parent;
25698             }
25699             return !isStatementCondition(node) &&
25700                 !isLogicalExpression(node.parent) &&
25701                 !(ts.isOptionalChain(node.parent) && node.parent.expression === node);
25702         }
25703         function doWithConditionalBranches(action, value, trueTarget, falseTarget) {
25704             var savedTrueTarget = currentTrueTarget;
25705             var savedFalseTarget = currentFalseTarget;
25706             currentTrueTarget = trueTarget;
25707             currentFalseTarget = falseTarget;
25708             action(value);
25709             currentTrueTarget = savedTrueTarget;
25710             currentFalseTarget = savedFalseTarget;
25711         }
25712         function bindCondition(node, trueTarget, falseTarget) {
25713             doWithConditionalBranches(bind, node, trueTarget, falseTarget);
25714             if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && ts.isOutermostOptionalChain(node))) {
25715                 addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node));
25716                 addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node));
25717             }
25718         }
25719         function bindIterativeStatement(node, breakTarget, continueTarget) {
25720             var saveBreakTarget = currentBreakTarget;
25721             var saveContinueTarget = currentContinueTarget;
25722             currentBreakTarget = breakTarget;
25723             currentContinueTarget = continueTarget;
25724             bind(node);
25725             currentBreakTarget = saveBreakTarget;
25726             currentContinueTarget = saveContinueTarget;
25727         }
25728         function setContinueTarget(node, target) {
25729             var label = activeLabelList;
25730             while (label && node.parent.kind === 238) {
25731                 label.continueTarget = target;
25732                 label = label.next;
25733                 node = node.parent;
25734             }
25735             return target;
25736         }
25737         function bindWhileStatement(node) {
25738             var preWhileLabel = setContinueTarget(node, createLoopLabel());
25739             var preBodyLabel = createBranchLabel();
25740             var postWhileLabel = createBranchLabel();
25741             addAntecedent(preWhileLabel, currentFlow);
25742             currentFlow = preWhileLabel;
25743             bindCondition(node.expression, preBodyLabel, postWhileLabel);
25744             currentFlow = finishFlowLabel(preBodyLabel);
25745             bindIterativeStatement(node.statement, postWhileLabel, preWhileLabel);
25746             addAntecedent(preWhileLabel, currentFlow);
25747             currentFlow = finishFlowLabel(postWhileLabel);
25748         }
25749         function bindDoStatement(node) {
25750             var preDoLabel = createLoopLabel();
25751             var preConditionLabel = setContinueTarget(node, createBranchLabel());
25752             var postDoLabel = createBranchLabel();
25753             addAntecedent(preDoLabel, currentFlow);
25754             currentFlow = preDoLabel;
25755             bindIterativeStatement(node.statement, postDoLabel, preConditionLabel);
25756             addAntecedent(preConditionLabel, currentFlow);
25757             currentFlow = finishFlowLabel(preConditionLabel);
25758             bindCondition(node.expression, preDoLabel, postDoLabel);
25759             currentFlow = finishFlowLabel(postDoLabel);
25760         }
25761         function bindForStatement(node) {
25762             var preLoopLabel = setContinueTarget(node, createLoopLabel());
25763             var preBodyLabel = createBranchLabel();
25764             var postLoopLabel = createBranchLabel();
25765             bind(node.initializer);
25766             addAntecedent(preLoopLabel, currentFlow);
25767             currentFlow = preLoopLabel;
25768             bindCondition(node.condition, preBodyLabel, postLoopLabel);
25769             currentFlow = finishFlowLabel(preBodyLabel);
25770             bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel);
25771             bind(node.incrementor);
25772             addAntecedent(preLoopLabel, currentFlow);
25773             currentFlow = finishFlowLabel(postLoopLabel);
25774         }
25775         function bindForInOrForOfStatement(node) {
25776             var preLoopLabel = setContinueTarget(node, createLoopLabel());
25777             var postLoopLabel = createBranchLabel();
25778             bind(node.expression);
25779             addAntecedent(preLoopLabel, currentFlow);
25780             currentFlow = preLoopLabel;
25781             if (node.kind === 232) {
25782                 bind(node.awaitModifier);
25783             }
25784             addAntecedent(postLoopLabel, currentFlow);
25785             bind(node.initializer);
25786             if (node.initializer.kind !== 243) {
25787                 bindAssignmentTargetFlow(node.initializer);
25788             }
25789             bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel);
25790             addAntecedent(preLoopLabel, currentFlow);
25791             currentFlow = finishFlowLabel(postLoopLabel);
25792         }
25793         function bindIfStatement(node) {
25794             var thenLabel = createBranchLabel();
25795             var elseLabel = createBranchLabel();
25796             var postIfLabel = createBranchLabel();
25797             bindCondition(node.expression, thenLabel, elseLabel);
25798             currentFlow = finishFlowLabel(thenLabel);
25799             bind(node.thenStatement);
25800             addAntecedent(postIfLabel, currentFlow);
25801             currentFlow = finishFlowLabel(elseLabel);
25802             bind(node.elseStatement);
25803             addAntecedent(postIfLabel, currentFlow);
25804             currentFlow = finishFlowLabel(postIfLabel);
25805         }
25806         function bindReturnOrThrow(node) {
25807             bind(node.expression);
25808             if (node.kind === 235) {
25809                 hasExplicitReturn = true;
25810                 if (currentReturnTarget) {
25811                     addAntecedent(currentReturnTarget, currentFlow);
25812                 }
25813             }
25814             currentFlow = unreachableFlow;
25815         }
25816         function findActiveLabel(name) {
25817             for (var label = activeLabelList; label; label = label.next) {
25818                 if (label.name === name) {
25819                     return label;
25820                 }
25821             }
25822             return undefined;
25823         }
25824         function bindBreakOrContinueFlow(node, breakTarget, continueTarget) {
25825             var flowLabel = node.kind === 234 ? breakTarget : continueTarget;
25826             if (flowLabel) {
25827                 addAntecedent(flowLabel, currentFlow);
25828                 currentFlow = unreachableFlow;
25829             }
25830         }
25831         function bindBreakOrContinueStatement(node) {
25832             bind(node.label);
25833             if (node.label) {
25834                 var activeLabel = findActiveLabel(node.label.escapedText);
25835                 if (activeLabel) {
25836                     activeLabel.referenced = true;
25837                     bindBreakOrContinueFlow(node, activeLabel.breakTarget, activeLabel.continueTarget);
25838                 }
25839             }
25840             else {
25841                 bindBreakOrContinueFlow(node, currentBreakTarget, currentContinueTarget);
25842             }
25843         }
25844         function bindTryStatement(node) {
25845             var saveReturnTarget = currentReturnTarget;
25846             var saveExceptionTarget = currentExceptionTarget;
25847             var normalExitLabel = createBranchLabel();
25848             var returnLabel = createBranchLabel();
25849             var exceptionLabel = createBranchLabel();
25850             if (node.finallyBlock) {
25851                 currentReturnTarget = returnLabel;
25852             }
25853             addAntecedent(exceptionLabel, currentFlow);
25854             currentExceptionTarget = exceptionLabel;
25855             bind(node.tryBlock);
25856             addAntecedent(normalExitLabel, currentFlow);
25857             if (node.catchClause) {
25858                 currentFlow = finishFlowLabel(exceptionLabel);
25859                 exceptionLabel = createBranchLabel();
25860                 addAntecedent(exceptionLabel, currentFlow);
25861                 currentExceptionTarget = exceptionLabel;
25862                 bind(node.catchClause);
25863                 addAntecedent(normalExitLabel, currentFlow);
25864             }
25865             currentReturnTarget = saveReturnTarget;
25866             currentExceptionTarget = saveExceptionTarget;
25867             if (node.finallyBlock) {
25868                 var finallyLabel = createBranchLabel();
25869                 finallyLabel.antecedents = ts.concatenate(ts.concatenate(normalExitLabel.antecedents, exceptionLabel.antecedents), returnLabel.antecedents);
25870                 currentFlow = finallyLabel;
25871                 bind(node.finallyBlock);
25872                 if (currentFlow.flags & 1) {
25873                     currentFlow = unreachableFlow;
25874                 }
25875                 else {
25876                     if (currentReturnTarget && returnLabel.antecedents) {
25877                         addAntecedent(currentReturnTarget, createReduceLabel(finallyLabel, returnLabel.antecedents, currentFlow));
25878                     }
25879                     currentFlow = normalExitLabel.antecedents ? createReduceLabel(finallyLabel, normalExitLabel.antecedents, currentFlow) : unreachableFlow;
25880                 }
25881             }
25882             else {
25883                 currentFlow = finishFlowLabel(normalExitLabel);
25884             }
25885         }
25886         function bindSwitchStatement(node) {
25887             var postSwitchLabel = createBranchLabel();
25888             bind(node.expression);
25889             var saveBreakTarget = currentBreakTarget;
25890             var savePreSwitchCaseFlow = preSwitchCaseFlow;
25891             currentBreakTarget = postSwitchLabel;
25892             preSwitchCaseFlow = currentFlow;
25893             bind(node.caseBlock);
25894             addAntecedent(postSwitchLabel, currentFlow);
25895             var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 278; });
25896             node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents;
25897             if (!hasDefault) {
25898                 addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0));
25899             }
25900             currentBreakTarget = saveBreakTarget;
25901             preSwitchCaseFlow = savePreSwitchCaseFlow;
25902             currentFlow = finishFlowLabel(postSwitchLabel);
25903         }
25904         function bindCaseBlock(node) {
25905             var savedSubtreeTransformFlags = subtreeTransformFlags;
25906             subtreeTransformFlags = 0;
25907             var clauses = node.clauses;
25908             var isNarrowingSwitch = isNarrowingExpression(node.parent.expression);
25909             var fallthroughFlow = unreachableFlow;
25910             for (var i = 0; i < clauses.length; i++) {
25911                 var clauseStart = i;
25912                 while (!clauses[i].statements.length && i + 1 < clauses.length) {
25913                     bind(clauses[i]);
25914                     i++;
25915                 }
25916                 var preCaseLabel = createBranchLabel();
25917                 addAntecedent(preCaseLabel, isNarrowingSwitch ? createFlowSwitchClause(preSwitchCaseFlow, node.parent, clauseStart, i + 1) : preSwitchCaseFlow);
25918                 addAntecedent(preCaseLabel, fallthroughFlow);
25919                 currentFlow = finishFlowLabel(preCaseLabel);
25920                 var clause = clauses[i];
25921                 bind(clause);
25922                 fallthroughFlow = currentFlow;
25923                 if (!(currentFlow.flags & 1) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) {
25924                     clause.fallthroughFlowNode = currentFlow;
25925                 }
25926             }
25927             clauses.transformFlags = subtreeTransformFlags | 536870912;
25928             subtreeTransformFlags |= savedSubtreeTransformFlags;
25929         }
25930         function bindCaseClause(node) {
25931             var saveCurrentFlow = currentFlow;
25932             currentFlow = preSwitchCaseFlow;
25933             bind(node.expression);
25934             currentFlow = saveCurrentFlow;
25935             bindEach(node.statements);
25936         }
25937         function bindExpressionStatement(node) {
25938             bind(node.expression);
25939             if (node.expression.kind === 196) {
25940                 var call = node.expression;
25941                 if (ts.isDottedName(call.expression)) {
25942                     currentFlow = createFlowCall(currentFlow, call);
25943                 }
25944             }
25945         }
25946         function bindLabeledStatement(node) {
25947             var postStatementLabel = createBranchLabel();
25948             activeLabelList = {
25949                 next: activeLabelList,
25950                 name: node.label.escapedText,
25951                 breakTarget: postStatementLabel,
25952                 continueTarget: undefined,
25953                 referenced: false
25954             };
25955             bind(node.label);
25956             bind(node.statement);
25957             if (!activeLabelList.referenced && !options.allowUnusedLabels) {
25958                 errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label);
25959             }
25960             activeLabelList = activeLabelList.next;
25961             addAntecedent(postStatementLabel, currentFlow);
25962             currentFlow = finishFlowLabel(postStatementLabel);
25963         }
25964         function bindDestructuringTargetFlow(node) {
25965             if (node.kind === 209 && node.operatorToken.kind === 62) {
25966                 bindAssignmentTargetFlow(node.left);
25967             }
25968             else {
25969                 bindAssignmentTargetFlow(node);
25970             }
25971         }
25972         function bindAssignmentTargetFlow(node) {
25973             if (isNarrowableReference(node)) {
25974                 currentFlow = createFlowMutation(16, currentFlow, node);
25975             }
25976             else if (node.kind === 192) {
25977                 for (var _i = 0, _a = node.elements; _i < _a.length; _i++) {
25978                     var e = _a[_i];
25979                     if (e.kind === 213) {
25980                         bindAssignmentTargetFlow(e.expression);
25981                     }
25982                     else {
25983                         bindDestructuringTargetFlow(e);
25984                     }
25985                 }
25986             }
25987             else if (node.kind === 193) {
25988                 for (var _b = 0, _c = node.properties; _b < _c.length; _b++) {
25989                     var p = _c[_b];
25990                     if (p.kind === 281) {
25991                         bindDestructuringTargetFlow(p.initializer);
25992                     }
25993                     else if (p.kind === 282) {
25994                         bindAssignmentTargetFlow(p.name);
25995                     }
25996                     else if (p.kind === 283) {
25997                         bindAssignmentTargetFlow(p.expression);
25998                     }
25999                 }
26000             }
26001         }
26002         function bindLogicalExpression(node, trueTarget, falseTarget) {
26003             var preRightLabel = createBranchLabel();
26004             if (node.operatorToken.kind === 55) {
26005                 bindCondition(node.left, preRightLabel, falseTarget);
26006             }
26007             else {
26008                 bindCondition(node.left, trueTarget, preRightLabel);
26009             }
26010             currentFlow = finishFlowLabel(preRightLabel);
26011             bind(node.operatorToken);
26012             bindCondition(node.right, trueTarget, falseTarget);
26013         }
26014         function bindPrefixUnaryExpressionFlow(node) {
26015             if (node.operator === 53) {
26016                 var saveTrueTarget = currentTrueTarget;
26017                 currentTrueTarget = currentFalseTarget;
26018                 currentFalseTarget = saveTrueTarget;
26019                 bindEachChild(node);
26020                 currentFalseTarget = currentTrueTarget;
26021                 currentTrueTarget = saveTrueTarget;
26022             }
26023             else {
26024                 bindEachChild(node);
26025                 if (node.operator === 45 || node.operator === 46) {
26026                     bindAssignmentTargetFlow(node.operand);
26027                 }
26028             }
26029         }
26030         function bindPostfixUnaryExpressionFlow(node) {
26031             bindEachChild(node);
26032             if (node.operator === 45 || node.operator === 46) {
26033                 bindAssignmentTargetFlow(node.operand);
26034             }
26035         }
26036         function bindBinaryExpressionFlow(node) {
26037             var workStacks = {
26038                 expr: [node],
26039                 state: [1],
26040                 inStrictMode: [undefined],
26041                 parent: [undefined],
26042                 subtreeFlags: [undefined]
26043             };
26044             var stackIndex = 0;
26045             while (stackIndex >= 0) {
26046                 node = workStacks.expr[stackIndex];
26047                 switch (workStacks.state[stackIndex]) {
26048                     case 0: {
26049                         node.parent = parent;
26050                         var saveInStrictMode = inStrictMode;
26051                         bindWorker(node);
26052                         var saveParent = parent;
26053                         parent = node;
26054                         var subtreeFlagsState = void 0;
26055                         if (skipTransformFlagAggregation) {
26056                         }
26057                         else if (node.transformFlags & 536870912) {
26058                             skipTransformFlagAggregation = true;
26059                             subtreeFlagsState = -1;
26060                         }
26061                         else {
26062                             var savedSubtreeTransformFlags = subtreeTransformFlags;
26063                             subtreeTransformFlags = 0;
26064                             subtreeFlagsState = savedSubtreeTransformFlags;
26065                         }
26066                         advanceState(1, saveInStrictMode, saveParent, subtreeFlagsState);
26067                         break;
26068                     }
26069                     case 1: {
26070                         var operator = node.operatorToken.kind;
26071                         if (operator === 55 || operator === 56 || operator === 60) {
26072                             if (isTopLevelLogicalExpression(node)) {
26073                                 var postExpressionLabel = createBranchLabel();
26074                                 bindLogicalExpression(node, postExpressionLabel, postExpressionLabel);
26075                                 currentFlow = finishFlowLabel(postExpressionLabel);
26076                             }
26077                             else {
26078                                 bindLogicalExpression(node, currentTrueTarget, currentFalseTarget);
26079                             }
26080                             completeNode();
26081                         }
26082                         else {
26083                             advanceState(2);
26084                             maybeBind(node.left);
26085                         }
26086                         break;
26087                     }
26088                     case 2: {
26089                         advanceState(3);
26090                         maybeBind(node.operatorToken);
26091                         break;
26092                     }
26093                     case 3: {
26094                         advanceState(4);
26095                         maybeBind(node.right);
26096                         break;
26097                     }
26098                     case 4: {
26099                         var operator = node.operatorToken.kind;
26100                         if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) {
26101                             bindAssignmentTargetFlow(node.left);
26102                             if (operator === 62 && node.left.kind === 195) {
26103                                 var elementAccess = node.left;
26104                                 if (isNarrowableOperand(elementAccess.expression)) {
26105                                     currentFlow = createFlowMutation(256, currentFlow, node);
26106                                 }
26107                             }
26108                         }
26109                         completeNode();
26110                         break;
26111                     }
26112                     default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for bindBinaryExpressionFlow");
26113                 }
26114             }
26115             function advanceState(state, isInStrictMode, parent, subtreeFlags) {
26116                 workStacks.state[stackIndex] = state;
26117                 if (isInStrictMode !== undefined) {
26118                     workStacks.inStrictMode[stackIndex] = isInStrictMode;
26119                 }
26120                 if (parent !== undefined) {
26121                     workStacks.parent[stackIndex] = parent;
26122                 }
26123                 if (subtreeFlags !== undefined) {
26124                     workStacks.subtreeFlags[stackIndex] = subtreeFlags;
26125                 }
26126             }
26127             function completeNode() {
26128                 if (workStacks.inStrictMode[stackIndex] !== undefined) {
26129                     if (workStacks.subtreeFlags[stackIndex] === -1) {
26130                         skipTransformFlagAggregation = false;
26131                         subtreeTransformFlags |= node.transformFlags & ~getTransformFlagsSubtreeExclusions(node.kind);
26132                     }
26133                     else if (workStacks.subtreeFlags[stackIndex] !== undefined) {
26134                         subtreeTransformFlags = workStacks.subtreeFlags[stackIndex] | computeTransformFlagsForNode(node, subtreeTransformFlags);
26135                     }
26136                     inStrictMode = workStacks.inStrictMode[stackIndex];
26137                     parent = workStacks.parent[stackIndex];
26138                 }
26139                 stackIndex--;
26140             }
26141             function maybeBind(node) {
26142                 if (node && ts.isBinaryExpression(node)) {
26143                     stackIndex++;
26144                     workStacks.expr[stackIndex] = node;
26145                     workStacks.state[stackIndex] = 0;
26146                     workStacks.inStrictMode[stackIndex] = undefined;
26147                     workStacks.parent[stackIndex] = undefined;
26148                     workStacks.subtreeFlags[stackIndex] = undefined;
26149                 }
26150                 else {
26151                     bind(node);
26152                 }
26153             }
26154         }
26155         function bindDeleteExpressionFlow(node) {
26156             bindEachChild(node);
26157             if (node.expression.kind === 194) {
26158                 bindAssignmentTargetFlow(node.expression);
26159             }
26160         }
26161         function bindConditionalExpressionFlow(node) {
26162             var trueLabel = createBranchLabel();
26163             var falseLabel = createBranchLabel();
26164             var postExpressionLabel = createBranchLabel();
26165             bindCondition(node.condition, trueLabel, falseLabel);
26166             currentFlow = finishFlowLabel(trueLabel);
26167             bind(node.questionToken);
26168             bind(node.whenTrue);
26169             addAntecedent(postExpressionLabel, currentFlow);
26170             currentFlow = finishFlowLabel(falseLabel);
26171             bind(node.colonToken);
26172             bind(node.whenFalse);
26173             addAntecedent(postExpressionLabel, currentFlow);
26174             currentFlow = finishFlowLabel(postExpressionLabel);
26175         }
26176         function bindInitializedVariableFlow(node) {
26177             var name = !ts.isOmittedExpression(node) ? node.name : undefined;
26178             if (ts.isBindingPattern(name)) {
26179                 for (var _i = 0, _a = name.elements; _i < _a.length; _i++) {
26180                     var child = _a[_i];
26181                     bindInitializedVariableFlow(child);
26182                 }
26183             }
26184             else {
26185                 currentFlow = createFlowMutation(16, currentFlow, node);
26186             }
26187         }
26188         function bindVariableDeclarationFlow(node) {
26189             bindEachChild(node);
26190             if (node.initializer || ts.isForInOrOfStatement(node.parent.parent)) {
26191                 bindInitializedVariableFlow(node);
26192             }
26193         }
26194         function bindJSDocTypeAlias(node) {
26195             node.tagName.parent = node;
26196             if (node.kind !== 316 && node.fullName) {
26197                 setParentPointers(node, node.fullName);
26198             }
26199         }
26200         function bindJSDocClassTag(node) {
26201             bindEachChild(node);
26202             var host = ts.getHostSignatureFromJSDoc(node);
26203             if (host && host.kind !== 161) {
26204                 addDeclarationToSymbol(host.symbol, host, 32);
26205             }
26206         }
26207         function bindOptionalExpression(node, trueTarget, falseTarget) {
26208             doWithConditionalBranches(bind, node, trueTarget, falseTarget);
26209             if (!ts.isOptionalChain(node) || ts.isOutermostOptionalChain(node)) {
26210                 addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node));
26211                 addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node));
26212             }
26213         }
26214         function bindOptionalChainRest(node) {
26215             switch (node.kind) {
26216                 case 194:
26217                     bind(node.questionDotToken);
26218                     bind(node.name);
26219                     break;
26220                 case 195:
26221                     bind(node.questionDotToken);
26222                     bind(node.argumentExpression);
26223                     break;
26224                 case 196:
26225                     bind(node.questionDotToken);
26226                     bindEach(node.typeArguments);
26227                     bindEach(node.arguments);
26228                     break;
26229             }
26230         }
26231         function bindOptionalChain(node, trueTarget, falseTarget) {
26232             var preChainLabel = ts.isOptionalChainRoot(node) ? createBranchLabel() : undefined;
26233             bindOptionalExpression(node.expression, preChainLabel || trueTarget, falseTarget);
26234             if (preChainLabel) {
26235                 currentFlow = finishFlowLabel(preChainLabel);
26236             }
26237             doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget);
26238             if (ts.isOutermostOptionalChain(node)) {
26239                 addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node));
26240                 addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node));
26241             }
26242         }
26243         function bindOptionalChainFlow(node) {
26244             if (isTopLevelLogicalExpression(node)) {
26245                 var postExpressionLabel = createBranchLabel();
26246                 bindOptionalChain(node, postExpressionLabel, postExpressionLabel);
26247                 currentFlow = finishFlowLabel(postExpressionLabel);
26248             }
26249             else {
26250                 bindOptionalChain(node, currentTrueTarget, currentFalseTarget);
26251             }
26252         }
26253         function bindNonNullExpressionFlow(node) {
26254             if (ts.isOptionalChain(node)) {
26255                 bindOptionalChainFlow(node);
26256             }
26257             else {
26258                 bindEachChild(node);
26259             }
26260         }
26261         function bindAccessExpressionFlow(node) {
26262             if (ts.isOptionalChain(node)) {
26263                 bindOptionalChainFlow(node);
26264             }
26265             else {
26266                 bindEachChild(node);
26267             }
26268         }
26269         function bindCallExpressionFlow(node) {
26270             if (ts.isOptionalChain(node)) {
26271                 bindOptionalChainFlow(node);
26272             }
26273             else {
26274                 var expr = ts.skipParentheses(node.expression);
26275                 if (expr.kind === 201 || expr.kind === 202) {
26276                     bindEach(node.typeArguments);
26277                     bindEach(node.arguments);
26278                     bind(node.expression);
26279                 }
26280                 else {
26281                     bindEachChild(node);
26282                 }
26283             }
26284             if (node.expression.kind === 194) {
26285                 var propertyAccess = node.expression;
26286                 if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) {
26287                     currentFlow = createFlowMutation(256, currentFlow, node);
26288                 }
26289             }
26290         }
26291         function getContainerFlags(node) {
26292             switch (node.kind) {
26293                 case 214:
26294                 case 245:
26295                 case 248:
26296                 case 193:
26297                 case 173:
26298                 case 304:
26299                 case 274:
26300                     return 1;
26301                 case 246:
26302                     return 1 | 64;
26303                 case 249:
26304                 case 247:
26305                 case 186:
26306                     return 1 | 32;
26307                 case 290:
26308                     return 1 | 4 | 32;
26309                 case 161:
26310                     if (ts.isObjectLiteralOrClassExpressionMethod(node)) {
26311                         return 1 | 4 | 32 | 8 | 128;
26312                     }
26313                 case 162:
26314                 case 244:
26315                 case 160:
26316                 case 163:
26317                 case 164:
26318                 case 165:
26319                 case 305:
26320                 case 300:
26321                 case 170:
26322                 case 166:
26323                 case 167:
26324                 case 171:
26325                     return 1 | 4 | 32 | 8;
26326                 case 201:
26327                 case 202:
26328                     return 1 | 4 | 32 | 8 | 16;
26329                 case 250:
26330                     return 4;
26331                 case 159:
26332                     return node.initializer ? 4 : 0;
26333                 case 280:
26334                 case 230:
26335                 case 231:
26336                 case 232:
26337                 case 251:
26338                     return 2;
26339                 case 223:
26340                     return ts.isFunctionLike(node.parent) ? 0 : 2;
26341             }
26342             return 0;
26343         }
26344         function addToContainerChain(next) {
26345             if (lastContainer) {
26346                 lastContainer.nextContainer = next;
26347             }
26348             lastContainer = next;
26349         }
26350         function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) {
26351             switch (container.kind) {
26352                 case 249:
26353                     return declareModuleMember(node, symbolFlags, symbolExcludes);
26354                 case 290:
26355                     return declareSourceFileMember(node, symbolFlags, symbolExcludes);
26356                 case 214:
26357                 case 245:
26358                     return declareClassMember(node, symbolFlags, symbolExcludes);
26359                 case 248:
26360                     return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
26361                 case 173:
26362                 case 304:
26363                 case 193:
26364                 case 246:
26365                 case 274:
26366                     return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes);
26367                 case 170:
26368                 case 171:
26369                 case 165:
26370                 case 166:
26371                 case 305:
26372                 case 167:
26373                 case 161:
26374                 case 160:
26375                 case 162:
26376                 case 163:
26377                 case 164:
26378                 case 244:
26379                 case 201:
26380                 case 202:
26381                 case 300:
26382                 case 322:
26383                 case 315:
26384                 case 247:
26385                 case 186:
26386                     return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes);
26387             }
26388         }
26389         function declareClassMember(node, symbolFlags, symbolExcludes) {
26390             return ts.hasModifier(node, 32)
26391                 ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes)
26392                 : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes);
26393         }
26394         function declareSourceFileMember(node, symbolFlags, symbolExcludes) {
26395             return ts.isExternalModule(file)
26396                 ? declareModuleMember(node, symbolFlags, symbolExcludes)
26397                 : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes);
26398         }
26399         function hasExportDeclarations(node) {
26400             var body = ts.isSourceFile(node) ? node : ts.tryCast(node.body, ts.isModuleBlock);
26401             return !!body && body.statements.some(function (s) { return ts.isExportDeclaration(s) || ts.isExportAssignment(s); });
26402         }
26403         function setExportContextFlag(node) {
26404             if (node.flags & 8388608 && !hasExportDeclarations(node)) {
26405                 node.flags |= 64;
26406             }
26407             else {
26408                 node.flags &= ~64;
26409             }
26410         }
26411         function bindModuleDeclaration(node) {
26412             setExportContextFlag(node);
26413             if (ts.isAmbientModule(node)) {
26414                 if (ts.hasModifier(node, 1)) {
26415                     errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible);
26416                 }
26417                 if (ts.isModuleAugmentationExternal(node)) {
26418                     declareModuleSymbol(node);
26419                 }
26420                 else {
26421                     var pattern = void 0;
26422                     if (node.name.kind === 10) {
26423                         var text = node.name.text;
26424                         if (ts.hasZeroOrOneAsteriskCharacter(text)) {
26425                             pattern = ts.tryParsePattern(text);
26426                         }
26427                         else {
26428                             errorOnFirstToken(node.name, ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, text);
26429                         }
26430                     }
26431                     var symbol = declareSymbolAndAddToSymbolTable(node, 512, 110735);
26432                     file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && { pattern: pattern, symbol: symbol });
26433                 }
26434             }
26435             else {
26436                 var state = declareModuleSymbol(node);
26437                 if (state !== 0) {
26438                     var symbol = node.symbol;
26439                     symbol.constEnumOnlyModule = (!(symbol.flags & (16 | 32 | 256)))
26440                         && state === 2
26441                         && symbol.constEnumOnlyModule !== false;
26442                 }
26443             }
26444         }
26445         function declareModuleSymbol(node) {
26446             var state = getModuleInstanceState(node);
26447             var instantiated = state !== 0;
26448             declareSymbolAndAddToSymbolTable(node, instantiated ? 512 : 1024, instantiated ? 110735 : 0);
26449             return state;
26450         }
26451         function bindFunctionOrConstructorType(node) {
26452             var symbol = createSymbol(131072, getDeclarationName(node));
26453             addDeclarationToSymbol(symbol, node, 131072);
26454             var typeLiteralSymbol = createSymbol(2048, "__type");
26455             addDeclarationToSymbol(typeLiteralSymbol, node, 2048);
26456             typeLiteralSymbol.members = ts.createSymbolTable();
26457             typeLiteralSymbol.members.set(symbol.escapedName, symbol);
26458         }
26459         function bindObjectLiteralExpression(node) {
26460             if (inStrictMode && !ts.isAssignmentTarget(node)) {
26461                 var seen = ts.createUnderscoreEscapedMap();
26462                 for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
26463                     var prop = _a[_i];
26464                     if (prop.kind === 283 || prop.name.kind !== 75) {
26465                         continue;
26466                     }
26467                     var identifier = prop.name;
26468                     var currentKind = prop.kind === 281 || prop.kind === 282 || prop.kind === 161
26469                         ? 1
26470                         : 2;
26471                     var existingKind = seen.get(identifier.escapedText);
26472                     if (!existingKind) {
26473                         seen.set(identifier.escapedText, currentKind);
26474                         continue;
26475                     }
26476                     if (currentKind === 1 && existingKind === 1) {
26477                         var span = ts.getErrorSpanForNode(file, identifier);
26478                         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));
26479                     }
26480                 }
26481             }
26482             return bindAnonymousDeclaration(node, 4096, "__object");
26483         }
26484         function bindJsxAttributes(node) {
26485             return bindAnonymousDeclaration(node, 4096, "__jsxAttributes");
26486         }
26487         function bindJsxAttribute(node, symbolFlags, symbolExcludes) {
26488             return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
26489         }
26490         function bindAnonymousDeclaration(node, symbolFlags, name) {
26491             var symbol = createSymbol(symbolFlags, name);
26492             if (symbolFlags & (8 | 106500)) {
26493                 symbol.parent = container.symbol;
26494             }
26495             addDeclarationToSymbol(symbol, node, symbolFlags);
26496             return symbol;
26497         }
26498         function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) {
26499             switch (blockScopeContainer.kind) {
26500                 case 249:
26501                     declareModuleMember(node, symbolFlags, symbolExcludes);
26502                     break;
26503                 case 290:
26504                     if (ts.isExternalOrCommonJsModule(container)) {
26505                         declareModuleMember(node, symbolFlags, symbolExcludes);
26506                         break;
26507                     }
26508                 default:
26509                     if (!blockScopeContainer.locals) {
26510                         blockScopeContainer.locals = ts.createSymbolTable();
26511                         addToContainerChain(blockScopeContainer);
26512                     }
26513                     declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes);
26514             }
26515         }
26516         function delayedBindJSDocTypedefTag() {
26517             if (!delayedTypeAliases) {
26518                 return;
26519             }
26520             var saveContainer = container;
26521             var saveLastContainer = lastContainer;
26522             var saveBlockScopeContainer = blockScopeContainer;
26523             var saveParent = parent;
26524             var saveCurrentFlow = currentFlow;
26525             for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) {
26526                 var typeAlias = delayedTypeAliases_1[_i];
26527                 var host = ts.getJSDocHost(typeAlias);
26528                 container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1); }) || file;
26529                 blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file;
26530                 currentFlow = initFlowNode({ flags: 2 });
26531                 parent = typeAlias;
26532                 bind(typeAlias.typeExpression);
26533                 var declName = ts.getNameOfDeclaration(typeAlias);
26534                 if ((ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName) && declName && ts.isPropertyAccessEntityNameExpression(declName.parent)) {
26535                     var isTopLevel = isTopLevelNamespaceAssignment(declName.parent);
26536                     if (isTopLevel) {
26537                         bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), false);
26538                         var oldContainer = container;
26539                         switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) {
26540                             case 1:
26541                             case 2:
26542                                 if (!ts.isExternalOrCommonJsModule(file)) {
26543                                     container = undefined;
26544                                 }
26545                                 else {
26546                                     container = file;
26547                                 }
26548                                 break;
26549                             case 4:
26550                                 container = declName.parent.expression;
26551                                 break;
26552                             case 3:
26553                                 container = declName.parent.expression.name;
26554                                 break;
26555                             case 5:
26556                                 container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file
26557                                     : ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name
26558                                         : declName.parent.expression;
26559                                 break;
26560                             case 0:
26561                                 return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration");
26562                         }
26563                         if (container) {
26564                             declareModuleMember(typeAlias, 524288, 788968);
26565                         }
26566                         container = oldContainer;
26567                     }
26568                 }
26569                 else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 75) {
26570                     parent = typeAlias.parent;
26571                     bindBlockScopedDeclaration(typeAlias, 524288, 788968);
26572                 }
26573                 else {
26574                     bind(typeAlias.fullName);
26575                 }
26576             }
26577             container = saveContainer;
26578             lastContainer = saveLastContainer;
26579             blockScopeContainer = saveBlockScopeContainer;
26580             parent = saveParent;
26581             currentFlow = saveCurrentFlow;
26582         }
26583         function checkStrictModeIdentifier(node) {
26584             if (inStrictMode &&
26585                 node.originalKeywordKind >= 113 &&
26586                 node.originalKeywordKind <= 121 &&
26587                 !ts.isIdentifierName(node) &&
26588                 !(node.flags & 8388608) &&
26589                 !(node.flags & 4194304)) {
26590                 if (!file.parseDiagnostics.length) {
26591                     file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node)));
26592                 }
26593             }
26594         }
26595         function getStrictModeIdentifierMessage(node) {
26596             if (ts.getContainingClass(node)) {
26597                 return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode;
26598             }
26599             if (file.externalModuleIndicator) {
26600                 return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode;
26601             }
26602             return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode;
26603         }
26604         function checkPrivateIdentifier(node) {
26605             if (node.escapedText === "#constructor") {
26606                 if (!file.parseDiagnostics.length) {
26607                     file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.constructor_is_a_reserved_word, ts.declarationNameToString(node)));
26608                 }
26609             }
26610         }
26611         function checkStrictModeBinaryExpression(node) {
26612             if (inStrictMode && ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) {
26613                 checkStrictModeEvalOrArguments(node, node.left);
26614             }
26615         }
26616         function checkStrictModeCatchClause(node) {
26617             if (inStrictMode && node.variableDeclaration) {
26618                 checkStrictModeEvalOrArguments(node, node.variableDeclaration.name);
26619             }
26620         }
26621         function checkStrictModeDeleteExpression(node) {
26622             if (inStrictMode && node.expression.kind === 75) {
26623                 var span = ts.getErrorSpanForNode(file, node.expression);
26624                 file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode));
26625             }
26626         }
26627         function isEvalOrArgumentsIdentifier(node) {
26628             return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments");
26629         }
26630         function checkStrictModeEvalOrArguments(contextNode, name) {
26631             if (name && name.kind === 75) {
26632                 var identifier = name;
26633                 if (isEvalOrArgumentsIdentifier(identifier)) {
26634                     var span = ts.getErrorSpanForNode(file, name);
26635                     file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, getStrictModeEvalOrArgumentsMessage(contextNode), ts.idText(identifier)));
26636                 }
26637             }
26638         }
26639         function getStrictModeEvalOrArgumentsMessage(node) {
26640             if (ts.getContainingClass(node)) {
26641                 return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode;
26642             }
26643             if (file.externalModuleIndicator) {
26644                 return ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode;
26645             }
26646             return ts.Diagnostics.Invalid_use_of_0_in_strict_mode;
26647         }
26648         function checkStrictModeFunctionName(node) {
26649             if (inStrictMode) {
26650                 checkStrictModeEvalOrArguments(node, node.name);
26651             }
26652         }
26653         function getStrictModeBlockScopeFunctionDeclarationMessage(node) {
26654             if (ts.getContainingClass(node)) {
26655                 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;
26656             }
26657             if (file.externalModuleIndicator) {
26658                 return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode;
26659             }
26660             return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5;
26661         }
26662         function checkStrictModeFunctionDeclaration(node) {
26663             if (languageVersion < 2) {
26664                 if (blockScopeContainer.kind !== 290 &&
26665                     blockScopeContainer.kind !== 249 &&
26666                     !ts.isFunctionLike(blockScopeContainer)) {
26667                     var errorSpan = ts.getErrorSpanForNode(file, node);
26668                     file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node)));
26669                 }
26670             }
26671         }
26672         function checkStrictModeNumericLiteral(node) {
26673             if (inStrictMode && node.numericLiteralFlags & 32) {
26674                 file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode));
26675             }
26676         }
26677         function checkStrictModePostfixUnaryExpression(node) {
26678             if (inStrictMode) {
26679                 checkStrictModeEvalOrArguments(node, node.operand);
26680             }
26681         }
26682         function checkStrictModePrefixUnaryExpression(node) {
26683             if (inStrictMode) {
26684                 if (node.operator === 45 || node.operator === 46) {
26685                     checkStrictModeEvalOrArguments(node, node.operand);
26686                 }
26687             }
26688         }
26689         function checkStrictModeWithStatement(node) {
26690             if (inStrictMode) {
26691                 errorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode);
26692             }
26693         }
26694         function checkStrictModeLabeledStatement(node) {
26695             if (inStrictMode && options.target >= 2) {
26696                 if (ts.isDeclarationStatement(node.statement) || ts.isVariableStatement(node.statement)) {
26697                     errorOnFirstToken(node.label, ts.Diagnostics.A_label_is_not_allowed_here);
26698                 }
26699             }
26700         }
26701         function errorOnFirstToken(node, message, arg0, arg1, arg2) {
26702             var span = ts.getSpanOfTokenAtPosition(file, node.pos);
26703             file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2));
26704         }
26705         function errorOrSuggestionOnNode(isError, node, message) {
26706             errorOrSuggestionOnRange(isError, node, node, message);
26707         }
26708         function errorOrSuggestionOnRange(isError, startNode, endNode, message) {
26709             addErrorOrSuggestionDiagnostic(isError, { pos: ts.getTokenPosOfNode(startNode, file), end: endNode.end }, message);
26710         }
26711         function addErrorOrSuggestionDiagnostic(isError, range, message) {
26712             var diag = ts.createFileDiagnostic(file, range.pos, range.end - range.pos, message);
26713             if (isError) {
26714                 file.bindDiagnostics.push(diag);
26715             }
26716             else {
26717                 file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion }));
26718             }
26719         }
26720         function bind(node) {
26721             if (!node) {
26722                 return;
26723             }
26724             node.parent = parent;
26725             var saveInStrictMode = inStrictMode;
26726             bindWorker(node);
26727             if (node.kind > 152) {
26728                 var saveParent = parent;
26729                 parent = node;
26730                 var containerFlags = getContainerFlags(node);
26731                 if (containerFlags === 0) {
26732                     bindChildren(node);
26733                 }
26734                 else {
26735                     bindContainer(node, containerFlags);
26736                 }
26737                 parent = saveParent;
26738             }
26739             else if (!skipTransformFlagAggregation && (node.transformFlags & 536870912) === 0) {
26740                 subtreeTransformFlags |= computeTransformFlagsForNode(node, 0);
26741                 var saveParent = parent;
26742                 if (node.kind === 1)
26743                     parent = node;
26744                 bindJSDoc(node);
26745                 parent = saveParent;
26746             }
26747             inStrictMode = saveInStrictMode;
26748         }
26749         function bindJSDoc(node) {
26750             if (ts.hasJSDocNodes(node)) {
26751                 if (ts.isInJSFile(node)) {
26752                     for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
26753                         var j = _a[_i];
26754                         bind(j);
26755                     }
26756                 }
26757                 else {
26758                     for (var _b = 0, _c = node.jsDoc; _b < _c.length; _b++) {
26759                         var j = _c[_b];
26760                         setParentPointers(node, j);
26761                     }
26762                 }
26763             }
26764         }
26765         function updateStrictModeStatementList(statements) {
26766             if (!inStrictMode) {
26767                 for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) {
26768                     var statement = statements_2[_i];
26769                     if (!ts.isPrologueDirective(statement)) {
26770                         return;
26771                     }
26772                     if (isUseStrictPrologueDirective(statement)) {
26773                         inStrictMode = true;
26774                         return;
26775                     }
26776                 }
26777             }
26778         }
26779         function isUseStrictPrologueDirective(node) {
26780             var nodeText = ts.getSourceTextOfNodeFromSourceFile(file, node.expression);
26781             return nodeText === '"use strict"' || nodeText === "'use strict'";
26782         }
26783         function bindWorker(node) {
26784             switch (node.kind) {
26785                 case 75:
26786                     if (node.isInJSDocNamespace) {
26787                         var parentNode = node.parent;
26788                         while (parentNode && !ts.isJSDocTypeAlias(parentNode)) {
26789                             parentNode = parentNode.parent;
26790                         }
26791                         bindBlockScopedDeclaration(parentNode, 524288, 788968);
26792                         break;
26793                     }
26794                 case 104:
26795                     if (currentFlow && (ts.isExpression(node) || parent.kind === 282)) {
26796                         node.flowNode = currentFlow;
26797                     }
26798                     return checkStrictModeIdentifier(node);
26799                 case 76:
26800                     return checkPrivateIdentifier(node);
26801                 case 194:
26802                 case 195:
26803                     var expr = node;
26804                     if (currentFlow && isNarrowableReference(expr)) {
26805                         expr.flowNode = currentFlow;
26806                     }
26807                     if (ts.isSpecialPropertyDeclaration(expr)) {
26808                         bindSpecialPropertyDeclaration(expr);
26809                     }
26810                     if (ts.isInJSFile(expr) &&
26811                         file.commonJsModuleIndicator &&
26812                         ts.isModuleExportsAccessExpression(expr) &&
26813                         !lookupSymbolForNameWorker(blockScopeContainer, "module")) {
26814                         declareSymbol(file.locals, undefined, expr.expression, 1 | 134217728, 111550);
26815                     }
26816                     break;
26817                 case 209:
26818                     var specialKind = ts.getAssignmentDeclarationKind(node);
26819                     switch (specialKind) {
26820                         case 1:
26821                             bindExportsPropertyAssignment(node);
26822                             break;
26823                         case 2:
26824                             bindModuleExportsAssignment(node);
26825                             break;
26826                         case 3:
26827                             bindPrototypePropertyAssignment(node.left, node);
26828                             break;
26829                         case 6:
26830                             bindPrototypeAssignment(node);
26831                             break;
26832                         case 4:
26833                             bindThisPropertyAssignment(node);
26834                             break;
26835                         case 5:
26836                             bindSpecialPropertyAssignment(node);
26837                             break;
26838                         case 0:
26839                             break;
26840                         default:
26841                             ts.Debug.fail("Unknown binary expression special property assignment kind");
26842                     }
26843                     return checkStrictModeBinaryExpression(node);
26844                 case 280:
26845                     return checkStrictModeCatchClause(node);
26846                 case 203:
26847                     return checkStrictModeDeleteExpression(node);
26848                 case 8:
26849                     return checkStrictModeNumericLiteral(node);
26850                 case 208:
26851                     return checkStrictModePostfixUnaryExpression(node);
26852                 case 207:
26853                     return checkStrictModePrefixUnaryExpression(node);
26854                 case 236:
26855                     return checkStrictModeWithStatement(node);
26856                 case 238:
26857                     return checkStrictModeLabeledStatement(node);
26858                 case 183:
26859                     seenThisKeyword = true;
26860                     return;
26861                 case 168:
26862                     break;
26863                 case 155:
26864                     return bindTypeParameter(node);
26865                 case 156:
26866                     return bindParameter(node);
26867                 case 242:
26868                     return bindVariableDeclarationOrBindingElement(node);
26869                 case 191:
26870                     node.flowNode = currentFlow;
26871                     return bindVariableDeclarationOrBindingElement(node);
26872                 case 159:
26873                 case 158:
26874                     return bindPropertyWorker(node);
26875                 case 281:
26876                 case 282:
26877                     return bindPropertyOrMethodOrAccessor(node, 4, 0);
26878                 case 284:
26879                     return bindPropertyOrMethodOrAccessor(node, 8, 900095);
26880                 case 165:
26881                 case 166:
26882                 case 167:
26883                     return declareSymbolAndAddToSymbolTable(node, 131072, 0);
26884                 case 161:
26885                 case 160:
26886                     return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 16777216 : 0), ts.isObjectLiteralMethod(node) ? 0 : 103359);
26887                 case 244:
26888                     return bindFunctionDeclaration(node);
26889                 case 162:
26890                     return declareSymbolAndAddToSymbolTable(node, 16384, 0);
26891                 case 163:
26892                     return bindPropertyOrMethodOrAccessor(node, 32768, 46015);
26893                 case 164:
26894                     return bindPropertyOrMethodOrAccessor(node, 65536, 78783);
26895                 case 170:
26896                 case 300:
26897                 case 305:
26898                 case 171:
26899                     return bindFunctionOrConstructorType(node);
26900                 case 173:
26901                 case 304:
26902                 case 186:
26903                     return bindAnonymousTypeWorker(node);
26904                 case 310:
26905                     return bindJSDocClassTag(node);
26906                 case 193:
26907                     return bindObjectLiteralExpression(node);
26908                 case 201:
26909                 case 202:
26910                     return bindFunctionExpression(node);
26911                 case 196:
26912                     var assignmentKind = ts.getAssignmentDeclarationKind(node);
26913                     switch (assignmentKind) {
26914                         case 7:
26915                             return bindObjectDefinePropertyAssignment(node);
26916                         case 8:
26917                             return bindObjectDefinePropertyExport(node);
26918                         case 9:
26919                             return bindObjectDefinePrototypeProperty(node);
26920                         case 0:
26921                             break;
26922                         default:
26923                             return ts.Debug.fail("Unknown call expression assignment declaration kind");
26924                     }
26925                     if (ts.isInJSFile(node)) {
26926                         bindCallExpression(node);
26927                     }
26928                     break;
26929                 case 214:
26930                 case 245:
26931                     inStrictMode = true;
26932                     return bindClassLikeDeclaration(node);
26933                 case 246:
26934                     return bindBlockScopedDeclaration(node, 64, 788872);
26935                 case 247:
26936                     return bindBlockScopedDeclaration(node, 524288, 788968);
26937                 case 248:
26938                     return bindEnumDeclaration(node);
26939                 case 249:
26940                     return bindModuleDeclaration(node);
26941                 case 274:
26942                     return bindJsxAttributes(node);
26943                 case 273:
26944                     return bindJsxAttribute(node, 4, 0);
26945                 case 253:
26946                 case 256:
26947                 case 258:
26948                 case 263:
26949                     return declareSymbolAndAddToSymbolTable(node, 2097152, 2097152);
26950                 case 252:
26951                     return bindNamespaceExportDeclaration(node);
26952                 case 255:
26953                     return bindImportClause(node);
26954                 case 260:
26955                     return bindExportDeclaration(node);
26956                 case 259:
26957                     return bindExportAssignment(node);
26958                 case 290:
26959                     updateStrictModeStatementList(node.statements);
26960                     return bindSourceFileIfExternalModule();
26961                 case 223:
26962                     if (!ts.isFunctionLike(node.parent)) {
26963                         return;
26964                     }
26965                 case 250:
26966                     return updateStrictModeStatementList(node.statements);
26967                 case 317:
26968                     if (node.parent.kind === 305) {
26969                         return bindParameter(node);
26970                     }
26971                     if (node.parent.kind !== 304) {
26972                         break;
26973                     }
26974                 case 323:
26975                     var propTag = node;
26976                     var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 299 ?
26977                         4 | 16777216 :
26978                         4;
26979                     return declareSymbolAndAddToSymbolTable(propTag, flags, 0);
26980                 case 322:
26981                 case 315:
26982                 case 316:
26983                     return (delayedTypeAliases || (delayedTypeAliases = [])).push(node);
26984             }
26985         }
26986         function bindPropertyWorker(node) {
26987             return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 16777216 : 0), 0);
26988         }
26989         function bindAnonymousTypeWorker(node) {
26990             return bindAnonymousDeclaration(node, 2048, "__type");
26991         }
26992         function bindSourceFileIfExternalModule() {
26993             setExportContextFlag(file);
26994             if (ts.isExternalModule(file)) {
26995                 bindSourceFileAsExternalModule();
26996             }
26997             else if (ts.isJsonSourceFile(file)) {
26998                 bindSourceFileAsExternalModule();
26999                 var originalSymbol = file.symbol;
27000                 declareSymbol(file.symbol.exports, file.symbol, file, 4, 67108863);
27001                 file.symbol = originalSymbol;
27002             }
27003         }
27004         function bindSourceFileAsExternalModule() {
27005             bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\"");
27006         }
27007         function bindExportAssignment(node) {
27008             if (!container.symbol || !container.symbol.exports) {
27009                 bindAnonymousDeclaration(node, 2097152, getDeclarationName(node));
27010             }
27011             else {
27012                 var flags = ts.exportAssignmentIsAlias(node)
27013                     ? 2097152
27014                     : 4;
27015                 var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863);
27016                 if (node.isExportEquals) {
27017                     ts.setValueDeclaration(symbol, node);
27018                 }
27019             }
27020         }
27021         function bindNamespaceExportDeclaration(node) {
27022             if (node.modifiers && node.modifiers.length) {
27023                 file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here));
27024             }
27025             var diag = !ts.isSourceFile(node.parent) ? ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level
27026                 : !ts.isExternalModule(node.parent) ? ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files
27027                     : !node.parent.isDeclarationFile ? ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files
27028                         : undefined;
27029             if (diag) {
27030                 file.bindDiagnostics.push(createDiagnosticForNode(node, diag));
27031             }
27032             else {
27033                 file.symbol.globalExports = file.symbol.globalExports || ts.createSymbolTable();
27034                 declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152, 2097152);
27035             }
27036         }
27037         function bindExportDeclaration(node) {
27038             if (!container.symbol || !container.symbol.exports) {
27039                 bindAnonymousDeclaration(node, 8388608, getDeclarationName(node));
27040             }
27041             else if (!node.exportClause) {
27042                 declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 0);
27043             }
27044             else if (ts.isNamespaceExport(node.exportClause)) {
27045                 node.exportClause.parent = node;
27046                 declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152, 2097152);
27047             }
27048         }
27049         function bindImportClause(node) {
27050             if (node.name) {
27051                 declareSymbolAndAddToSymbolTable(node, 2097152, 2097152);
27052             }
27053         }
27054         function setCommonJsModuleIndicator(node) {
27055             if (file.externalModuleIndicator) {
27056                 return false;
27057             }
27058             if (!file.commonJsModuleIndicator) {
27059                 file.commonJsModuleIndicator = node;
27060                 bindSourceFileAsExternalModule();
27061             }
27062             return true;
27063         }
27064         function bindObjectDefinePropertyExport(node) {
27065             if (!setCommonJsModuleIndicator(node)) {
27066                 return;
27067             }
27068             var symbol = forEachIdentifierInEntityName(node.arguments[0], undefined, function (id, symbol) {
27069                 if (symbol) {
27070                     addDeclarationToSymbol(symbol, id, 1536 | 67108864);
27071                 }
27072                 return symbol;
27073             });
27074             if (symbol) {
27075                 var flags = 4 | 1048576;
27076                 declareSymbol(symbol.exports, symbol, node, flags, 0);
27077             }
27078         }
27079         function bindExportsPropertyAssignment(node) {
27080             if (!setCommonJsModuleIndicator(node)) {
27081                 return;
27082             }
27083             var symbol = forEachIdentifierInEntityName(node.left.expression, undefined, function (id, symbol) {
27084                 if (symbol) {
27085                     addDeclarationToSymbol(symbol, id, 1536 | 67108864);
27086                 }
27087                 return symbol;
27088             });
27089             if (symbol) {
27090                 var flags = ts.isClassExpression(node.right) ?
27091                     4 | 1048576 | 32 :
27092                     4 | 1048576;
27093                 declareSymbol(symbol.exports, symbol, node.left, flags, 0);
27094             }
27095         }
27096         function bindModuleExportsAssignment(node) {
27097             if (!setCommonJsModuleIndicator(node)) {
27098                 return;
27099             }
27100             var assignedExpression = ts.getRightMostAssignedExpression(node.right);
27101             if (ts.isEmptyObjectLiteral(assignedExpression) || container === file && isExportsOrModuleExportsOrAlias(file, assignedExpression)) {
27102                 return;
27103             }
27104             var flags = ts.exportAssignmentIsAlias(node)
27105                 ? 2097152
27106                 : 4 | 1048576 | 512;
27107             var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864, 0);
27108             ts.setValueDeclaration(symbol, node);
27109         }
27110         function bindThisPropertyAssignment(node) {
27111             ts.Debug.assert(ts.isInJSFile(node));
27112             var hasPrivateIdentifier = (ts.isBinaryExpression(node) && ts.isPropertyAccessExpression(node.left) && ts.isPrivateIdentifier(node.left.name))
27113                 || (ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name));
27114             if (hasPrivateIdentifier) {
27115                 return;
27116             }
27117             var thisContainer = ts.getThisContainer(node, false);
27118             switch (thisContainer.kind) {
27119                 case 244:
27120                 case 201:
27121                     var constructorSymbol = thisContainer.symbol;
27122                     if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 62) {
27123                         var l = thisContainer.parent.left;
27124                         if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) {
27125                             constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer);
27126                         }
27127                     }
27128                     if (constructorSymbol && constructorSymbol.valueDeclaration) {
27129                         constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable();
27130                         if (ts.hasDynamicName(node)) {
27131                             bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol);
27132                         }
27133                         else {
27134                             declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 | 67108864, 0 & ~4);
27135                         }
27136                         addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32);
27137                     }
27138                     break;
27139                 case 162:
27140                 case 159:
27141                 case 161:
27142                 case 163:
27143                 case 164:
27144                     var containingClass = thisContainer.parent;
27145                     var symbolTable = ts.hasModifier(thisContainer, 32) ? containingClass.symbol.exports : containingClass.symbol.members;
27146                     if (ts.hasDynamicName(node)) {
27147                         bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol);
27148                     }
27149                     else {
27150                         declareSymbol(symbolTable, containingClass.symbol, node, 4 | 67108864, 0, true);
27151                     }
27152                     break;
27153                 case 290:
27154                     if (ts.hasDynamicName(node)) {
27155                         break;
27156                     }
27157                     else if (thisContainer.commonJsModuleIndicator) {
27158                         declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 | 1048576, 0);
27159                     }
27160                     else {
27161                         declareSymbolAndAddToSymbolTable(node, 1, 111550);
27162                     }
27163                     break;
27164                 default:
27165                     ts.Debug.failBadSyntaxKind(thisContainer);
27166             }
27167         }
27168         function bindDynamicallyNamedThisPropertyAssignment(node, symbol) {
27169             bindAnonymousDeclaration(node, 4, "__computed");
27170             addLateBoundAssignmentDeclarationToSymbol(node, symbol);
27171         }
27172         function addLateBoundAssignmentDeclarationToSymbol(node, symbol) {
27173             if (symbol) {
27174                 var members = symbol.assignmentDeclarationMembers || (symbol.assignmentDeclarationMembers = ts.createMap());
27175                 members.set("" + ts.getNodeId(node), node);
27176             }
27177         }
27178         function bindSpecialPropertyDeclaration(node) {
27179             if (node.expression.kind === 104) {
27180                 bindThisPropertyAssignment(node);
27181             }
27182             else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 290) {
27183                 if (ts.isPrototypeAccess(node.expression)) {
27184                     bindPrototypePropertyAssignment(node, node.parent);
27185                 }
27186                 else {
27187                     bindStaticPropertyAssignment(node);
27188                 }
27189             }
27190         }
27191         function bindPrototypeAssignment(node) {
27192             node.left.parent = node;
27193             node.right.parent = node;
27194             bindPropertyAssignment(node.left.expression, node.left, false, true);
27195         }
27196         function bindObjectDefinePrototypeProperty(node) {
27197             var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression);
27198             if (namespaceSymbol && namespaceSymbol.valueDeclaration) {
27199                 addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32);
27200             }
27201             bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, true);
27202         }
27203         function bindPrototypePropertyAssignment(lhs, parent) {
27204             var classPrototype = lhs.expression;
27205             var constructorFunction = classPrototype.expression;
27206             lhs.parent = parent;
27207             constructorFunction.parent = classPrototype;
27208             classPrototype.parent = lhs;
27209             bindPropertyAssignment(constructorFunction, lhs, true, true);
27210         }
27211         function bindObjectDefinePropertyAssignment(node) {
27212             var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]);
27213             var isToplevel = node.parent.parent.kind === 290;
27214             namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, false, false);
27215             bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, false);
27216         }
27217         function bindSpecialPropertyAssignment(node) {
27218             var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression);
27219             if (!ts.isInJSFile(node) && !ts.isFunctionSymbol(parentSymbol)) {
27220                 return;
27221             }
27222             node.left.parent = node;
27223             node.right.parent = node;
27224             if (ts.isIdentifier(node.left.expression) && container === file && isExportsOrModuleExportsOrAlias(file, node.left.expression)) {
27225                 bindExportsPropertyAssignment(node);
27226             }
27227             else if (ts.hasDynamicName(node)) {
27228                 bindAnonymousDeclaration(node, 4 | 67108864, "__computed");
27229                 var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), false, false);
27230                 addLateBoundAssignmentDeclarationToSymbol(node, sym);
27231             }
27232             else {
27233                 bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticNameExpression));
27234             }
27235         }
27236         function bindStaticPropertyAssignment(node) {
27237             ts.Debug.assert(!ts.isIdentifier(node));
27238             node.expression.parent = node;
27239             bindPropertyAssignment(node.expression, node, false, false);
27240         }
27241         function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) {
27242             if (isToplevel && !isPrototypeProperty) {
27243                 var flags_1 = 1536 | 67108864;
27244                 var excludeFlags_1 = 110735 & ~67108864;
27245                 namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) {
27246                     if (symbol) {
27247                         addDeclarationToSymbol(symbol, id, flags_1);
27248                         return symbol;
27249                     }
27250                     else {
27251                         var table = parent ? parent.exports :
27252                             file.jsGlobalAugmentations || (file.jsGlobalAugmentations = ts.createSymbolTable());
27253                         return declareSymbol(table, parent, id, flags_1, excludeFlags_1);
27254                     }
27255                 });
27256             }
27257             if (containerIsClass && namespaceSymbol && namespaceSymbol.valueDeclaration) {
27258                 addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32);
27259             }
27260             return namespaceSymbol;
27261         }
27262         function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) {
27263             if (!namespaceSymbol || !isExpandoSymbol(namespaceSymbol)) {
27264                 return;
27265             }
27266             var symbolTable = isPrototypeProperty ?
27267                 (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) :
27268                 (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable()));
27269             var includes = 0;
27270             var excludes = 0;
27271             if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) {
27272                 includes = 8192;
27273                 excludes = 103359;
27274             }
27275             else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) {
27276                 if (ts.some(declaration.arguments[2].properties, function (p) {
27277                     var id = ts.getNameOfDeclaration(p);
27278                     return !!id && ts.isIdentifier(id) && ts.idText(id) === "set";
27279                 })) {
27280                     includes |= 65536 | 4;
27281                     excludes |= 78783;
27282                 }
27283                 if (ts.some(declaration.arguments[2].properties, function (p) {
27284                     var id = ts.getNameOfDeclaration(p);
27285                     return !!id && ts.isIdentifier(id) && ts.idText(id) === "get";
27286                 })) {
27287                     includes |= 32768 | 4;
27288                     excludes |= 46015;
27289                 }
27290             }
27291             if (includes === 0) {
27292                 includes = 4;
27293                 excludes = 0;
27294             }
27295             declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864, excludes & ~67108864);
27296         }
27297         function isTopLevelNamespaceAssignment(propertyAccess) {
27298             return ts.isBinaryExpression(propertyAccess.parent)
27299                 ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 290
27300                 : propertyAccess.parent.parent.kind === 290;
27301         }
27302         function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) {
27303             var namespaceSymbol = lookupSymbolForPropertyAccess(name);
27304             var isToplevel = isTopLevelNamespaceAssignment(propertyAccess);
27305             namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass);
27306             bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty);
27307         }
27308         function isExpandoSymbol(symbol) {
27309             if (symbol.flags & (16 | 32 | 1024)) {
27310                 return true;
27311             }
27312             var node = symbol.valueDeclaration;
27313             if (node && ts.isCallExpression(node)) {
27314                 return !!ts.getAssignedExpandoInitializer(node);
27315             }
27316             var init = !node ? undefined :
27317                 ts.isVariableDeclaration(node) ? node.initializer :
27318                     ts.isBinaryExpression(node) ? node.right :
27319                         ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) ? node.parent.right :
27320                             undefined;
27321             init = init && ts.getRightMostAssignedExpression(init);
27322             if (init) {
27323                 var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node);
27324                 return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 || init.operatorToken.kind === 60) ? init.right : init, isPrototypeAssignment);
27325             }
27326             return false;
27327         }
27328         function getParentOfBinaryExpression(expr) {
27329             while (ts.isBinaryExpression(expr.parent)) {
27330                 expr = expr.parent;
27331             }
27332             return expr.parent;
27333         }
27334         function lookupSymbolForPropertyAccess(node, lookupContainer) {
27335             if (lookupContainer === void 0) { lookupContainer = container; }
27336             if (ts.isIdentifier(node)) {
27337                 return lookupSymbolForNameWorker(lookupContainer, node.escapedText);
27338             }
27339             else {
27340                 var symbol = lookupSymbolForPropertyAccess(node.expression);
27341                 return symbol && symbol.exports && symbol.exports.get(ts.getElementOrPropertyAccessName(node));
27342             }
27343         }
27344         function forEachIdentifierInEntityName(e, parent, action) {
27345             if (isExportsOrModuleExportsOrAlias(file, e)) {
27346                 return file.symbol;
27347             }
27348             else if (ts.isIdentifier(e)) {
27349                 return action(e, lookupSymbolForPropertyAccess(e), parent);
27350             }
27351             else {
27352                 var s = forEachIdentifierInEntityName(e.expression, parent, action);
27353                 var name = ts.getNameOrArgument(e);
27354                 if (ts.isPrivateIdentifier(name)) {
27355                     ts.Debug.fail("unexpected PrivateIdentifier");
27356                 }
27357                 return action(name, s && s.exports && s.exports.get(ts.getElementOrPropertyAccessName(e)), s);
27358             }
27359         }
27360         function bindCallExpression(node) {
27361             if (!file.commonJsModuleIndicator && ts.isRequireCall(node, false)) {
27362                 setCommonJsModuleIndicator(node);
27363             }
27364         }
27365         function bindClassLikeDeclaration(node) {
27366             if (node.kind === 245) {
27367                 bindBlockScopedDeclaration(node, 32, 899503);
27368             }
27369             else {
27370                 var bindingName = node.name ? node.name.escapedText : "__class";
27371                 bindAnonymousDeclaration(node, 32, bindingName);
27372                 if (node.name) {
27373                     classifiableNames.set(node.name.escapedText, true);
27374                 }
27375             }
27376             var symbol = node.symbol;
27377             var prototypeSymbol = createSymbol(4 | 4194304, "prototype");
27378             var symbolExport = symbol.exports.get(prototypeSymbol.escapedName);
27379             if (symbolExport) {
27380                 if (node.name) {
27381                     node.name.parent = node;
27382                 }
27383                 file.bindDiagnostics.push(createDiagnosticForNode(symbolExport.declarations[0], ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(prototypeSymbol)));
27384             }
27385             symbol.exports.set(prototypeSymbol.escapedName, prototypeSymbol);
27386             prototypeSymbol.parent = symbol;
27387         }
27388         function bindEnumDeclaration(node) {
27389             return ts.isEnumConst(node)
27390                 ? bindBlockScopedDeclaration(node, 128, 899967)
27391                 : bindBlockScopedDeclaration(node, 256, 899327);
27392         }
27393         function bindVariableDeclarationOrBindingElement(node) {
27394             if (inStrictMode) {
27395                 checkStrictModeEvalOrArguments(node, node.name);
27396             }
27397             if (!ts.isBindingPattern(node.name)) {
27398                 if (ts.isBlockOrCatchScoped(node)) {
27399                     bindBlockScopedDeclaration(node, 2, 111551);
27400                 }
27401                 else if (ts.isParameterDeclaration(node)) {
27402                     declareSymbolAndAddToSymbolTable(node, 1, 111551);
27403                 }
27404                 else {
27405                     declareSymbolAndAddToSymbolTable(node, 1, 111550);
27406                 }
27407             }
27408         }
27409         function bindParameter(node) {
27410             if (node.kind === 317 && container.kind !== 305) {
27411                 return;
27412             }
27413             if (inStrictMode && !(node.flags & 8388608)) {
27414                 checkStrictModeEvalOrArguments(node, node.name);
27415             }
27416             if (ts.isBindingPattern(node.name)) {
27417                 bindAnonymousDeclaration(node, 1, "__" + node.parent.parameters.indexOf(node));
27418             }
27419             else {
27420                 declareSymbolAndAddToSymbolTable(node, 1, 111551);
27421             }
27422             if (ts.isParameterPropertyDeclaration(node, node.parent)) {
27423                 var classDeclaration = node.parent.parent;
27424                 declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 | (node.questionToken ? 16777216 : 0), 0);
27425             }
27426         }
27427         function bindFunctionDeclaration(node) {
27428             if (!file.isDeclarationFile && !(node.flags & 8388608)) {
27429                 if (ts.isAsyncFunction(node)) {
27430                     emitFlags |= 2048;
27431                 }
27432             }
27433             checkStrictModeFunctionName(node);
27434             if (inStrictMode) {
27435                 checkStrictModeFunctionDeclaration(node);
27436                 bindBlockScopedDeclaration(node, 16, 110991);
27437             }
27438             else {
27439                 declareSymbolAndAddToSymbolTable(node, 16, 110991);
27440             }
27441         }
27442         function bindFunctionExpression(node) {
27443             if (!file.isDeclarationFile && !(node.flags & 8388608)) {
27444                 if (ts.isAsyncFunction(node)) {
27445                     emitFlags |= 2048;
27446                 }
27447             }
27448             if (currentFlow) {
27449                 node.flowNode = currentFlow;
27450             }
27451             checkStrictModeFunctionName(node);
27452             var bindingName = node.name ? node.name.escapedText : "__function";
27453             return bindAnonymousDeclaration(node, 16, bindingName);
27454         }
27455         function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) {
27456             if (!file.isDeclarationFile && !(node.flags & 8388608) && ts.isAsyncFunction(node)) {
27457                 emitFlags |= 2048;
27458             }
27459             if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) {
27460                 node.flowNode = currentFlow;
27461             }
27462             return ts.hasDynamicName(node)
27463                 ? bindAnonymousDeclaration(node, symbolFlags, "__computed")
27464                 : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
27465         }
27466         function getInferTypeContainer(node) {
27467             var extendsType = ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && n.parent.extendsType === n; });
27468             return extendsType && extendsType.parent;
27469         }
27470         function bindTypeParameter(node) {
27471             if (ts.isJSDocTemplateTag(node.parent)) {
27472                 var container_1 = ts.find(node.parent.parent.tags, ts.isJSDocTypeAlias) || ts.getHostSignatureFromJSDoc(node.parent);
27473                 if (container_1) {
27474                     if (!container_1.locals) {
27475                         container_1.locals = ts.createSymbolTable();
27476                     }
27477                     declareSymbol(container_1.locals, undefined, node, 262144, 526824);
27478                 }
27479                 else {
27480                     declareSymbolAndAddToSymbolTable(node, 262144, 526824);
27481                 }
27482             }
27483             else if (node.parent.kind === 181) {
27484                 var container_2 = getInferTypeContainer(node.parent);
27485                 if (container_2) {
27486                     if (!container_2.locals) {
27487                         container_2.locals = ts.createSymbolTable();
27488                     }
27489                     declareSymbol(container_2.locals, undefined, node, 262144, 526824);
27490                 }
27491                 else {
27492                     bindAnonymousDeclaration(node, 262144, getDeclarationName(node));
27493                 }
27494             }
27495             else {
27496                 declareSymbolAndAddToSymbolTable(node, 262144, 526824);
27497             }
27498         }
27499         function shouldReportErrorOnModuleDeclaration(node) {
27500             var instanceState = getModuleInstanceState(node);
27501             return instanceState === 1 || (instanceState === 2 && !!options.preserveConstEnums);
27502         }
27503         function checkUnreachable(node) {
27504             if (!(currentFlow.flags & 1)) {
27505                 return false;
27506             }
27507             if (currentFlow === unreachableFlow) {
27508                 var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 224) ||
27509                     node.kind === 245 ||
27510                     (node.kind === 249 && shouldReportErrorOnModuleDeclaration(node));
27511                 if (reportError) {
27512                     currentFlow = reportedUnreachableFlow;
27513                     if (!options.allowUnreachableCode) {
27514                         var isError_1 = ts.unreachableCodeIsError(options) &&
27515                             !(node.flags & 8388608) &&
27516                             (!ts.isVariableStatement(node) ||
27517                                 !!(ts.getCombinedNodeFlags(node.declarationList) & 3) ||
27518                                 node.declarationList.declarations.some(function (d) { return !!d.initializer; }));
27519                         eachUnreachableRange(node, function (start, end) { return errorOrSuggestionOnRange(isError_1, start, end, ts.Diagnostics.Unreachable_code_detected); });
27520                     }
27521                 }
27522             }
27523             return true;
27524         }
27525     }
27526     function eachUnreachableRange(node, cb) {
27527         if (ts.isStatement(node) && isExecutableStatement(node) && ts.isBlock(node.parent)) {
27528             var statements = node.parent.statements;
27529             var slice_1 = ts.sliceAfter(statements, node);
27530             ts.getRangesWhere(slice_1, isExecutableStatement, function (start, afterEnd) { return cb(slice_1[start], slice_1[afterEnd - 1]); });
27531         }
27532         else {
27533             cb(node, node);
27534         }
27535     }
27536     function isExecutableStatement(s) {
27537         return !ts.isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && !ts.isEnumDeclaration(s) &&
27538             !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 | 2)) && s.declarationList.declarations.some(function (d) { return !d.initializer; }));
27539     }
27540     function isPurelyTypeDeclaration(s) {
27541         switch (s.kind) {
27542             case 246:
27543             case 247:
27544                 return true;
27545             case 249:
27546                 return getModuleInstanceState(s) !== 1;
27547             case 248:
27548                 return ts.hasModifier(s, 2048);
27549             default:
27550                 return false;
27551         }
27552     }
27553     function isExportsOrModuleExportsOrAlias(sourceFile, node) {
27554         var i = 0;
27555         var q = [node];
27556         while (q.length && i < 100) {
27557             i++;
27558             node = q.shift();
27559             if (ts.isExportsIdentifier(node) || ts.isModuleExportsAccessExpression(node)) {
27560                 return true;
27561             }
27562             else if (ts.isIdentifier(node)) {
27563                 var symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText);
27564                 if (!!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && !!symbol.valueDeclaration.initializer) {
27565                     var init = symbol.valueDeclaration.initializer;
27566                     q.push(init);
27567                     if (ts.isAssignmentExpression(init, true)) {
27568                         q.push(init.left);
27569                         q.push(init.right);
27570                     }
27571                 }
27572             }
27573         }
27574         return false;
27575     }
27576     ts.isExportsOrModuleExportsOrAlias = isExportsOrModuleExportsOrAlias;
27577     function lookupSymbolForNameWorker(container, name) {
27578         var local = container.locals && container.locals.get(name);
27579         if (local) {
27580             return local.exportSymbol || local;
27581         }
27582         if (ts.isSourceFile(container) && container.jsGlobalAugmentations && container.jsGlobalAugmentations.has(name)) {
27583             return container.jsGlobalAugmentations.get(name);
27584         }
27585         return container.symbol && container.symbol.exports && container.symbol.exports.get(name);
27586     }
27587     function computeTransformFlagsForNode(node, subtreeFlags) {
27588         var kind = node.kind;
27589         switch (kind) {
27590             case 196:
27591                 return computeCallExpression(node, subtreeFlags);
27592             case 197:
27593                 return computeNewExpression(node, subtreeFlags);
27594             case 249:
27595                 return computeModuleDeclaration(node, subtreeFlags);
27596             case 200:
27597                 return computeParenthesizedExpression(node, subtreeFlags);
27598             case 209:
27599                 return computeBinaryExpression(node, subtreeFlags);
27600             case 226:
27601                 return computeExpressionStatement(node, subtreeFlags);
27602             case 156:
27603                 return computeParameter(node, subtreeFlags);
27604             case 202:
27605                 return computeArrowFunction(node, subtreeFlags);
27606             case 201:
27607                 return computeFunctionExpression(node, subtreeFlags);
27608             case 244:
27609                 return computeFunctionDeclaration(node, subtreeFlags);
27610             case 242:
27611                 return computeVariableDeclaration(node, subtreeFlags);
27612             case 243:
27613                 return computeVariableDeclarationList(node, subtreeFlags);
27614             case 225:
27615                 return computeVariableStatement(node, subtreeFlags);
27616             case 238:
27617                 return computeLabeledStatement(node, subtreeFlags);
27618             case 245:
27619                 return computeClassDeclaration(node, subtreeFlags);
27620             case 214:
27621                 return computeClassExpression(node, subtreeFlags);
27622             case 279:
27623                 return computeHeritageClause(node, subtreeFlags);
27624             case 280:
27625                 return computeCatchClause(node, subtreeFlags);
27626             case 216:
27627                 return computeExpressionWithTypeArguments(node, subtreeFlags);
27628             case 162:
27629                 return computeConstructor(node, subtreeFlags);
27630             case 159:
27631                 return computePropertyDeclaration(node, subtreeFlags);
27632             case 161:
27633                 return computeMethod(node, subtreeFlags);
27634             case 163:
27635             case 164:
27636                 return computeAccessor(node, subtreeFlags);
27637             case 253:
27638                 return computeImportEquals(node, subtreeFlags);
27639             case 194:
27640                 return computePropertyAccess(node, subtreeFlags);
27641             case 195:
27642                 return computeElementAccess(node, subtreeFlags);
27643             case 267:
27644             case 268:
27645                 return computeJsxOpeningLikeElement(node, subtreeFlags);
27646             default:
27647                 return computeOther(node, kind, subtreeFlags);
27648         }
27649     }
27650     ts.computeTransformFlagsForNode = computeTransformFlagsForNode;
27651     function computeCallExpression(node, subtreeFlags) {
27652         var transformFlags = subtreeFlags;
27653         var callee = ts.skipOuterExpressions(node.expression);
27654         var expression = node.expression;
27655         if (node.flags & 32) {
27656             transformFlags |= 8;
27657         }
27658         if (node.typeArguments) {
27659             transformFlags |= 1;
27660         }
27661         if (subtreeFlags & 8192 || ts.isSuperOrSuperProperty(callee)) {
27662             transformFlags |= 256;
27663             if (ts.isSuperProperty(callee)) {
27664                 transformFlags |= 4096;
27665             }
27666         }
27667         if (expression.kind === 96) {
27668             transformFlags |= 2097152;
27669         }
27670         node.transformFlags = transformFlags | 536870912;
27671         return transformFlags & ~536879104;
27672     }
27673     function computeNewExpression(node, subtreeFlags) {
27674         var transformFlags = subtreeFlags;
27675         if (node.typeArguments) {
27676             transformFlags |= 1;
27677         }
27678         if (subtreeFlags & 8192) {
27679             transformFlags |= 256;
27680         }
27681         node.transformFlags = transformFlags | 536870912;
27682         return transformFlags & ~536879104;
27683     }
27684     function computeJsxOpeningLikeElement(node, subtreeFlags) {
27685         var transformFlags = subtreeFlags | 2;
27686         if (node.typeArguments) {
27687             transformFlags |= 1;
27688         }
27689         node.transformFlags = transformFlags | 536870912;
27690         return transformFlags & ~536870912;
27691     }
27692     function computeBinaryExpression(node, subtreeFlags) {
27693         var transformFlags = subtreeFlags;
27694         var operatorTokenKind = node.operatorToken.kind;
27695         var leftKind = node.left.kind;
27696         if (operatorTokenKind === 60) {
27697             transformFlags |= 8;
27698         }
27699         else if (operatorTokenKind === 62 && leftKind === 193) {
27700             transformFlags |= 32 | 256 | 1024;
27701         }
27702         else if (operatorTokenKind === 62 && leftKind === 192) {
27703             transformFlags |= 256 | 1024;
27704         }
27705         else if (operatorTokenKind === 42
27706             || operatorTokenKind === 66) {
27707             transformFlags |= 128;
27708         }
27709         node.transformFlags = transformFlags | 536870912;
27710         return transformFlags & ~536870912;
27711     }
27712     function computeParameter(node, subtreeFlags) {
27713         var transformFlags = subtreeFlags;
27714         var name = node.name;
27715         var initializer = node.initializer;
27716         var dotDotDotToken = node.dotDotDotToken;
27717         if (node.questionToken
27718             || node.type
27719             || (subtreeFlags & 2048 && ts.some(node.decorators))
27720             || ts.isThisIdentifier(name)) {
27721             transformFlags |= 1;
27722         }
27723         if (ts.hasModifier(node, 92)) {
27724             transformFlags |= 1 | 2048;
27725         }
27726         if (subtreeFlags & 16384) {
27727             transformFlags |= 32;
27728         }
27729         if (subtreeFlags & 131072 || initializer || dotDotDotToken) {
27730             transformFlags |= 256;
27731         }
27732         node.transformFlags = transformFlags | 536870912;
27733         return transformFlags & ~536870912;
27734     }
27735     function computeParenthesizedExpression(node, subtreeFlags) {
27736         var transformFlags = subtreeFlags;
27737         var expression = node.expression;
27738         var expressionKind = expression.kind;
27739         if (expressionKind === 217
27740             || expressionKind === 199) {
27741             transformFlags |= 1;
27742         }
27743         node.transformFlags = transformFlags | 536870912;
27744         return transformFlags & ~536870912;
27745     }
27746     function computeClassDeclaration(node, subtreeFlags) {
27747         var transformFlags;
27748         if (ts.hasModifier(node, 2)) {
27749             transformFlags = 1;
27750         }
27751         else {
27752             transformFlags = subtreeFlags | 256;
27753             if ((subtreeFlags & 2048)
27754                 || node.typeParameters) {
27755                 transformFlags |= 1;
27756             }
27757         }
27758         node.transformFlags = transformFlags | 536870912;
27759         return transformFlags & ~536905728;
27760     }
27761     function computeClassExpression(node, subtreeFlags) {
27762         var transformFlags = subtreeFlags | 256;
27763         if (subtreeFlags & 2048
27764             || node.typeParameters) {
27765             transformFlags |= 1;
27766         }
27767         node.transformFlags = transformFlags | 536870912;
27768         return transformFlags & ~536905728;
27769     }
27770     function computeHeritageClause(node, subtreeFlags) {
27771         var transformFlags = subtreeFlags;
27772         switch (node.token) {
27773             case 90:
27774                 transformFlags |= 256;
27775                 break;
27776             case 113:
27777                 transformFlags |= 1;
27778                 break;
27779             default:
27780                 ts.Debug.fail("Unexpected token for heritage clause");
27781                 break;
27782         }
27783         node.transformFlags = transformFlags | 536870912;
27784         return transformFlags & ~536870912;
27785     }
27786     function computeCatchClause(node, subtreeFlags) {
27787         var transformFlags = subtreeFlags;
27788         if (!node.variableDeclaration) {
27789             transformFlags |= 16;
27790         }
27791         else if (ts.isBindingPattern(node.variableDeclaration.name)) {
27792             transformFlags |= 256;
27793         }
27794         node.transformFlags = transformFlags | 536870912;
27795         return transformFlags & ~536887296;
27796     }
27797     function computeExpressionWithTypeArguments(node, subtreeFlags) {
27798         var transformFlags = subtreeFlags | 256;
27799         if (node.typeArguments) {
27800             transformFlags |= 1;
27801         }
27802         node.transformFlags = transformFlags | 536870912;
27803         return transformFlags & ~536870912;
27804     }
27805     function computeConstructor(node, subtreeFlags) {
27806         var transformFlags = subtreeFlags;
27807         if (ts.hasModifier(node, 2270)
27808             || !node.body) {
27809             transformFlags |= 1;
27810         }
27811         if (subtreeFlags & 16384) {
27812             transformFlags |= 32;
27813         }
27814         node.transformFlags = transformFlags | 536870912;
27815         return transformFlags & ~538923008;
27816     }
27817     function computeMethod(node, subtreeFlags) {
27818         var transformFlags = subtreeFlags | 256;
27819         if (node.decorators
27820             || ts.hasModifier(node, 2270)
27821             || node.typeParameters
27822             || node.type
27823             || !node.body
27824             || node.questionToken) {
27825             transformFlags |= 1;
27826         }
27827         if (subtreeFlags & 16384) {
27828             transformFlags |= 32;
27829         }
27830         if (ts.hasModifier(node, 256)) {
27831             transformFlags |= node.asteriskToken ? 32 : 64;
27832         }
27833         if (node.asteriskToken) {
27834             transformFlags |= 512;
27835         }
27836         node.transformFlags = transformFlags | 536870912;
27837         return propagatePropertyNameFlags(node.name, transformFlags & ~538923008);
27838     }
27839     function computeAccessor(node, subtreeFlags) {
27840         var transformFlags = subtreeFlags;
27841         if (node.decorators
27842             || ts.hasModifier(node, 2270)
27843             || node.type
27844             || !node.body) {
27845             transformFlags |= 1;
27846         }
27847         if (subtreeFlags & 16384) {
27848             transformFlags |= 32;
27849         }
27850         node.transformFlags = transformFlags | 536870912;
27851         return propagatePropertyNameFlags(node.name, transformFlags & ~538923008);
27852     }
27853     function computePropertyDeclaration(node, subtreeFlags) {
27854         var transformFlags = subtreeFlags | 4194304;
27855         if (ts.some(node.decorators) || ts.hasModifier(node, 2270) || node.type || node.questionToken || node.exclamationToken) {
27856             transformFlags |= 1;
27857         }
27858         if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) {
27859             transformFlags |= 2048;
27860         }
27861         node.transformFlags = transformFlags | 536870912;
27862         return propagatePropertyNameFlags(node.name, transformFlags & ~536875008);
27863     }
27864     function computeFunctionDeclaration(node, subtreeFlags) {
27865         var transformFlags;
27866         var modifierFlags = ts.getModifierFlags(node);
27867         var body = node.body;
27868         if (!body || (modifierFlags & 2)) {
27869             transformFlags = 1;
27870         }
27871         else {
27872             transformFlags = subtreeFlags | 1048576;
27873             if (modifierFlags & 2270
27874                 || node.typeParameters
27875                 || node.type) {
27876                 transformFlags |= 1;
27877             }
27878             if (modifierFlags & 256) {
27879                 transformFlags |= node.asteriskToken ? 32 : 64;
27880             }
27881             if (subtreeFlags & 16384) {
27882                 transformFlags |= 32;
27883             }
27884             if (node.asteriskToken) {
27885                 transformFlags |= 512;
27886             }
27887         }
27888         node.transformFlags = transformFlags | 536870912;
27889         return transformFlags & ~538925056;
27890     }
27891     function computeFunctionExpression(node, subtreeFlags) {
27892         var transformFlags = subtreeFlags;
27893         if (ts.hasModifier(node, 2270)
27894             || node.typeParameters
27895             || node.type) {
27896             transformFlags |= 1;
27897         }
27898         if (ts.hasModifier(node, 256)) {
27899             transformFlags |= node.asteriskToken ? 32 : 64;
27900         }
27901         if (subtreeFlags & 16384) {
27902             transformFlags |= 32;
27903         }
27904         if (node.asteriskToken) {
27905             transformFlags |= 512;
27906         }
27907         node.transformFlags = transformFlags | 536870912;
27908         return transformFlags & ~538925056;
27909     }
27910     function computeArrowFunction(node, subtreeFlags) {
27911         var transformFlags = subtreeFlags | 256;
27912         if (ts.hasModifier(node, 2270)
27913             || node.typeParameters
27914             || node.type) {
27915             transformFlags |= 1;
27916         }
27917         if (ts.hasModifier(node, 256)) {
27918             transformFlags |= 64;
27919         }
27920         if (subtreeFlags & 16384) {
27921             transformFlags |= 32;
27922         }
27923         node.transformFlags = transformFlags | 536870912;
27924         return transformFlags & ~538920960;
27925     }
27926     function computePropertyAccess(node, subtreeFlags) {
27927         var transformFlags = subtreeFlags;
27928         if (node.flags & 32) {
27929             transformFlags |= 8;
27930         }
27931         if (node.expression.kind === 102) {
27932             transformFlags |= 64 | 32;
27933         }
27934         node.transformFlags = transformFlags | 536870912;
27935         return transformFlags & ~536870912;
27936     }
27937     function computeElementAccess(node, subtreeFlags) {
27938         var transformFlags = subtreeFlags;
27939         if (node.flags & 32) {
27940             transformFlags |= 8;
27941         }
27942         if (node.expression.kind === 102) {
27943             transformFlags |= 64 | 32;
27944         }
27945         node.transformFlags = transformFlags | 536870912;
27946         return transformFlags & ~536870912;
27947     }
27948     function computeVariableDeclaration(node, subtreeFlags) {
27949         var transformFlags = subtreeFlags;
27950         transformFlags |= 256 | 131072;
27951         if (subtreeFlags & 16384) {
27952             transformFlags |= 32;
27953         }
27954         if (node.type || node.exclamationToken) {
27955             transformFlags |= 1;
27956         }
27957         node.transformFlags = transformFlags | 536870912;
27958         return transformFlags & ~536870912;
27959     }
27960     function computeVariableStatement(node, subtreeFlags) {
27961         var transformFlags;
27962         var declarationListTransformFlags = node.declarationList.transformFlags;
27963         if (ts.hasModifier(node, 2)) {
27964             transformFlags = 1;
27965         }
27966         else {
27967             transformFlags = subtreeFlags;
27968             if (declarationListTransformFlags & 131072) {
27969                 transformFlags |= 256;
27970             }
27971         }
27972         node.transformFlags = transformFlags | 536870912;
27973         return transformFlags & ~536870912;
27974     }
27975     function computeLabeledStatement(node, subtreeFlags) {
27976         var transformFlags = subtreeFlags;
27977         if (subtreeFlags & 65536
27978             && ts.isIterationStatement(node, true)) {
27979             transformFlags |= 256;
27980         }
27981         node.transformFlags = transformFlags | 536870912;
27982         return transformFlags & ~536870912;
27983     }
27984     function computeImportEquals(node, subtreeFlags) {
27985         var transformFlags = subtreeFlags;
27986         if (!ts.isExternalModuleImportEqualsDeclaration(node)) {
27987             transformFlags |= 1;
27988         }
27989         node.transformFlags = transformFlags | 536870912;
27990         return transformFlags & ~536870912;
27991     }
27992     function computeExpressionStatement(node, subtreeFlags) {
27993         var transformFlags = subtreeFlags;
27994         node.transformFlags = transformFlags | 536870912;
27995         return transformFlags & ~536870912;
27996     }
27997     function computeModuleDeclaration(node, subtreeFlags) {
27998         var transformFlags = 1;
27999         var modifierFlags = ts.getModifierFlags(node);
28000         if ((modifierFlags & 2) === 0) {
28001             transformFlags |= subtreeFlags;
28002         }
28003         node.transformFlags = transformFlags | 536870912;
28004         return transformFlags & ~537991168;
28005     }
28006     function computeVariableDeclarationList(node, subtreeFlags) {
28007         var transformFlags = subtreeFlags | 1048576;
28008         if (subtreeFlags & 131072) {
28009             transformFlags |= 256;
28010         }
28011         if (node.flags & 3) {
28012             transformFlags |= 256 | 65536;
28013         }
28014         node.transformFlags = transformFlags | 536870912;
28015         return transformFlags & ~537018368;
28016     }
28017     function computeOther(node, kind, subtreeFlags) {
28018         var transformFlags = subtreeFlags;
28019         var excludeFlags = 536870912;
28020         switch (kind) {
28021             case 126:
28022                 transformFlags |= 32 | 64;
28023                 break;
28024             case 206:
28025                 transformFlags |= 32 | 64 | 524288;
28026                 break;
28027             case 199:
28028             case 217:
28029             case 326:
28030                 transformFlags |= 1;
28031                 excludeFlags = 536870912;
28032                 break;
28033             case 119:
28034             case 117:
28035             case 118:
28036             case 122:
28037             case 130:
28038             case 81:
28039             case 248:
28040             case 284:
28041             case 218:
28042             case 138:
28043                 transformFlags |= 1;
28044                 break;
28045             case 266:
28046             case 11:
28047             case 269:
28048             case 270:
28049             case 271:
28050             case 272:
28051             case 273:
28052             case 274:
28053             case 275:
28054             case 276:
28055                 transformFlags |= 2;
28056                 break;
28057             case 14:
28058             case 15:
28059             case 16:
28060             case 17:
28061                 if (node.templateFlags) {
28062                     transformFlags |= 32;
28063                     break;
28064                 }
28065             case 198:
28066                 if (ts.hasInvalidEscape(node.template)) {
28067                     transformFlags |= 32;
28068                     break;
28069                 }
28070             case 211:
28071             case 282:
28072             case 120:
28073             case 219:
28074                 transformFlags |= 256;
28075                 break;
28076             case 10:
28077                 if (node.hasExtendedUnicodeEscape) {
28078                     transformFlags |= 256;
28079                 }
28080                 break;
28081             case 8:
28082                 if (node.numericLiteralFlags & 384) {
28083                     transformFlags |= 256;
28084                 }
28085                 break;
28086             case 9:
28087                 transformFlags |= 4;
28088                 break;
28089             case 232:
28090                 if (node.awaitModifier) {
28091                     transformFlags |= 32;
28092                 }
28093                 transformFlags |= 256;
28094                 break;
28095             case 212:
28096                 transformFlags |= 32 | 256 | 262144;
28097                 break;
28098             case 125:
28099             case 140:
28100             case 151:
28101             case 137:
28102             case 141:
28103             case 143:
28104             case 128:
28105             case 144:
28106             case 110:
28107             case 155:
28108             case 158:
28109             case 160:
28110             case 165:
28111             case 166:
28112             case 167:
28113             case 168:
28114             case 169:
28115             case 170:
28116             case 171:
28117             case 172:
28118             case 173:
28119             case 174:
28120             case 175:
28121             case 176:
28122             case 177:
28123             case 178:
28124             case 179:
28125             case 180:
28126             case 181:
28127             case 182:
28128             case 246:
28129             case 247:
28130             case 183:
28131             case 184:
28132             case 185:
28133             case 186:
28134             case 187:
28135             case 252:
28136                 transformFlags = 1;
28137                 excludeFlags = -2;
28138                 break;
28139             case 154:
28140                 transformFlags |= 32768;
28141                 break;
28142             case 213:
28143                 transformFlags |= 256 | 8192;
28144                 break;
28145             case 283:
28146                 transformFlags |= 32 | 16384;
28147                 break;
28148             case 102:
28149                 transformFlags |= 256;
28150                 excludeFlags = 536870912;
28151                 break;
28152             case 104:
28153                 transformFlags |= 4096;
28154                 break;
28155             case 189:
28156                 transformFlags |= 256 | 131072;
28157                 if (subtreeFlags & 8192) {
28158                     transformFlags |= 32 | 16384;
28159                 }
28160                 excludeFlags = 536879104;
28161                 break;
28162             case 190:
28163                 transformFlags |= 256 | 131072;
28164                 excludeFlags = 536879104;
28165                 break;
28166             case 191:
28167                 transformFlags |= 256;
28168                 if (node.dotDotDotToken) {
28169                     transformFlags |= 8192;
28170                 }
28171                 break;
28172             case 157:
28173                 transformFlags |= 1 | 2048;
28174                 break;
28175             case 193:
28176                 excludeFlags = 536922112;
28177                 if (subtreeFlags & 32768) {
28178                     transformFlags |= 256;
28179                 }
28180                 if (subtreeFlags & 16384) {
28181                     transformFlags |= 32;
28182                 }
28183                 break;
28184             case 192:
28185                 excludeFlags = 536879104;
28186                 break;
28187             case 228:
28188             case 229:
28189             case 230:
28190             case 231:
28191                 if (subtreeFlags & 65536) {
28192                     transformFlags |= 256;
28193                 }
28194                 break;
28195             case 290:
28196                 break;
28197             case 262:
28198                 transformFlags |= 4;
28199                 break;
28200             case 235:
28201                 transformFlags |= 1048576 | 32;
28202                 break;
28203             case 233:
28204             case 234:
28205                 transformFlags |= 1048576;
28206                 break;
28207             case 76:
28208                 transformFlags |= 4194304;
28209                 break;
28210         }
28211         node.transformFlags = transformFlags | 536870912;
28212         return transformFlags & ~excludeFlags;
28213     }
28214     function propagatePropertyNameFlags(node, transformFlags) {
28215         return transformFlags | (node.transformFlags & 4096);
28216     }
28217     function getTransformFlagsSubtreeExclusions(kind) {
28218         if (kind >= 168 && kind <= 188) {
28219             return -2;
28220         }
28221         switch (kind) {
28222             case 196:
28223             case 197:
28224             case 192:
28225                 return 536879104;
28226             case 249:
28227                 return 537991168;
28228             case 156:
28229                 return 536870912;
28230             case 202:
28231                 return 538920960;
28232             case 201:
28233             case 244:
28234                 return 538925056;
28235             case 243:
28236                 return 537018368;
28237             case 245:
28238             case 214:
28239                 return 536905728;
28240             case 162:
28241                 return 538923008;
28242             case 161:
28243             case 163:
28244             case 164:
28245                 return 538923008;
28246             case 125:
28247             case 140:
28248             case 151:
28249             case 137:
28250             case 143:
28251             case 141:
28252             case 128:
28253             case 144:
28254             case 110:
28255             case 155:
28256             case 158:
28257             case 160:
28258             case 165:
28259             case 166:
28260             case 167:
28261             case 246:
28262             case 247:
28263                 return -2;
28264             case 193:
28265                 return 536922112;
28266             case 280:
28267                 return 536887296;
28268             case 189:
28269             case 190:
28270                 return 536879104;
28271             case 199:
28272             case 217:
28273             case 326:
28274             case 200:
28275             case 102:
28276                 return 536870912;
28277             case 194:
28278             case 195:
28279                 return 536870912;
28280             default:
28281                 return 536870912;
28282         }
28283     }
28284     ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions;
28285     function setParentPointers(parent, child) {
28286         child.parent = parent;
28287         ts.forEachChild(child, function (grandchild) { return setParentPointers(child, grandchild); });
28288     }
28289 })(ts || (ts = {}));
28290 var ts;
28291 (function (ts) {
28292     function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments) {
28293         return getSymbolWalker;
28294         function getSymbolWalker(accept) {
28295             if (accept === void 0) { accept = function () { return true; }; }
28296             var visitedTypes = [];
28297             var visitedSymbols = [];
28298             return {
28299                 walkType: function (type) {
28300                     try {
28301                         visitType(type);
28302                         return { visitedTypes: ts.getOwnValues(visitedTypes), visitedSymbols: ts.getOwnValues(visitedSymbols) };
28303                     }
28304                     finally {
28305                         ts.clear(visitedTypes);
28306                         ts.clear(visitedSymbols);
28307                     }
28308                 },
28309                 walkSymbol: function (symbol) {
28310                     try {
28311                         visitSymbol(symbol);
28312                         return { visitedTypes: ts.getOwnValues(visitedTypes), visitedSymbols: ts.getOwnValues(visitedSymbols) };
28313                     }
28314                     finally {
28315                         ts.clear(visitedTypes);
28316                         ts.clear(visitedSymbols);
28317                     }
28318                 },
28319             };
28320             function visitType(type) {
28321                 if (!type) {
28322                     return;
28323                 }
28324                 if (visitedTypes[type.id]) {
28325                     return;
28326                 }
28327                 visitedTypes[type.id] = type;
28328                 var shouldBail = visitSymbol(type.symbol);
28329                 if (shouldBail)
28330                     return;
28331                 if (type.flags & 524288) {
28332                     var objectType = type;
28333                     var objectFlags = objectType.objectFlags;
28334                     if (objectFlags & 4) {
28335                         visitTypeReference(type);
28336                     }
28337                     if (objectFlags & 32) {
28338                         visitMappedType(type);
28339                     }
28340                     if (objectFlags & (1 | 2)) {
28341                         visitInterfaceType(type);
28342                     }
28343                     if (objectFlags & (8 | 16)) {
28344                         visitObjectType(objectType);
28345                     }
28346                 }
28347                 if (type.flags & 262144) {
28348                     visitTypeParameter(type);
28349                 }
28350                 if (type.flags & 3145728) {
28351                     visitUnionOrIntersectionType(type);
28352                 }
28353                 if (type.flags & 4194304) {
28354                     visitIndexType(type);
28355                 }
28356                 if (type.flags & 8388608) {
28357                     visitIndexedAccessType(type);
28358                 }
28359             }
28360             function visitTypeReference(type) {
28361                 visitType(type.target);
28362                 ts.forEach(getTypeArguments(type), visitType);
28363             }
28364             function visitTypeParameter(type) {
28365                 visitType(getConstraintOfTypeParameter(type));
28366             }
28367             function visitUnionOrIntersectionType(type) {
28368                 ts.forEach(type.types, visitType);
28369             }
28370             function visitIndexType(type) {
28371                 visitType(type.type);
28372             }
28373             function visitIndexedAccessType(type) {
28374                 visitType(type.objectType);
28375                 visitType(type.indexType);
28376                 visitType(type.constraint);
28377             }
28378             function visitMappedType(type) {
28379                 visitType(type.typeParameter);
28380                 visitType(type.constraintType);
28381                 visitType(type.templateType);
28382                 visitType(type.modifiersType);
28383             }
28384             function visitSignature(signature) {
28385                 var typePredicate = getTypePredicateOfSignature(signature);
28386                 if (typePredicate) {
28387                     visitType(typePredicate.type);
28388                 }
28389                 ts.forEach(signature.typeParameters, visitType);
28390                 for (var _i = 0, _a = signature.parameters; _i < _a.length; _i++) {
28391                     var parameter = _a[_i];
28392                     visitSymbol(parameter);
28393                 }
28394                 visitType(getRestTypeOfSignature(signature));
28395                 visitType(getReturnTypeOfSignature(signature));
28396             }
28397             function visitInterfaceType(interfaceT) {
28398                 visitObjectType(interfaceT);
28399                 ts.forEach(interfaceT.typeParameters, visitType);
28400                 ts.forEach(getBaseTypes(interfaceT), visitType);
28401                 visitType(interfaceT.thisType);
28402             }
28403             function visitObjectType(type) {
28404                 var stringIndexType = getIndexTypeOfStructuredType(type, 0);
28405                 visitType(stringIndexType);
28406                 var numberIndexType = getIndexTypeOfStructuredType(type, 1);
28407                 visitType(numberIndexType);
28408                 var resolved = resolveStructuredTypeMembers(type);
28409                 for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) {
28410                     var signature = _a[_i];
28411                     visitSignature(signature);
28412                 }
28413                 for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) {
28414                     var signature = _c[_b];
28415                     visitSignature(signature);
28416                 }
28417                 for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) {
28418                     var p = _e[_d];
28419                     visitSymbol(p);
28420                 }
28421             }
28422             function visitSymbol(symbol) {
28423                 if (!symbol) {
28424                     return false;
28425                 }
28426                 var symbolId = ts.getSymbolId(symbol);
28427                 if (visitedSymbols[symbolId]) {
28428                     return false;
28429                 }
28430                 visitedSymbols[symbolId] = symbol;
28431                 if (!accept(symbol)) {
28432                     return true;
28433                 }
28434                 var t = getTypeOfSymbol(symbol);
28435                 visitType(t);
28436                 if (symbol.exports) {
28437                     symbol.exports.forEach(visitSymbol);
28438                 }
28439                 ts.forEach(symbol.declarations, function (d) {
28440                     if (d.type && d.type.kind === 172) {
28441                         var query = d.type;
28442                         var entity = getResolvedSymbol(getFirstIdentifier(query.exprName));
28443                         visitSymbol(entity);
28444                     }
28445                 });
28446                 return false;
28447             }
28448         }
28449     }
28450     ts.createGetSymbolWalker = createGetSymbolWalker;
28451 })(ts || (ts = {}));
28452 var ts;
28453 (function (ts) {
28454     var ambientModuleSymbolRegex = /^".+"$/;
28455     var anon = "(anonymous)";
28456     var nextSymbolId = 1;
28457     var nextNodeId = 1;
28458     var nextMergeId = 1;
28459     var nextFlowId = 1;
28460     var typeofEQFacts = ts.createMapFromTemplate({
28461         string: 1,
28462         number: 2,
28463         bigint: 4,
28464         boolean: 8,
28465         symbol: 16,
28466         undefined: 65536,
28467         object: 32,
28468         function: 64
28469     });
28470     var typeofNEFacts = ts.createMapFromTemplate({
28471         string: 256,
28472         number: 512,
28473         bigint: 1024,
28474         boolean: 2048,
28475         symbol: 4096,
28476         undefined: 524288,
28477         object: 8192,
28478         function: 16384
28479     });
28480     var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor);
28481     function SymbolLinks() {
28482     }
28483     function NodeLinks() {
28484         this.flags = 0;
28485     }
28486     function getNodeId(node) {
28487         if (!node.id) {
28488             node.id = nextNodeId;
28489             nextNodeId++;
28490         }
28491         return node.id;
28492     }
28493     ts.getNodeId = getNodeId;
28494     function getSymbolId(symbol) {
28495         if (!symbol.id) {
28496             symbol.id = nextSymbolId;
28497             nextSymbolId++;
28498         }
28499         return symbol.id;
28500     }
28501     ts.getSymbolId = getSymbolId;
28502     function isInstantiatedModule(node, preserveConstEnums) {
28503         var moduleState = ts.getModuleInstanceState(node);
28504         return moduleState === 1 ||
28505             (preserveConstEnums && moduleState === 2);
28506     }
28507     ts.isInstantiatedModule = isInstantiatedModule;
28508     function createTypeChecker(host, produceDiagnostics) {
28509         var getPackagesSet = ts.memoize(function () {
28510             var set = ts.createMap();
28511             host.getSourceFiles().forEach(function (sf) {
28512                 if (!sf.resolvedModules)
28513                     return;
28514                 ts.forEachEntry(sf.resolvedModules, function (r) {
28515                     if (r && r.packageId)
28516                         set.set(r.packageId.name, true);
28517                 });
28518             });
28519             return set;
28520         });
28521         var cancellationToken;
28522         var requestedExternalEmitHelpers;
28523         var externalHelpersModule;
28524         var Symbol = ts.objectAllocator.getSymbolConstructor();
28525         var Type = ts.objectAllocator.getTypeConstructor();
28526         var Signature = ts.objectAllocator.getSignatureConstructor();
28527         var typeCount = 0;
28528         var symbolCount = 0;
28529         var enumCount = 0;
28530         var totalInstantiationCount = 0;
28531         var instantiationCount = 0;
28532         var instantiationDepth = 0;
28533         var constraintDepth = 0;
28534         var currentNode;
28535         var emptySymbols = ts.createSymbolTable();
28536         var arrayVariances = [1];
28537         var compilerOptions = host.getCompilerOptions();
28538         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
28539         var moduleKind = ts.getEmitModuleKind(compilerOptions);
28540         var allowSyntheticDefaultImports = ts.getAllowSyntheticDefaultImports(compilerOptions);
28541         var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
28542         var strictFunctionTypes = ts.getStrictOptionValue(compilerOptions, "strictFunctionTypes");
28543         var strictBindCallApply = ts.getStrictOptionValue(compilerOptions, "strictBindCallApply");
28544         var strictPropertyInitialization = ts.getStrictOptionValue(compilerOptions, "strictPropertyInitialization");
28545         var noImplicitAny = ts.getStrictOptionValue(compilerOptions, "noImplicitAny");
28546         var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis");
28547         var keyofStringsOnly = !!compilerOptions.keyofStringsOnly;
28548         var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 32768;
28549         var emitResolver = createResolver();
28550         var nodeBuilder = createNodeBuilder();
28551         var globals = ts.createSymbolTable();
28552         var undefinedSymbol = createSymbol(4, "undefined");
28553         undefinedSymbol.declarations = [];
28554         var globalThisSymbol = createSymbol(1536, "globalThis", 8);
28555         globalThisSymbol.exports = globals;
28556         globalThisSymbol.declarations = [];
28557         globals.set(globalThisSymbol.escapedName, globalThisSymbol);
28558         var argumentsSymbol = createSymbol(4, "arguments");
28559         var requireSymbol = createSymbol(4, "require");
28560         var apparentArgumentCount;
28561         var checker = {
28562             getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); },
28563             getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); },
28564             getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; },
28565             getTypeCount: function () { return typeCount; },
28566             getInstantiationCount: function () { return totalInstantiationCount; },
28567             getRelationCacheSizes: function () { return ({
28568                 assignable: assignableRelation.size,
28569                 identity: identityRelation.size,
28570                 subtype: subtypeRelation.size,
28571                 strictSubtype: strictSubtypeRelation.size,
28572             }); },
28573             isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; },
28574             isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; },
28575             isUnknownSymbol: function (symbol) { return symbol === unknownSymbol; },
28576             getMergedSymbol: getMergedSymbol,
28577             getDiagnostics: getDiagnostics,
28578             getGlobalDiagnostics: getGlobalDiagnostics,
28579             getTypeOfSymbolAtLocation: function (symbol, location) {
28580                 location = ts.getParseTreeNode(location);
28581                 return location ? getTypeOfSymbolAtLocation(symbol, location) : errorType;
28582             },
28583             getSymbolsOfParameterPropertyDeclaration: function (parameterIn, parameterName) {
28584                 var parameter = ts.getParseTreeNode(parameterIn, ts.isParameter);
28585                 if (parameter === undefined)
28586                     return ts.Debug.fail("Cannot get symbols of a synthetic parameter that cannot be resolved to a parse-tree node.");
28587                 return getSymbolsOfParameterPropertyDeclaration(parameter, ts.escapeLeadingUnderscores(parameterName));
28588             },
28589             getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol,
28590             getPropertiesOfType: getPropertiesOfType,
28591             getPropertyOfType: function (type, name) { return getPropertyOfType(type, ts.escapeLeadingUnderscores(name)); },
28592             getPrivateIdentifierPropertyOfType: function (leftType, name, location) {
28593                 var node = ts.getParseTreeNode(location);
28594                 if (!node) {
28595                     return undefined;
28596                 }
28597                 var propName = ts.escapeLeadingUnderscores(name);
28598                 var lexicallyScopedIdentifier = lookupSymbolForPrivateIdentifierDeclaration(propName, node);
28599                 return lexicallyScopedIdentifier ? getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) : undefined;
28600             },
28601             getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); },
28602             getIndexInfoOfType: getIndexInfoOfType,
28603             getSignaturesOfType: getSignaturesOfType,
28604             getIndexTypeOfType: getIndexTypeOfType,
28605             getBaseTypes: getBaseTypes,
28606             getBaseTypeOfLiteralType: getBaseTypeOfLiteralType,
28607             getWidenedType: getWidenedType,
28608             getTypeFromTypeNode: function (nodeIn) {
28609                 var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
28610                 return node ? getTypeFromTypeNode(node) : errorType;
28611             },
28612             getParameterType: getTypeAtPosition,
28613             getPromisedTypeOfPromise: getPromisedTypeOfPromise,
28614             getReturnTypeOfSignature: getReturnTypeOfSignature,
28615             isNullableType: isNullableType,
28616             getNullableType: getNullableType,
28617             getNonNullableType: getNonNullableType,
28618             getNonOptionalType: removeOptionalTypeMarker,
28619             getTypeArguments: getTypeArguments,
28620             typeToTypeNode: nodeBuilder.typeToTypeNode,
28621             indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration,
28622             signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration,
28623             symbolToEntityName: nodeBuilder.symbolToEntityName,
28624             symbolToExpression: nodeBuilder.symbolToExpression,
28625             symbolToTypeParameterDeclarations: nodeBuilder.symbolToTypeParameterDeclarations,
28626             symbolToParameterDeclaration: nodeBuilder.symbolToParameterDeclaration,
28627             typeParameterToDeclaration: nodeBuilder.typeParameterToDeclaration,
28628             getSymbolsInScope: function (location, meaning) {
28629                 location = ts.getParseTreeNode(location);
28630                 return location ? getSymbolsInScope(location, meaning) : [];
28631             },
28632             getSymbolAtLocation: function (node) {
28633                 node = ts.getParseTreeNode(node);
28634                 return node ? getSymbolAtLocation(node, true) : undefined;
28635             },
28636             getShorthandAssignmentValueSymbol: function (node) {
28637                 node = ts.getParseTreeNode(node);
28638                 return node ? getShorthandAssignmentValueSymbol(node) : undefined;
28639             },
28640             getExportSpecifierLocalTargetSymbol: function (nodeIn) {
28641                 var node = ts.getParseTreeNode(nodeIn, ts.isExportSpecifier);
28642                 return node ? getExportSpecifierLocalTargetSymbol(node) : undefined;
28643             },
28644             getExportSymbolOfSymbol: function (symbol) {
28645                 return getMergedSymbol(symbol.exportSymbol || symbol);
28646             },
28647             getTypeAtLocation: function (node) {
28648                 node = ts.getParseTreeNode(node);
28649                 return node ? getTypeOfNode(node) : errorType;
28650             },
28651             getTypeOfAssignmentPattern: function (nodeIn) {
28652                 var node = ts.getParseTreeNode(nodeIn, ts.isAssignmentPattern);
28653                 return node && getTypeOfAssignmentPattern(node) || errorType;
28654             },
28655             getPropertySymbolOfDestructuringAssignment: function (locationIn) {
28656                 var location = ts.getParseTreeNode(locationIn, ts.isIdentifier);
28657                 return location ? getPropertySymbolOfDestructuringAssignment(location) : undefined;
28658             },
28659             signatureToString: function (signature, enclosingDeclaration, flags, kind) {
28660                 return signatureToString(signature, ts.getParseTreeNode(enclosingDeclaration), flags, kind);
28661             },
28662             typeToString: function (type, enclosingDeclaration, flags) {
28663                 return typeToString(type, ts.getParseTreeNode(enclosingDeclaration), flags);
28664             },
28665             symbolToString: function (symbol, enclosingDeclaration, meaning, flags) {
28666                 return symbolToString(symbol, ts.getParseTreeNode(enclosingDeclaration), meaning, flags);
28667             },
28668             typePredicateToString: function (predicate, enclosingDeclaration, flags) {
28669                 return typePredicateToString(predicate, ts.getParseTreeNode(enclosingDeclaration), flags);
28670             },
28671             writeSignature: function (signature, enclosingDeclaration, flags, kind, writer) {
28672                 return signatureToString(signature, ts.getParseTreeNode(enclosingDeclaration), flags, kind, writer);
28673             },
28674             writeType: function (type, enclosingDeclaration, flags, writer) {
28675                 return typeToString(type, ts.getParseTreeNode(enclosingDeclaration), flags, writer);
28676             },
28677             writeSymbol: function (symbol, enclosingDeclaration, meaning, flags, writer) {
28678                 return symbolToString(symbol, ts.getParseTreeNode(enclosingDeclaration), meaning, flags, writer);
28679             },
28680             writeTypePredicate: function (predicate, enclosingDeclaration, flags, writer) {
28681                 return typePredicateToString(predicate, ts.getParseTreeNode(enclosingDeclaration), flags, writer);
28682             },
28683             getAugmentedPropertiesOfType: getAugmentedPropertiesOfType,
28684             getRootSymbols: getRootSymbols,
28685             getContextualType: function (nodeIn, contextFlags) {
28686                 var node = ts.getParseTreeNode(nodeIn, ts.isExpression);
28687                 if (!node) {
28688                     return undefined;
28689                 }
28690                 var containingCall = ts.findAncestor(node, ts.isCallLikeExpression);
28691                 var containingCallResolvedSignature = containingCall && getNodeLinks(containingCall).resolvedSignature;
28692                 if (contextFlags & 4 && containingCall) {
28693                     var toMarkSkip = node;
28694                     do {
28695                         getNodeLinks(toMarkSkip).skipDirectInference = true;
28696                         toMarkSkip = toMarkSkip.parent;
28697                     } while (toMarkSkip && toMarkSkip !== containingCall);
28698                     getNodeLinks(containingCall).resolvedSignature = undefined;
28699                 }
28700                 var result = getContextualType(node, contextFlags);
28701                 if (contextFlags & 4 && containingCall) {
28702                     var toMarkSkip = node;
28703                     do {
28704                         getNodeLinks(toMarkSkip).skipDirectInference = undefined;
28705                         toMarkSkip = toMarkSkip.parent;
28706                     } while (toMarkSkip && toMarkSkip !== containingCall);
28707                     getNodeLinks(containingCall).resolvedSignature = containingCallResolvedSignature;
28708                 }
28709                 return result;
28710             },
28711             getContextualTypeForObjectLiteralElement: function (nodeIn) {
28712                 var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike);
28713                 return node ? getContextualTypeForObjectLiteralElement(node) : undefined;
28714             },
28715             getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) {
28716                 var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
28717                 return node && getContextualTypeForArgumentAtIndex(node, argIndex);
28718             },
28719             getContextualTypeForJsxAttribute: function (nodeIn) {
28720                 var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike);
28721                 return node && getContextualTypeForJsxAttribute(node);
28722             },
28723             isContextSensitive: isContextSensitive,
28724             getFullyQualifiedName: getFullyQualifiedName,
28725             getResolvedSignature: function (node, candidatesOutArray, argumentCount) {
28726                 return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0);
28727             },
28728             getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) {
28729                 return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16);
28730             },
28731             getExpandedParameters: getExpandedParameters,
28732             hasEffectiveRestParameter: hasEffectiveRestParameter,
28733             getConstantValue: function (nodeIn) {
28734                 var node = ts.getParseTreeNode(nodeIn, canHaveConstantValue);
28735                 return node ? getConstantValue(node) : undefined;
28736             },
28737             isValidPropertyAccess: function (nodeIn, propertyName) {
28738                 var node = ts.getParseTreeNode(nodeIn, ts.isPropertyAccessOrQualifiedNameOrImportTypeNode);
28739                 return !!node && isValidPropertyAccess(node, ts.escapeLeadingUnderscores(propertyName));
28740             },
28741             isValidPropertyAccessForCompletions: function (nodeIn, type, property) {
28742                 var node = ts.getParseTreeNode(nodeIn, ts.isPropertyAccessExpression);
28743                 return !!node && isValidPropertyAccessForCompletions(node, type, property);
28744             },
28745             getSignatureFromDeclaration: function (declarationIn) {
28746                 var declaration = ts.getParseTreeNode(declarationIn, ts.isFunctionLike);
28747                 return declaration ? getSignatureFromDeclaration(declaration) : undefined;
28748             },
28749             isImplementationOfOverload: function (node) {
28750                 var parsed = ts.getParseTreeNode(node, ts.isFunctionLike);
28751                 return parsed ? isImplementationOfOverload(parsed) : undefined;
28752             },
28753             getImmediateAliasedSymbol: getImmediateAliasedSymbol,
28754             getAliasedSymbol: resolveAlias,
28755             getEmitResolver: getEmitResolver,
28756             getExportsOfModule: getExportsOfModuleAsArray,
28757             getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule,
28758             getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, ts.getFirstIdentifier, getTypeArguments),
28759             getAmbientModules: getAmbientModules,
28760             getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt,
28761             isOptionalParameter: function (nodeIn) {
28762                 var node = ts.getParseTreeNode(nodeIn, ts.isParameter);
28763                 return node ? isOptionalParameter(node) : false;
28764             },
28765             tryGetMemberInModuleExports: function (name, symbol) { return tryGetMemberInModuleExports(ts.escapeLeadingUnderscores(name), symbol); },
28766             tryGetMemberInModuleExportsAndProperties: function (name, symbol) { return tryGetMemberInModuleExportsAndProperties(ts.escapeLeadingUnderscores(name), symbol); },
28767             tryFindAmbientModuleWithoutAugmentations: function (moduleName) {
28768                 return tryFindAmbientModule(moduleName, false);
28769             },
28770             getApparentType: getApparentType,
28771             getUnionType: getUnionType,
28772             isTypeAssignableTo: isTypeAssignableTo,
28773             createAnonymousType: createAnonymousType,
28774             createSignature: createSignature,
28775             createSymbol: createSymbol,
28776             createIndexInfo: createIndexInfo,
28777             getAnyType: function () { return anyType; },
28778             getStringType: function () { return stringType; },
28779             getNumberType: function () { return numberType; },
28780             createPromiseType: createPromiseType,
28781             createArrayType: createArrayType,
28782             getElementTypeOfArrayType: getElementTypeOfArrayType,
28783             getBooleanType: function () { return booleanType; },
28784             getFalseType: function (fresh) { return fresh ? falseType : regularFalseType; },
28785             getTrueType: function (fresh) { return fresh ? trueType : regularTrueType; },
28786             getVoidType: function () { return voidType; },
28787             getUndefinedType: function () { return undefinedType; },
28788             getNullType: function () { return nullType; },
28789             getESSymbolType: function () { return esSymbolType; },
28790             getNeverType: function () { return neverType; },
28791             getOptionalType: function () { return optionalType; },
28792             isSymbolAccessible: isSymbolAccessible,
28793             isArrayType: isArrayType,
28794             isTupleType: isTupleType,
28795             isArrayLikeType: isArrayLikeType,
28796             isTypeInvalidDueToUnionDiscriminant: isTypeInvalidDueToUnionDiscriminant,
28797             getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes,
28798             getSuggestedSymbolForNonexistentProperty: getSuggestedSymbolForNonexistentProperty,
28799             getSuggestionForNonexistentProperty: getSuggestionForNonexistentProperty,
28800             getSuggestedSymbolForNonexistentSymbol: function (location, name, meaning) { return getSuggestedSymbolForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); },
28801             getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); },
28802             getSuggestedSymbolForNonexistentModule: getSuggestedSymbolForNonexistentModule,
28803             getSuggestionForNonexistentExport: getSuggestionForNonexistentExport,
28804             getBaseConstraintOfType: getBaseConstraintOfType,
28805             getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 ? getDefaultFromTypeParameter(type) : undefined; },
28806             resolveName: function (name, location, meaning, excludeGlobals) {
28807                 return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, undefined, undefined, false, excludeGlobals);
28808             },
28809             getJsxNamespace: function (n) { return ts.unescapeLeadingUnderscores(getJsxNamespace(n)); },
28810             getAccessibleSymbolChain: getAccessibleSymbolChain,
28811             getTypePredicateOfSignature: getTypePredicateOfSignature,
28812             resolveExternalModuleName: function (moduleSpecifier) {
28813                 return resolveExternalModuleName(moduleSpecifier, moduleSpecifier, true);
28814             },
28815             resolveExternalModuleSymbol: resolveExternalModuleSymbol,
28816             tryGetThisTypeAt: function (node, includeGlobalThis) {
28817                 node = ts.getParseTreeNode(node);
28818                 return node && tryGetThisTypeAt(node, includeGlobalThis);
28819             },
28820             getTypeArgumentConstraint: function (nodeIn) {
28821                 var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
28822                 return node && getTypeArgumentConstraint(node);
28823             },
28824             getSuggestionDiagnostics: function (file, ct) {
28825                 if (ts.skipTypeChecking(file, compilerOptions, host)) {
28826                     return ts.emptyArray;
28827                 }
28828                 var diagnostics;
28829                 try {
28830                     cancellationToken = ct;
28831                     checkSourceFile(file);
28832                     ts.Debug.assert(!!(getNodeLinks(file).flags & 1));
28833                     diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName));
28834                     checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) {
28835                         if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 8388608))) {
28836                             (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion }));
28837                         }
28838                     });
28839                     return diagnostics || ts.emptyArray;
28840                 }
28841                 finally {
28842                     cancellationToken = undefined;
28843                 }
28844             },
28845             runWithCancellationToken: function (token, callback) {
28846                 try {
28847                     cancellationToken = token;
28848                     return callback(checker);
28849                 }
28850                 finally {
28851                     cancellationToken = undefined;
28852                 }
28853             },
28854             getLocalTypeParametersOfClassOrInterfaceOrTypeAlias: getLocalTypeParametersOfClassOrInterfaceOrTypeAlias,
28855             isDeclarationVisible: isDeclarationVisible,
28856         };
28857         function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode) {
28858             var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
28859             apparentArgumentCount = argumentCount;
28860             var res = node ? getResolvedSignature(node, candidatesOutArray, checkMode) : undefined;
28861             apparentArgumentCount = undefined;
28862             return res;
28863         }
28864         var tupleTypes = ts.createMap();
28865         var unionTypes = ts.createMap();
28866         var intersectionTypes = ts.createMap();
28867         var literalTypes = ts.createMap();
28868         var indexedAccessTypes = ts.createMap();
28869         var substitutionTypes = ts.createMap();
28870         var evolvingArrayTypes = [];
28871         var undefinedProperties = ts.createMap();
28872         var unknownSymbol = createSymbol(4, "unknown");
28873         var resolvingSymbol = createSymbol(0, "__resolving__");
28874         var anyType = createIntrinsicType(1, "any");
28875         var autoType = createIntrinsicType(1, "any");
28876         var wildcardType = createIntrinsicType(1, "any");
28877         var errorType = createIntrinsicType(1, "error");
28878         var nonInferrableAnyType = createIntrinsicType(1, "any", 524288);
28879         var unknownType = createIntrinsicType(2, "unknown");
28880         var undefinedType = createIntrinsicType(32768, "undefined");
28881         var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768, "undefined", 524288);
28882         var optionalType = createIntrinsicType(32768, "undefined");
28883         var nullType = createIntrinsicType(65536, "null");
28884         var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536, "null", 524288);
28885         var stringType = createIntrinsicType(4, "string");
28886         var numberType = createIntrinsicType(8, "number");
28887         var bigintType = createIntrinsicType(64, "bigint");
28888         var falseType = createIntrinsicType(512, "false");
28889         var regularFalseType = createIntrinsicType(512, "false");
28890         var trueType = createIntrinsicType(512, "true");
28891         var regularTrueType = createIntrinsicType(512, "true");
28892         trueType.regularType = regularTrueType;
28893         trueType.freshType = trueType;
28894         regularTrueType.regularType = regularTrueType;
28895         regularTrueType.freshType = trueType;
28896         falseType.regularType = regularFalseType;
28897         falseType.freshType = falseType;
28898         regularFalseType.regularType = regularFalseType;
28899         regularFalseType.freshType = falseType;
28900         var booleanType = createBooleanType([regularFalseType, regularTrueType]);
28901         createBooleanType([regularFalseType, trueType]);
28902         createBooleanType([falseType, regularTrueType]);
28903         createBooleanType([falseType, trueType]);
28904         var esSymbolType = createIntrinsicType(4096, "symbol");
28905         var voidType = createIntrinsicType(16384, "void");
28906         var neverType = createIntrinsicType(131072, "never");
28907         var silentNeverType = createIntrinsicType(131072, "never");
28908         var nonInferrableType = createIntrinsicType(131072, "never", 2097152);
28909         var implicitNeverType = createIntrinsicType(131072, "never");
28910         var unreachableNeverType = createIntrinsicType(131072, "never");
28911         var nonPrimitiveType = createIntrinsicType(67108864, "object");
28912         var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]);
28913         var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType;
28914         var numberOrBigIntType = getUnionType([numberType, bigintType]);
28915         var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? getRestrictiveTypeParameter(t) : t; });
28916         var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? wildcardType : t; });
28917         var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28918         var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28919         emptyJsxObjectType.objectFlags |= 4096;
28920         var emptyTypeLiteralSymbol = createSymbol(2048, "__type");
28921         emptyTypeLiteralSymbol.members = ts.createSymbolTable();
28922         var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28923         var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28924         emptyGenericType.instantiations = ts.createMap();
28925         var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28926         anyFunctionType.objectFlags |= 2097152;
28927         var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28928         var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28929         var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
28930         var markerSuperType = createTypeParameter();
28931         var markerSubType = createTypeParameter();
28932         markerSubType.constraint = markerSuperType;
28933         var markerOtherType = createTypeParameter();
28934         var noTypePredicate = createTypePredicate(1, "<<unresolved>>", 0, anyType);
28935         var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, undefined, 0, 0);
28936         var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, undefined, 0, 0);
28937         var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, undefined, 0, 0);
28938         var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, undefined, 0, 0);
28939         var enumNumberIndexInfo = createIndexInfo(stringType, true);
28940         var iterationTypesCache = ts.createMap();
28941         var noIterationTypes = {
28942             get yieldType() { return ts.Debug.fail("Not supported"); },
28943             get returnType() { return ts.Debug.fail("Not supported"); },
28944             get nextType() { return ts.Debug.fail("Not supported"); },
28945         };
28946         var anyIterationTypes = createIterationTypes(anyType, anyType, anyType);
28947         var anyIterationTypesExceptNext = createIterationTypes(anyType, anyType, unknownType);
28948         var defaultIterationTypes = createIterationTypes(neverType, anyType, undefinedType);
28949         var asyncIterationTypesResolver = {
28950             iterableCacheKey: "iterationTypesOfAsyncIterable",
28951             iteratorCacheKey: "iterationTypesOfAsyncIterator",
28952             iteratorSymbolName: "asyncIterator",
28953             getGlobalIteratorType: getGlobalAsyncIteratorType,
28954             getGlobalIterableType: getGlobalAsyncIterableType,
28955             getGlobalIterableIteratorType: getGlobalAsyncIterableIteratorType,
28956             getGlobalGeneratorType: getGlobalAsyncGeneratorType,
28957             resolveIterationType: getAwaitedType,
28958             mustHaveANextMethodDiagnostic: ts.Diagnostics.An_async_iterator_must_have_a_next_method,
28959             mustBeAMethodDiagnostic: ts.Diagnostics.The_0_property_of_an_async_iterator_must_be_a_method,
28960             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,
28961         };
28962         var syncIterationTypesResolver = {
28963             iterableCacheKey: "iterationTypesOfIterable",
28964             iteratorCacheKey: "iterationTypesOfIterator",
28965             iteratorSymbolName: "iterator",
28966             getGlobalIteratorType: getGlobalIteratorType,
28967             getGlobalIterableType: getGlobalIterableType,
28968             getGlobalIterableIteratorType: getGlobalIterableIteratorType,
28969             getGlobalGeneratorType: getGlobalGeneratorType,
28970             resolveIterationType: function (type, _errorNode) { return type; },
28971             mustHaveANextMethodDiagnostic: ts.Diagnostics.An_iterator_must_have_a_next_method,
28972             mustBeAMethodDiagnostic: ts.Diagnostics.The_0_property_of_an_iterator_must_be_a_method,
28973             mustHaveAValueDiagnostic: ts.Diagnostics.The_type_returned_by_the_0_method_of_an_iterator_must_have_a_value_property,
28974         };
28975         var amalgamatedDuplicates;
28976         var reverseMappedCache = ts.createMap();
28977         var ambientModulesCache;
28978         var patternAmbientModules;
28979         var patternAmbientModuleAugmentations;
28980         var globalObjectType;
28981         var globalFunctionType;
28982         var globalCallableFunctionType;
28983         var globalNewableFunctionType;
28984         var globalArrayType;
28985         var globalReadonlyArrayType;
28986         var globalStringType;
28987         var globalNumberType;
28988         var globalBooleanType;
28989         var globalRegExpType;
28990         var globalThisType;
28991         var anyArrayType;
28992         var autoArrayType;
28993         var anyReadonlyArrayType;
28994         var deferredGlobalNonNullableTypeAlias;
28995         var deferredGlobalESSymbolConstructorSymbol;
28996         var deferredGlobalESSymbolType;
28997         var deferredGlobalTypedPropertyDescriptorType;
28998         var deferredGlobalPromiseType;
28999         var deferredGlobalPromiseLikeType;
29000         var deferredGlobalPromiseConstructorSymbol;
29001         var deferredGlobalPromiseConstructorLikeType;
29002         var deferredGlobalIterableType;
29003         var deferredGlobalIteratorType;
29004         var deferredGlobalIterableIteratorType;
29005         var deferredGlobalGeneratorType;
29006         var deferredGlobalIteratorYieldResultType;
29007         var deferredGlobalIteratorReturnResultType;
29008         var deferredGlobalAsyncIterableType;
29009         var deferredGlobalAsyncIteratorType;
29010         var deferredGlobalAsyncIterableIteratorType;
29011         var deferredGlobalAsyncGeneratorType;
29012         var deferredGlobalTemplateStringsArrayType;
29013         var deferredGlobalImportMetaType;
29014         var deferredGlobalExtractSymbol;
29015         var deferredGlobalOmitSymbol;
29016         var deferredGlobalBigIntType;
29017         var allPotentiallyUnusedIdentifiers = ts.createMap();
29018         var flowLoopStart = 0;
29019         var flowLoopCount = 0;
29020         var sharedFlowCount = 0;
29021         var flowAnalysisDisabled = false;
29022         var flowInvocationCount = 0;
29023         var lastFlowNode;
29024         var lastFlowNodeReachable;
29025         var flowTypeCache;
29026         var emptyStringType = getLiteralType("");
29027         var zeroType = getLiteralType(0);
29028         var zeroBigIntType = getLiteralType({ negative: false, base10Value: "0" });
29029         var resolutionTargets = [];
29030         var resolutionResults = [];
29031         var resolutionPropertyNames = [];
29032         var suggestionCount = 0;
29033         var maximumSuggestionCount = 10;
29034         var mergedSymbols = [];
29035         var symbolLinks = [];
29036         var nodeLinks = [];
29037         var flowLoopCaches = [];
29038         var flowLoopNodes = [];
29039         var flowLoopKeys = [];
29040         var flowLoopTypes = [];
29041         var sharedFlowNodes = [];
29042         var sharedFlowTypes = [];
29043         var flowNodeReachable = [];
29044         var potentialThisCollisions = [];
29045         var potentialNewTargetCollisions = [];
29046         var potentialWeakMapCollisions = [];
29047         var awaitedTypeStack = [];
29048         var diagnostics = ts.createDiagnosticCollection();
29049         var suggestionDiagnostics = ts.createDiagnosticCollection();
29050         var typeofTypesByName = ts.createMapFromTemplate({
29051             string: stringType,
29052             number: numberType,
29053             bigint: bigintType,
29054             boolean: booleanType,
29055             symbol: esSymbolType,
29056             undefined: undefinedType
29057         });
29058         var typeofType = createTypeofType();
29059         var _jsxNamespace;
29060         var _jsxFactoryEntity;
29061         var outofbandVarianceMarkerHandler;
29062         var subtypeRelation = ts.createMap();
29063         var strictSubtypeRelation = ts.createMap();
29064         var assignableRelation = ts.createMap();
29065         var comparableRelation = ts.createMap();
29066         var identityRelation = ts.createMap();
29067         var enumRelation = ts.createMap();
29068         var builtinGlobals = ts.createSymbolTable();
29069         builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol);
29070         initializeTypeChecker();
29071         return checker;
29072         function getJsxNamespace(location) {
29073             if (location) {
29074                 var file = ts.getSourceFileOfNode(location);
29075                 if (file) {
29076                     if (file.localJsxNamespace) {
29077                         return file.localJsxNamespace;
29078                     }
29079                     var jsxPragma = file.pragmas.get("jsx");
29080                     if (jsxPragma) {
29081                         var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma;
29082                         file.localJsxFactory = ts.parseIsolatedEntityName(chosenpragma.arguments.factory, languageVersion);
29083                         ts.visitNode(file.localJsxFactory, markAsSynthetic);
29084                         if (file.localJsxFactory) {
29085                             return file.localJsxNamespace = ts.getFirstIdentifier(file.localJsxFactory).escapedText;
29086                         }
29087                     }
29088                 }
29089             }
29090             if (!_jsxNamespace) {
29091                 _jsxNamespace = "React";
29092                 if (compilerOptions.jsxFactory) {
29093                     _jsxFactoryEntity = ts.parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion);
29094                     ts.visitNode(_jsxFactoryEntity, markAsSynthetic);
29095                     if (_jsxFactoryEntity) {
29096                         _jsxNamespace = ts.getFirstIdentifier(_jsxFactoryEntity).escapedText;
29097                     }
29098                 }
29099                 else if (compilerOptions.reactNamespace) {
29100                     _jsxNamespace = ts.escapeLeadingUnderscores(compilerOptions.reactNamespace);
29101                 }
29102             }
29103             if (!_jsxFactoryEntity) {
29104                 _jsxFactoryEntity = ts.createQualifiedName(ts.createIdentifier(ts.unescapeLeadingUnderscores(_jsxNamespace)), "createElement");
29105             }
29106             return _jsxNamespace;
29107             function markAsSynthetic(node) {
29108                 node.pos = -1;
29109                 node.end = -1;
29110                 return ts.visitEachChild(node, markAsSynthetic, ts.nullTransformationContext);
29111             }
29112         }
29113         function getEmitResolver(sourceFile, cancellationToken) {
29114             getDiagnostics(sourceFile, cancellationToken);
29115             return emitResolver;
29116         }
29117         function lookupOrIssueError(location, message, arg0, arg1, arg2, arg3) {
29118             var diagnostic = location
29119                 ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3)
29120                 : ts.createCompilerDiagnostic(message, arg0, arg1, arg2, arg3);
29121             var existing = diagnostics.lookup(diagnostic);
29122             if (existing) {
29123                 return existing;
29124             }
29125             else {
29126                 diagnostics.add(diagnostic);
29127                 return diagnostic;
29128             }
29129         }
29130         function error(location, message, arg0, arg1, arg2, arg3) {
29131             var diagnostic = location
29132                 ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3)
29133                 : ts.createCompilerDiagnostic(message, arg0, arg1, arg2, arg3);
29134             diagnostics.add(diagnostic);
29135             return diagnostic;
29136         }
29137         function addErrorOrSuggestion(isError, diagnostic) {
29138             if (isError) {
29139                 diagnostics.add(diagnostic);
29140             }
29141             else {
29142                 suggestionDiagnostics.add(__assign(__assign({}, diagnostic), { category: ts.DiagnosticCategory.Suggestion }));
29143             }
29144         }
29145         function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) {
29146             addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message));
29147         }
29148         function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) {
29149             var diagnostic = error(location, message, arg0, arg1, arg2, arg3);
29150             if (maybeMissingAwait) {
29151                 var related = ts.createDiagnosticForNode(location, ts.Diagnostics.Did_you_forget_to_use_await);
29152                 ts.addRelatedInfo(diagnostic, related);
29153             }
29154             return diagnostic;
29155         }
29156         function createSymbol(flags, name, checkFlags) {
29157             symbolCount++;
29158             var symbol = (new Symbol(flags | 33554432, name));
29159             symbol.checkFlags = checkFlags || 0;
29160             return symbol;
29161         }
29162         function getExcludedSymbolFlags(flags) {
29163             var result = 0;
29164             if (flags & 2)
29165                 result |= 111551;
29166             if (flags & 1)
29167                 result |= 111550;
29168             if (flags & 4)
29169                 result |= 0;
29170             if (flags & 8)
29171                 result |= 900095;
29172             if (flags & 16)
29173                 result |= 110991;
29174             if (flags & 32)
29175                 result |= 899503;
29176             if (flags & 64)
29177                 result |= 788872;
29178             if (flags & 256)
29179                 result |= 899327;
29180             if (flags & 128)
29181                 result |= 899967;
29182             if (flags & 512)
29183                 result |= 110735;
29184             if (flags & 8192)
29185                 result |= 103359;
29186             if (flags & 32768)
29187                 result |= 46015;
29188             if (flags & 65536)
29189                 result |= 78783;
29190             if (flags & 262144)
29191                 result |= 526824;
29192             if (flags & 524288)
29193                 result |= 788968;
29194             if (flags & 2097152)
29195                 result |= 2097152;
29196             return result;
29197         }
29198         function recordMergedSymbol(target, source) {
29199             if (!source.mergeId) {
29200                 source.mergeId = nextMergeId;
29201                 nextMergeId++;
29202             }
29203             mergedSymbols[source.mergeId] = target;
29204         }
29205         function cloneSymbol(symbol) {
29206             var result = createSymbol(symbol.flags, symbol.escapedName);
29207             result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
29208             result.parent = symbol.parent;
29209             if (symbol.valueDeclaration)
29210                 result.valueDeclaration = symbol.valueDeclaration;
29211             if (symbol.constEnumOnlyModule)
29212                 result.constEnumOnlyModule = true;
29213             if (symbol.members)
29214                 result.members = ts.cloneMap(symbol.members);
29215             if (symbol.exports)
29216                 result.exports = ts.cloneMap(symbol.exports);
29217             recordMergedSymbol(result, symbol);
29218             return result;
29219         }
29220         function mergeSymbol(target, source, unidirectional) {
29221             if (unidirectional === void 0) { unidirectional = false; }
29222             if (!(target.flags & getExcludedSymbolFlags(source.flags)) ||
29223                 (source.flags | target.flags) & 67108864) {
29224                 if (source === target) {
29225                     return target;
29226                 }
29227                 if (!(target.flags & 33554432)) {
29228                     var resolvedTarget = resolveSymbol(target);
29229                     if (resolvedTarget === unknownSymbol) {
29230                         return source;
29231                     }
29232                     target = cloneSymbol(resolvedTarget);
29233                 }
29234                 if (source.flags & 512 && target.flags & 512 && target.constEnumOnlyModule && !source.constEnumOnlyModule) {
29235                     target.constEnumOnlyModule = false;
29236                 }
29237                 target.flags |= source.flags;
29238                 if (source.valueDeclaration) {
29239                     ts.setValueDeclaration(target, source.valueDeclaration);
29240                 }
29241                 ts.addRange(target.declarations, source.declarations);
29242                 if (source.members) {
29243                     if (!target.members)
29244                         target.members = ts.createSymbolTable();
29245                     mergeSymbolTable(target.members, source.members, unidirectional);
29246                 }
29247                 if (source.exports) {
29248                     if (!target.exports)
29249                         target.exports = ts.createSymbolTable();
29250                     mergeSymbolTable(target.exports, source.exports, unidirectional);
29251                 }
29252                 if (!unidirectional) {
29253                     recordMergedSymbol(target, source);
29254                 }
29255             }
29256             else if (target.flags & 1024) {
29257                 if (target !== globalThisSymbol) {
29258                     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));
29259                 }
29260             }
29261             else {
29262                 var isEitherEnum = !!(target.flags & 384 || source.flags & 384);
29263                 var isEitherBlockScoped_1 = !!(target.flags & 2 || source.flags & 2);
29264                 var message = isEitherEnum
29265                     ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations
29266                     : isEitherBlockScoped_1
29267                         ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
29268                         : ts.Diagnostics.Duplicate_identifier_0;
29269                 var sourceSymbolFile = source.declarations && ts.getSourceFileOfNode(source.declarations[0]);
29270                 var targetSymbolFile = target.declarations && ts.getSourceFileOfNode(target.declarations[0]);
29271                 var symbolName_1 = symbolToString(source);
29272                 if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) {
29273                     var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 ? sourceSymbolFile : targetSymbolFile;
29274                     var secondFile_1 = firstFile_1 === sourceSymbolFile ? targetSymbolFile : sourceSymbolFile;
29275                     var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, firstFile_1.path + "|" + secondFile_1.path, function () {
29276                         return ({ firstFile: firstFile_1, secondFile: secondFile_1, conflictingSymbols: ts.createMap() });
29277                     });
29278                     var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () {
29279                         return ({ isBlockScoped: isEitherBlockScoped_1, firstFileLocations: [], secondFileLocations: [] });
29280                     });
29281                     addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
29282                     addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
29283                 }
29284                 else {
29285                     addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_1, target);
29286                     addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_1, source);
29287                 }
29288             }
29289             return target;
29290             function addDuplicateLocations(locs, symbol) {
29291                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
29292                     var decl = _a[_i];
29293                     ts.pushIfUnique(locs, decl);
29294                 }
29295             }
29296         }
29297         function addDuplicateDeclarationErrorsForSymbols(target, message, symbolName, source) {
29298             ts.forEach(target.declarations, function (node) {
29299                 addDuplicateDeclarationError(node, message, symbolName, source.declarations);
29300             });
29301         }
29302         function addDuplicateDeclarationError(node, message, symbolName, relatedNodes) {
29303             var errorNode = (ts.getExpandoInitializer(node, false) ? ts.getNameOfExpando(node) : ts.getNameOfDeclaration(node)) || node;
29304             var err = lookupOrIssueError(errorNode, message, symbolName);
29305             var _loop_6 = function (relatedNode) {
29306                 var adjustedNode = (ts.getExpandoInitializer(relatedNode, false) ? ts.getNameOfExpando(relatedNode) : ts.getNameOfDeclaration(relatedNode)) || relatedNode;
29307                 if (adjustedNode === errorNode)
29308                     return "continue";
29309                 err.relatedInformation = err.relatedInformation || [];
29310                 var leadingMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics._0_was_also_declared_here, symbolName);
29311                 var followOnMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics.and_here);
29312                 if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 || ts.compareDiagnostics(r, leadingMessage) === 0; }))
29313                     return "continue";
29314                 ts.addRelatedInfo(err, !ts.length(err.relatedInformation) ? leadingMessage : followOnMessage);
29315             };
29316             for (var _i = 0, _a = relatedNodes || ts.emptyArray; _i < _a.length; _i++) {
29317                 var relatedNode = _a[_i];
29318                 _loop_6(relatedNode);
29319             }
29320         }
29321         function combineSymbolTables(first, second) {
29322             if (!ts.hasEntries(first))
29323                 return second;
29324             if (!ts.hasEntries(second))
29325                 return first;
29326             var combined = ts.createSymbolTable();
29327             mergeSymbolTable(combined, first);
29328             mergeSymbolTable(combined, second);
29329             return combined;
29330         }
29331         function mergeSymbolTable(target, source, unidirectional) {
29332             if (unidirectional === void 0) { unidirectional = false; }
29333             source.forEach(function (sourceSymbol, id) {
29334                 var targetSymbol = target.get(id);
29335                 target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : sourceSymbol);
29336             });
29337         }
29338         function mergeModuleAugmentation(moduleName) {
29339             var _a, _b;
29340             var moduleAugmentation = moduleName.parent;
29341             if (moduleAugmentation.symbol.declarations[0] !== moduleAugmentation) {
29342                 ts.Debug.assert(moduleAugmentation.symbol.declarations.length > 1);
29343                 return;
29344             }
29345             if (ts.isGlobalScopeAugmentation(moduleAugmentation)) {
29346                 mergeSymbolTable(globals, moduleAugmentation.symbol.exports);
29347             }
29348             else {
29349                 var moduleNotFoundError = !(moduleName.parent.parent.flags & 8388608)
29350                     ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found
29351                     : undefined;
29352                 var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, true);
29353                 if (!mainModule_1) {
29354                     return;
29355                 }
29356                 mainModule_1 = resolveExternalModuleSymbol(mainModule_1);
29357                 if (mainModule_1.flags & 1920) {
29358                     if (ts.some(patternAmbientModules, function (module) { return mainModule_1 === module.symbol; })) {
29359                         var merged = mergeSymbol(moduleAugmentation.symbol, mainModule_1, true);
29360                         if (!patternAmbientModuleAugmentations) {
29361                             patternAmbientModuleAugmentations = ts.createMap();
29362                         }
29363                         patternAmbientModuleAugmentations.set(moduleName.text, merged);
29364                     }
29365                     else {
29366                         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)) {
29367                             var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports");
29368                             for (var _i = 0, _c = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _c.length; _i++) {
29369                                 var _d = _c[_i], key = _d[0], value = _d[1];
29370                                 if (resolvedExports.has(key) && !mainModule_1.exports.has(key)) {
29371                                     mergeSymbol(resolvedExports.get(key), value);
29372                                 }
29373                             }
29374                         }
29375                         mergeSymbol(mainModule_1, moduleAugmentation.symbol);
29376                     }
29377                 }
29378                 else {
29379                     error(moduleName, ts.Diagnostics.Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity, moduleName.text);
29380                 }
29381             }
29382         }
29383         function addToSymbolTable(target, source, message) {
29384             source.forEach(function (sourceSymbol, id) {
29385                 var targetSymbol = target.get(id);
29386                 if (targetSymbol) {
29387                     ts.forEach(targetSymbol.declarations, addDeclarationDiagnostic(ts.unescapeLeadingUnderscores(id), message));
29388                 }
29389                 else {
29390                     target.set(id, sourceSymbol);
29391                 }
29392             });
29393             function addDeclarationDiagnostic(id, message) {
29394                 return function (declaration) { return diagnostics.add(ts.createDiagnosticForNode(declaration, message, id)); };
29395             }
29396         }
29397         function getSymbolLinks(symbol) {
29398             if (symbol.flags & 33554432)
29399                 return symbol;
29400             var id = getSymbolId(symbol);
29401             return symbolLinks[id] || (symbolLinks[id] = new SymbolLinks());
29402         }
29403         function getNodeLinks(node) {
29404             var nodeId = getNodeId(node);
29405             return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks());
29406         }
29407         function isGlobalSourceFile(node) {
29408             return node.kind === 290 && !ts.isExternalOrCommonJsModule(node);
29409         }
29410         function getSymbol(symbols, name, meaning) {
29411             if (meaning) {
29412                 var symbol = getMergedSymbol(symbols.get(name));
29413                 if (symbol) {
29414                     ts.Debug.assert((ts.getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here.");
29415                     if (symbol.flags & meaning) {
29416                         return symbol;
29417                     }
29418                     if (symbol.flags & 2097152) {
29419                         var target = resolveAlias(symbol);
29420                         if (target === unknownSymbol || target.flags & meaning) {
29421                             return symbol;
29422                         }
29423                     }
29424                 }
29425             }
29426         }
29427         function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) {
29428             var constructorDeclaration = parameter.parent;
29429             var classDeclaration = parameter.parent.parent;
29430             var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551);
29431             var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551);
29432             if (parameterSymbol && propertySymbol) {
29433                 return [parameterSymbol, propertySymbol];
29434             }
29435             return ts.Debug.fail("There should exist two symbols, one as property declaration and one as parameter declaration");
29436         }
29437         function isBlockScopedNameDeclaredBeforeUse(declaration, usage) {
29438             var declarationFile = ts.getSourceFileOfNode(declaration);
29439             var useFile = ts.getSourceFileOfNode(usage);
29440             var declContainer = ts.getEnclosingBlockScopeContainer(declaration);
29441             if (declarationFile !== useFile) {
29442                 if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) ||
29443                     (!compilerOptions.outFile && !compilerOptions.out) ||
29444                     isInTypeQuery(usage) ||
29445                     declaration.flags & 8388608) {
29446                     return true;
29447                 }
29448                 if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
29449                     return true;
29450                 }
29451                 var sourceFiles = host.getSourceFiles();
29452                 return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile);
29453             }
29454             if (declaration.pos <= usage.pos) {
29455                 if (declaration.kind === 191) {
29456                     var errorBindingElement = ts.getAncestor(usage, 191);
29457                     if (errorBindingElement) {
29458                         return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) ||
29459                             declaration.pos < errorBindingElement.pos;
29460                     }
29461                     return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 242), usage);
29462                 }
29463                 else if (declaration.kind === 242) {
29464                     return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage);
29465                 }
29466                 else if (ts.isClassDeclaration(declaration)) {
29467                     return !ts.findAncestor(usage, function (n) { return ts.isComputedPropertyName(n) && n.parent.parent === declaration; });
29468                 }
29469                 else if (ts.isPropertyDeclaration(declaration)) {
29470                     return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, false);
29471                 }
29472                 else if (ts.isParameterPropertyDeclaration(declaration, declaration.parent)) {
29473                     return !(compilerOptions.target === 99 && !!compilerOptions.useDefineForClassFields
29474                         && ts.getContainingClass(declaration) === ts.getContainingClass(usage)
29475                         && isUsedInFunctionOrInstanceProperty(usage, declaration));
29476                 }
29477                 return true;
29478             }
29479             if (usage.parent.kind === 263 || (usage.parent.kind === 259 && usage.parent.isExportEquals)) {
29480                 return true;
29481             }
29482             if (usage.kind === 259 && usage.isExportEquals) {
29483                 return true;
29484             }
29485             if (!!(usage.flags & 4194304) || isInTypeQuery(usage) || usageInTypeDeclaration()) {
29486                 return true;
29487             }
29488             if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
29489                 if (compilerOptions.target === 99 && !!compilerOptions.useDefineForClassFields
29490                     && ts.getContainingClass(declaration)
29491                     && (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) {
29492                     return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, true);
29493                 }
29494                 else {
29495                     return true;
29496                 }
29497             }
29498             return false;
29499             function usageInTypeDeclaration() {
29500                 return !!ts.findAncestor(usage, function (node) { return ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node); });
29501             }
29502             function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) {
29503                 switch (declaration.parent.parent.kind) {
29504                     case 225:
29505                     case 230:
29506                     case 232:
29507                         if (isSameScopeDescendentOf(usage, declaration, declContainer)) {
29508                             return true;
29509                         }
29510                         break;
29511                 }
29512                 var grandparent = declaration.parent.parent;
29513                 return ts.isForInOrOfStatement(grandparent) && isSameScopeDescendentOf(usage, grandparent.expression, declContainer);
29514             }
29515             function isUsedInFunctionOrInstanceProperty(usage, declaration) {
29516                 return !!ts.findAncestor(usage, function (current) {
29517                     if (current === declContainer) {
29518                         return "quit";
29519                     }
29520                     if (ts.isFunctionLike(current)) {
29521                         return true;
29522                     }
29523                     var initializerOfProperty = current.parent &&
29524                         current.parent.kind === 159 &&
29525                         current.parent.initializer === current;
29526                     if (initializerOfProperty) {
29527                         if (ts.hasModifier(current.parent, 32)) {
29528                             if (declaration.kind === 161) {
29529                                 return true;
29530                             }
29531                         }
29532                         else {
29533                             var isDeclarationInstanceProperty = declaration.kind === 159 && !ts.hasModifier(declaration, 32);
29534                             if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) {
29535                                 return true;
29536                             }
29537                         }
29538                     }
29539                     return false;
29540                 });
29541             }
29542             function isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, stopAtAnyPropertyDeclaration) {
29543                 if (usage.end > declaration.end) {
29544                     return false;
29545                 }
29546                 var ancestorChangingReferenceScope = ts.findAncestor(usage, function (node) {
29547                     if (node === declaration) {
29548                         return "quit";
29549                     }
29550                     switch (node.kind) {
29551                         case 202:
29552                             return true;
29553                         case 159:
29554                             return stopAtAnyPropertyDeclaration &&
29555                                 (ts.isPropertyDeclaration(declaration) && node.parent === declaration.parent
29556                                     || ts.isParameterPropertyDeclaration(declaration, declaration.parent) && node.parent === declaration.parent.parent)
29557                                 ? "quit" : true;
29558                         case 223:
29559                             switch (node.parent.kind) {
29560                                 case 163:
29561                                 case 161:
29562                                 case 164:
29563                                     return true;
29564                                 default:
29565                                     return false;
29566                             }
29567                         default:
29568                             return false;
29569                     }
29570                 });
29571                 return ancestorChangingReferenceScope === undefined;
29572             }
29573         }
29574         function useOuterVariableScopeInParameter(result, location, lastLocation) {
29575             var target = ts.getEmitScriptTarget(compilerOptions);
29576             var functionLocation = location;
29577             if (ts.isParameter(lastLocation) && functionLocation.body && result.valueDeclaration.pos >= functionLocation.body.pos && result.valueDeclaration.end <= functionLocation.body.end) {
29578                 if (target >= 2) {
29579                     var links = getNodeLinks(functionLocation);
29580                     if (links.declarationRequiresScopeChange === undefined) {
29581                         links.declarationRequiresScopeChange = ts.forEach(functionLocation.parameters, requiresScopeChange) || false;
29582                     }
29583                     return !links.declarationRequiresScopeChange;
29584                 }
29585             }
29586             return false;
29587             function requiresScopeChange(node) {
29588                 return requiresScopeChangeWorker(node.name)
29589                     || !!node.initializer && requiresScopeChangeWorker(node.initializer);
29590             }
29591             function requiresScopeChangeWorker(node) {
29592                 switch (node.kind) {
29593                     case 202:
29594                     case 201:
29595                     case 244:
29596                     case 162:
29597                         return false;
29598                     case 161:
29599                     case 163:
29600                     case 164:
29601                     case 281:
29602                         return requiresScopeChangeWorker(node.name);
29603                     case 159:
29604                         if (ts.hasStaticModifier(node)) {
29605                             return target < 99 || !compilerOptions.useDefineForClassFields;
29606                         }
29607                         return requiresScopeChangeWorker(node.name);
29608                     default:
29609                         if (ts.isNullishCoalesce(node) || ts.isOptionalChain(node)) {
29610                             return target < 7;
29611                         }
29612                         if (ts.isBindingElement(node) && node.dotDotDotToken && ts.isObjectBindingPattern(node.parent)) {
29613                             return target < 4;
29614                         }
29615                         if (ts.isTypeNode(node))
29616                             return false;
29617                         return ts.forEachChild(node, requiresScopeChangeWorker) || false;
29618                 }
29619             }
29620         }
29621         function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, suggestedNameNotFoundMessage) {
29622             if (excludeGlobals === void 0) { excludeGlobals = false; }
29623             return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol, suggestedNameNotFoundMessage);
29624         }
29625         function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup, suggestedNameNotFoundMessage) {
29626             var originalLocation = location;
29627             var result;
29628             var lastLocation;
29629             var lastSelfReferenceLocation;
29630             var propertyWithInvalidInitializer;
29631             var associatedDeclarationForContainingInitializerOrBindingName;
29632             var withinDeferredContext = false;
29633             var errorLocation = location;
29634             var grandparent;
29635             var isInExternalModule = false;
29636             loop: while (location) {
29637                 if (location.locals && !isGlobalSourceFile(location)) {
29638                     if (result = lookup(location.locals, name, meaning)) {
29639                         var useResult = true;
29640                         if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) {
29641                             if (meaning & result.flags & 788968 && lastLocation.kind !== 303) {
29642                                 useResult = result.flags & 262144
29643                                     ? lastLocation === location.type ||
29644                                         lastLocation.kind === 156 ||
29645                                         lastLocation.kind === 155
29646                                     : false;
29647                             }
29648                             if (meaning & result.flags & 3) {
29649                                 if (useOuterVariableScopeInParameter(result, location, lastLocation)) {
29650                                     useResult = false;
29651                                 }
29652                                 else if (result.flags & 1) {
29653                                     useResult =
29654                                         lastLocation.kind === 156 ||
29655                                             (lastLocation === location.type &&
29656                                                 !!ts.findAncestor(result.valueDeclaration, ts.isParameter));
29657                                 }
29658                             }
29659                         }
29660                         else if (location.kind === 180) {
29661                             useResult = lastLocation === location.trueType;
29662                         }
29663                         if (useResult) {
29664                             break loop;
29665                         }
29666                         else {
29667                             result = undefined;
29668                         }
29669                     }
29670                 }
29671                 withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation);
29672                 switch (location.kind) {
29673                     case 290:
29674                         if (!ts.isExternalOrCommonJsModule(location))
29675                             break;
29676                         isInExternalModule = true;
29677                     case 249:
29678                         var moduleExports = getSymbolOfNode(location).exports || emptySymbols;
29679                         if (location.kind === 290 || (ts.isModuleDeclaration(location) && location.flags & 8388608 && !ts.isGlobalScopeAugmentation(location))) {
29680                             if (result = moduleExports.get("default")) {
29681                                 var localSymbol = ts.getLocalSymbolForExportDefault(result);
29682                                 if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) {
29683                                     break loop;
29684                                 }
29685                                 result = undefined;
29686                             }
29687                             var moduleExport = moduleExports.get(name);
29688                             if (moduleExport &&
29689                                 moduleExport.flags === 2097152 &&
29690                                 (ts.getDeclarationOfKind(moduleExport, 263) || ts.getDeclarationOfKind(moduleExport, 262))) {
29691                                 break;
29692                             }
29693                         }
29694                         if (name !== "default" && (result = lookup(moduleExports, name, meaning & 2623475))) {
29695                             if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !result.declarations.some(ts.isJSDocTypeAlias)) {
29696                                 result = undefined;
29697                             }
29698                             else {
29699                                 break loop;
29700                             }
29701                         }
29702                         break;
29703                     case 248:
29704                         if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8)) {
29705                             break loop;
29706                         }
29707                         break;
29708                     case 159:
29709                         if (!ts.hasModifier(location, 32)) {
29710                             var ctor = findConstructorDeclaration(location.parent);
29711                             if (ctor && ctor.locals) {
29712                                 if (lookup(ctor.locals, name, meaning & 111551)) {
29713                                     propertyWithInvalidInitializer = location;
29714                                 }
29715                             }
29716                         }
29717                         break;
29718                     case 245:
29719                     case 214:
29720                     case 246:
29721                         if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968)) {
29722                             if (!isTypeParameterSymbolDeclaredInContainer(result, location)) {
29723                                 result = undefined;
29724                                 break;
29725                             }
29726                             if (lastLocation && ts.hasModifier(lastLocation, 32)) {
29727                                 error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters);
29728                                 return undefined;
29729                             }
29730                             break loop;
29731                         }
29732                         if (location.kind === 214 && meaning & 32) {
29733                             var className = location.name;
29734                             if (className && name === className.escapedText) {
29735                                 result = location.symbol;
29736                                 break loop;
29737                             }
29738                         }
29739                         break;
29740                     case 216:
29741                         if (lastLocation === location.expression && location.parent.token === 90) {
29742                             var container = location.parent.parent;
29743                             if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968))) {
29744                                 if (nameNotFoundMessage) {
29745                                     error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters);
29746                                 }
29747                                 return undefined;
29748                             }
29749                         }
29750                         break;
29751                     case 154:
29752                         grandparent = location.parent.parent;
29753                         if (ts.isClassLike(grandparent) || grandparent.kind === 246) {
29754                             if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968)) {
29755                                 error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type);
29756                                 return undefined;
29757                             }
29758                         }
29759                         break;
29760                     case 202:
29761                         if (compilerOptions.target >= 2) {
29762                             break;
29763                         }
29764                     case 161:
29765                     case 162:
29766                     case 163:
29767                     case 164:
29768                     case 244:
29769                         if (meaning & 3 && name === "arguments") {
29770                             result = argumentsSymbol;
29771                             break loop;
29772                         }
29773                         break;
29774                     case 201:
29775                         if (meaning & 3 && name === "arguments") {
29776                             result = argumentsSymbol;
29777                             break loop;
29778                         }
29779                         if (meaning & 16) {
29780                             var functionName = location.name;
29781                             if (functionName && name === functionName.escapedText) {
29782                                 result = location.symbol;
29783                                 break loop;
29784                             }
29785                         }
29786                         break;
29787                     case 157:
29788                         if (location.parent && location.parent.kind === 156) {
29789                             location = location.parent;
29790                         }
29791                         if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 245)) {
29792                             location = location.parent;
29793                         }
29794                         break;
29795                     case 322:
29796                     case 315:
29797                     case 316:
29798                         location = ts.getJSDocHost(location);
29799                         break;
29800                     case 156:
29801                         if (lastLocation && (lastLocation === location.initializer ||
29802                             lastLocation === location.name && ts.isBindingPattern(lastLocation))) {
29803                             if (!associatedDeclarationForContainingInitializerOrBindingName) {
29804                                 associatedDeclarationForContainingInitializerOrBindingName = location;
29805                             }
29806                         }
29807                         break;
29808                     case 191:
29809                         if (lastLocation && (lastLocation === location.initializer ||
29810                             lastLocation === location.name && ts.isBindingPattern(lastLocation))) {
29811                             var root = ts.getRootDeclaration(location);
29812                             if (root.kind === 156) {
29813                                 if (!associatedDeclarationForContainingInitializerOrBindingName) {
29814                                     associatedDeclarationForContainingInitializerOrBindingName = location;
29815                                 }
29816                             }
29817                         }
29818                         break;
29819                 }
29820                 if (isSelfReferenceLocation(location)) {
29821                     lastSelfReferenceLocation = location;
29822                 }
29823                 lastLocation = location;
29824                 location = location.parent;
29825             }
29826             if (isUse && result && (!lastSelfReferenceLocation || result !== lastSelfReferenceLocation.symbol)) {
29827                 result.isReferenced |= meaning;
29828             }
29829             if (!result) {
29830                 if (lastLocation) {
29831                     ts.Debug.assert(lastLocation.kind === 290);
29832                     if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) {
29833                         return lastLocation.symbol;
29834                     }
29835                 }
29836                 if (!excludeGlobals) {
29837                     result = lookup(globals, name, meaning);
29838                 }
29839             }
29840             if (!result) {
29841                 if (originalLocation && ts.isInJSFile(originalLocation) && originalLocation.parent) {
29842                     if (ts.isRequireCall(originalLocation.parent, false)) {
29843                         return requireSymbol;
29844                     }
29845                 }
29846             }
29847             if (!result) {
29848                 if (nameNotFoundMessage) {
29849                     if (!errorLocation ||
29850                         !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) &&
29851                             !checkAndReportErrorForExtendingInterface(errorLocation) &&
29852                             !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
29853                             !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
29854                             !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
29855                             !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
29856                             !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
29857                         var suggestion = void 0;
29858                         if (suggestedNameNotFoundMessage && suggestionCount < maximumSuggestionCount) {
29859                             suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
29860                             if (suggestion) {
29861                                 var suggestionName = symbolToString(suggestion);
29862                                 var diagnostic = error(errorLocation, suggestedNameNotFoundMessage, diagnosticName(nameArg), suggestionName);
29863                                 if (suggestion.valueDeclaration) {
29864                                     ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
29865                                 }
29866                             }
29867                         }
29868                         if (!suggestion) {
29869                             error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
29870                         }
29871                         suggestionCount++;
29872                     }
29873                 }
29874                 return undefined;
29875             }
29876             if (nameNotFoundMessage) {
29877                 if (propertyWithInvalidInitializer && !(compilerOptions.target === 99 && compilerOptions.useDefineForClassFields)) {
29878                     var propertyName = propertyWithInvalidInitializer.name;
29879                     error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg));
29880                     return undefined;
29881                 }
29882                 if (errorLocation &&
29883                     (meaning & 2 ||
29884                         ((meaning & 32 || meaning & 384) && (meaning & 111551) === 111551))) {
29885                     var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result);
29886                     if (exportOrLocalSymbol.flags & 2 || exportOrLocalSymbol.flags & 32 || exportOrLocalSymbol.flags & 384) {
29887                         checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
29888                     }
29889                 }
29890                 if (result && isInExternalModule && (meaning & 111551) === 111551 && !(originalLocation.flags & 4194304)) {
29891                     var merged = getMergedSymbol(result);
29892                     if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) {
29893                         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));
29894                     }
29895                 }
29896                 if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551) === 111551) {
29897                     var candidate = getMergedSymbol(getLateBoundSymbol(result));
29898                     var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName);
29899                     if (candidate === getSymbolOfNode(associatedDeclarationForContainingInitializerOrBindingName)) {
29900                         error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_itself, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name));
29901                     }
29902                     else if (candidate.valueDeclaration && candidate.valueDeclaration.pos > associatedDeclarationForContainingInitializerOrBindingName.pos && root.parent.locals && lookup(root.parent.locals, candidate.escapedName, meaning) === candidate) {
29903                         error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation));
29904                     }
29905                 }
29906                 if (result && errorLocation && meaning & 111551 && result.flags & 2097152) {
29907                     checkSymbolUsageInExpressionContext(result, name, errorLocation);
29908                 }
29909             }
29910             return result;
29911         }
29912         function checkSymbolUsageInExpressionContext(symbol, name, useSite) {
29913             if (!ts.isValidTypeOnlyAliasUseSite(useSite)) {
29914                 var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol);
29915                 if (typeOnlyDeclaration) {
29916                     var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration);
29917                     var message = isExport
29918                         ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
29919                         : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
29920                     var relatedMessage = isExport
29921                         ? ts.Diagnostics._0_was_exported_here
29922                         : ts.Diagnostics._0_was_imported_here;
29923                     var unescapedName = ts.unescapeLeadingUnderscores(name);
29924                     ts.addRelatedInfo(error(useSite, message, unescapedName), ts.createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, unescapedName));
29925                 }
29926             }
29927         }
29928         function getIsDeferredContext(location, lastLocation) {
29929             if (location.kind !== 202 && location.kind !== 201) {
29930                 return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) ||
29931                     (location.kind === 159 && !ts.hasModifier(location, 32))) && (!lastLocation || lastLocation !== location.name));
29932             }
29933             if (lastLocation && lastLocation === location.name) {
29934                 return false;
29935             }
29936             if (location.asteriskToken || ts.hasModifier(location, 256)) {
29937                 return true;
29938             }
29939             return !ts.getImmediatelyInvokedFunctionExpression(location);
29940         }
29941         function isSelfReferenceLocation(node) {
29942             switch (node.kind) {
29943                 case 244:
29944                 case 245:
29945                 case 246:
29946                 case 248:
29947                 case 247:
29948                 case 249:
29949                     return true;
29950                 default:
29951                     return false;
29952             }
29953         }
29954         function diagnosticName(nameArg) {
29955             return ts.isString(nameArg) ? ts.unescapeLeadingUnderscores(nameArg) : ts.declarationNameToString(nameArg);
29956         }
29957         function isTypeParameterSymbolDeclaredInContainer(symbol, container) {
29958             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
29959                 var decl = _a[_i];
29960                 if (decl.kind === 155) {
29961                     var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent;
29962                     if (parent === container) {
29963                         return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias));
29964                     }
29965                 }
29966             }
29967             return false;
29968         }
29969         function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) {
29970             if (!ts.isIdentifier(errorLocation) || errorLocation.escapedText !== name || isTypeReferenceIdentifier(errorLocation) || isInTypeQuery(errorLocation)) {
29971                 return false;
29972             }
29973             var container = ts.getThisContainer(errorLocation, false);
29974             var location = container;
29975             while (location) {
29976                 if (ts.isClassLike(location.parent)) {
29977                     var classSymbol = getSymbolOfNode(location.parent);
29978                     if (!classSymbol) {
29979                         break;
29980                     }
29981                     var constructorType = getTypeOfSymbol(classSymbol);
29982                     if (getPropertyOfType(constructorType, name)) {
29983                         error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0, diagnosticName(nameArg), symbolToString(classSymbol));
29984                         return true;
29985                     }
29986                     if (location === container && !ts.hasModifier(location, 32)) {
29987                         var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType;
29988                         if (getPropertyOfType(instanceType, name)) {
29989                             error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, diagnosticName(nameArg));
29990                             return true;
29991                         }
29992                     }
29993                 }
29994                 location = location.parent;
29995             }
29996             return false;
29997         }
29998         function checkAndReportErrorForExtendingInterface(errorLocation) {
29999             var expression = getEntityNameForExtendingInterface(errorLocation);
30000             if (expression && resolveEntityName(expression, 64, true)) {
30001                 error(errorLocation, ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, ts.getTextOfNode(expression));
30002                 return true;
30003             }
30004             return false;
30005         }
30006         function getEntityNameForExtendingInterface(node) {
30007             switch (node.kind) {
30008                 case 75:
30009                 case 194:
30010                     return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined;
30011                 case 216:
30012                     if (ts.isEntityNameExpression(node.expression)) {
30013                         return node.expression;
30014                     }
30015                 default:
30016                     return undefined;
30017             }
30018         }
30019         function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) {
30020             var namespaceMeaning = 1920 | (ts.isInJSFile(errorLocation) ? 111551 : 0);
30021             if (meaning === namespaceMeaning) {
30022                 var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 & ~namespaceMeaning, undefined, undefined, false));
30023                 var parent = errorLocation.parent;
30024                 if (symbol) {
30025                     if (ts.isQualifiedName(parent)) {
30026                         ts.Debug.assert(parent.left === errorLocation, "Should only be resolving left side of qualified name as a namespace");
30027                         var propName = parent.right.escapedText;
30028                         var propType = getPropertyOfType(getDeclaredTypeOfSymbol(symbol), propName);
30029                         if (propType) {
30030                             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));
30031                             return true;
30032                         }
30033                     }
30034                     error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here, ts.unescapeLeadingUnderscores(name));
30035                     return true;
30036                 }
30037             }
30038             return false;
30039         }
30040         function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) {
30041             if (meaning & (788968 & ~1920)) {
30042                 var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 & 111551, undefined, undefined, false));
30043                 if (symbol && !(symbol.flags & 1920)) {
30044                     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));
30045                     return true;
30046                 }
30047             }
30048             return false;
30049         }
30050         function isPrimitiveTypeName(name) {
30051             return name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never" || name === "unknown";
30052         }
30053         function checkAndReportErrorForExportingPrimitiveType(errorLocation, name) {
30054             if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 263) {
30055                 error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name);
30056                 return true;
30057             }
30058             return false;
30059         }
30060         function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) {
30061             if (meaning & (111551 & ~1024)) {
30062                 if (isPrimitiveTypeName(name)) {
30063                     error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name));
30064                     return true;
30065                 }
30066                 var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 & ~111551, undefined, undefined, false));
30067                 if (symbol && !(symbol.flags & 1024)) {
30068                     var message = isES2015OrLaterConstructorName(name)
30069                         ? 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
30070                         : ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here;
30071                     error(errorLocation, message, ts.unescapeLeadingUnderscores(name));
30072                     return true;
30073                 }
30074             }
30075             return false;
30076         }
30077         function isES2015OrLaterConstructorName(n) {
30078             switch (n) {
30079                 case "Promise":
30080                 case "Symbol":
30081                 case "Map":
30082                 case "WeakMap":
30083                 case "Set":
30084                 case "WeakSet":
30085                     return true;
30086             }
30087             return false;
30088         }
30089         function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) {
30090             if (meaning & (111551 & ~1024 & ~788968)) {
30091                 var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~111551, undefined, undefined, false));
30092                 if (symbol) {
30093                     error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name));
30094                     return true;
30095                 }
30096             }
30097             else if (meaning & (788968 & ~1024 & ~111551)) {
30098                 var symbol = resolveSymbol(resolveName(errorLocation, name, (512 | 1024) & ~788968, undefined, undefined, false));
30099                 if (symbol) {
30100                     error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name));
30101                     return true;
30102                 }
30103             }
30104             return false;
30105         }
30106         function checkResolvedBlockScopedVariable(result, errorLocation) {
30107             ts.Debug.assert(!!(result.flags & 2 || result.flags & 32 || result.flags & 384));
30108             if (result.flags & (16 | 1 | 67108864) && result.flags & 32) {
30109                 return;
30110             }
30111             var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 248); });
30112             if (declaration === undefined)
30113                 return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration");
30114             if (!(declaration.flags & 8388608) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) {
30115                 var diagnosticMessage = void 0;
30116                 var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration));
30117                 if (result.flags & 2) {
30118                     diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName);
30119                 }
30120                 else if (result.flags & 32) {
30121                     diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
30122                 }
30123                 else if (result.flags & 256) {
30124                     diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName);
30125                 }
30126                 else {
30127                     ts.Debug.assert(!!(result.flags & 128));
30128                     if (compilerOptions.preserveConstEnums) {
30129                         diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
30130                     }
30131                 }
30132                 if (diagnosticMessage) {
30133                     ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_is_declared_here, declarationName));
30134                 }
30135             }
30136         }
30137         function isSameScopeDescendentOf(initial, parent, stopAt) {
30138             return !!parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; });
30139         }
30140         function getAnyImportSyntax(node) {
30141             switch (node.kind) {
30142                 case 253:
30143                     return node;
30144                 case 255:
30145                     return node.parent;
30146                 case 256:
30147                     return node.parent.parent;
30148                 case 258:
30149                     return node.parent.parent.parent;
30150                 default:
30151                     return undefined;
30152             }
30153         }
30154         function getDeclarationOfAliasSymbol(symbol) {
30155             return ts.find(symbol.declarations, isAliasSymbolDeclaration);
30156         }
30157         function isAliasSymbolDeclaration(node) {
30158             return node.kind === 253 ||
30159                 node.kind === 252 ||
30160                 node.kind === 255 && !!node.name ||
30161                 node.kind === 256 ||
30162                 node.kind === 262 ||
30163                 node.kind === 258 ||
30164                 node.kind === 263 ||
30165                 node.kind === 259 && ts.exportAssignmentIsAlias(node) ||
30166                 ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 && ts.exportAssignmentIsAlias(node) ||
30167                 ts.isPropertyAccessExpression(node)
30168                     && ts.isBinaryExpression(node.parent)
30169                     && node.parent.left === node
30170                     && node.parent.operatorToken.kind === 62
30171                     && isAliasableOrJsExpression(node.parent.right) ||
30172                 node.kind === 282 ||
30173                 node.kind === 281 && isAliasableOrJsExpression(node.initializer);
30174         }
30175         function isAliasableOrJsExpression(e) {
30176             return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
30177         }
30178         function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) {
30179             if (node.moduleReference.kind === 265) {
30180                 var immediate = resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node));
30181                 var resolved_4 = resolveExternalModuleSymbol(immediate);
30182                 markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, false);
30183                 return resolved_4;
30184             }
30185             var resolved = getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias);
30186             checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved);
30187             return resolved;
30188         }
30189         function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) {
30190             if (markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false)) {
30191                 var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node));
30192                 var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration);
30193                 var message = isExport
30194                     ? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type
30195                     : ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type;
30196                 var relatedMessage = isExport
30197                     ? ts.Diagnostics._0_was_exported_here
30198                     : ts.Diagnostics._0_was_imported_here;
30199                 var name = ts.unescapeLeadingUnderscores(typeOnlyDeclaration.name.escapedText);
30200                 ts.addRelatedInfo(error(node.moduleReference, message), ts.createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, name));
30201             }
30202         }
30203         function resolveExportByName(moduleSymbol, name, sourceNode, dontResolveAlias) {
30204             var exportValue = moduleSymbol.exports.get("export=");
30205             if (exportValue) {
30206                 return getPropertyOfType(getTypeOfSymbol(exportValue), name);
30207             }
30208             var exportSymbol = moduleSymbol.exports.get(name);
30209             var resolved = resolveSymbol(exportSymbol, dontResolveAlias);
30210             markSymbolOfAliasDeclarationIfTypeOnly(sourceNode, exportSymbol, resolved, false);
30211             return resolved;
30212         }
30213         function isSyntacticDefault(node) {
30214             return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasModifier(node, 512) || ts.isExportSpecifier(node));
30215         }
30216         function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias) {
30217             if (!allowSyntheticDefaultImports) {
30218                 return false;
30219             }
30220             if (!file || file.isDeclarationFile) {
30221                 var defaultExportSymbol = resolveExportByName(moduleSymbol, "default", undefined, true);
30222                 if (defaultExportSymbol && ts.some(defaultExportSymbol.declarations, isSyntacticDefault)) {
30223                     return false;
30224                 }
30225                 if (resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), undefined, dontResolveAlias)) {
30226                     return false;
30227                 }
30228                 return true;
30229             }
30230             if (!ts.isSourceFileJS(file)) {
30231                 return hasExportAssignmentSymbol(moduleSymbol);
30232             }
30233             return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), undefined, dontResolveAlias);
30234         }
30235         function getTargetOfImportClause(node, dontResolveAlias) {
30236             var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier);
30237             if (moduleSymbol) {
30238                 var exportDefaultSymbol = void 0;
30239                 if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) {
30240                     exportDefaultSymbol = moduleSymbol;
30241                 }
30242                 else {
30243                     exportDefaultSymbol = resolveExportByName(moduleSymbol, "default", node, dontResolveAlias);
30244                 }
30245                 var file = ts.find(moduleSymbol.declarations, ts.isSourceFile);
30246                 var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias);
30247                 if (!exportDefaultSymbol && !hasSyntheticDefault) {
30248                     if (hasExportAssignmentSymbol(moduleSymbol)) {
30249                         var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop";
30250                         var exportEqualsSymbol = moduleSymbol.exports.get("export=");
30251                         var exportAssignment = exportEqualsSymbol.valueDeclaration;
30252                         var err = error(node.name, ts.Diagnostics.Module_0_can_only_be_default_imported_using_the_1_flag, symbolToString(moduleSymbol), compilerOptionName);
30253                         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));
30254                     }
30255                     else {
30256                         reportNonDefaultExport(moduleSymbol, node);
30257                     }
30258                 }
30259                 else if (hasSyntheticDefault) {
30260                     var resolved = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
30261                     markSymbolOfAliasDeclarationIfTypeOnly(node, moduleSymbol, resolved, false);
30262                     return resolved;
30263                 }
30264                 markSymbolOfAliasDeclarationIfTypeOnly(node, exportDefaultSymbol, undefined, false);
30265                 return exportDefaultSymbol;
30266             }
30267         }
30268         function reportNonDefaultExport(moduleSymbol, node) {
30269             var _a, _b;
30270             if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has(node.symbol.escapedName)) {
30271                 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));
30272             }
30273             else {
30274                 var diagnostic = error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol));
30275                 var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export");
30276                 if (exportStar) {
30277                     var defaultExport = ts.find(exportStar.declarations, function (decl) {
30278                         var _a, _b;
30279                         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")));
30280                     });
30281                     if (defaultExport) {
30282                         ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(defaultExport, ts.Diagnostics.export_Asterisk_does_not_re_export_a_default));
30283                     }
30284                 }
30285             }
30286         }
30287         function getTargetOfNamespaceImport(node, dontResolveAlias) {
30288             var moduleSpecifier = node.parent.parent.moduleSpecifier;
30289             var immediate = resolveExternalModuleName(node, moduleSpecifier);
30290             var resolved = resolveESModuleSymbol(immediate, moduleSpecifier, dontResolveAlias, false);
30291             markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved, false);
30292             return resolved;
30293         }
30294         function getTargetOfNamespaceExport(node, dontResolveAlias) {
30295             var moduleSpecifier = node.parent.moduleSpecifier;
30296             var immediate = moduleSpecifier && resolveExternalModuleName(node, moduleSpecifier);
30297             var resolved = moduleSpecifier && resolveESModuleSymbol(immediate, moduleSpecifier, dontResolveAlias, false);
30298             markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved, false);
30299             return resolved;
30300         }
30301         function combineValueAndTypeSymbols(valueSymbol, typeSymbol) {
30302             if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) {
30303                 return unknownSymbol;
30304             }
30305             if (valueSymbol.flags & (788968 | 1920)) {
30306                 return valueSymbol;
30307             }
30308             var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName);
30309             result.declarations = ts.deduplicate(ts.concatenate(valueSymbol.declarations, typeSymbol.declarations), ts.equateValues);
30310             result.parent = valueSymbol.parent || typeSymbol.parent;
30311             if (valueSymbol.valueDeclaration)
30312                 result.valueDeclaration = valueSymbol.valueDeclaration;
30313             if (typeSymbol.members)
30314                 result.members = ts.cloneMap(typeSymbol.members);
30315             if (valueSymbol.exports)
30316                 result.exports = ts.cloneMap(valueSymbol.exports);
30317             return result;
30318         }
30319         function getExportOfModule(symbol, specifier, dontResolveAlias) {
30320             var _a;
30321             if (symbol.flags & 1536) {
30322                 var name = ((_a = specifier.propertyName) !== null && _a !== void 0 ? _a : specifier.name).escapedText;
30323                 var exportSymbol = getExportsOfSymbol(symbol).get(name);
30324                 var resolved = resolveSymbol(exportSymbol, dontResolveAlias);
30325                 markSymbolOfAliasDeclarationIfTypeOnly(specifier, exportSymbol, resolved, false);
30326                 return resolved;
30327             }
30328         }
30329         function getPropertyOfVariable(symbol, name) {
30330             if (symbol.flags & 3) {
30331                 var typeAnnotation = symbol.valueDeclaration.type;
30332                 if (typeAnnotation) {
30333                     return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name));
30334                 }
30335             }
30336         }
30337         function getExternalModuleMember(node, specifier, dontResolveAlias) {
30338             var _a;
30339             if (dontResolveAlias === void 0) { dontResolveAlias = false; }
30340             var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier);
30341             var name = specifier.propertyName || specifier.name;
30342             var suppressInteropError = name.escapedText === "default" && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop);
30343             var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias, suppressInteropError);
30344             if (targetSymbol) {
30345                 if (name.escapedText) {
30346                     if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) {
30347                         return moduleSymbol;
30348                     }
30349                     var symbolFromVariable = void 0;
30350                     if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=")) {
30351                         symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.escapedText);
30352                     }
30353                     else {
30354                         symbolFromVariable = getPropertyOfVariable(targetSymbol, name.escapedText);
30355                     }
30356                     symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias);
30357                     var symbolFromModule = getExportOfModule(targetSymbol, specifier, dontResolveAlias);
30358                     if (symbolFromModule === undefined && name.escapedText === "default") {
30359                         var file = ts.find(moduleSymbol.declarations, ts.isSourceFile);
30360                         if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias)) {
30361                             symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
30362                         }
30363                     }
30364                     var symbol = symbolFromModule && symbolFromVariable && symbolFromModule !== symbolFromVariable ?
30365                         combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) :
30366                         symbolFromModule || symbolFromVariable;
30367                     if (!symbol) {
30368                         var moduleName = getFullyQualifiedName(moduleSymbol, node);
30369                         var declarationName = ts.declarationNameToString(name);
30370                         var suggestion = getSuggestedSymbolForNonexistentModule(name, targetSymbol);
30371                         if (suggestion !== undefined) {
30372                             var suggestionName = symbolToString(suggestion);
30373                             var diagnostic = error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_2, moduleName, declarationName, suggestionName);
30374                             if (suggestion.valueDeclaration) {
30375                                 ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
30376                             }
30377                         }
30378                         else {
30379                             if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has("default")) {
30380                                 error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName);
30381                             }
30382                             else {
30383                                 reportNonExportedMember(node, name, declarationName, moduleSymbol, moduleName);
30384                             }
30385                         }
30386                     }
30387                     return symbol;
30388                 }
30389             }
30390         }
30391         function reportNonExportedMember(node, name, declarationName, moduleSymbol, moduleName) {
30392             var _a;
30393             var localSymbol = (_a = moduleSymbol.valueDeclaration.locals) === null || _a === void 0 ? void 0 : _a.get(name.escapedText);
30394             var exports = moduleSymbol.exports;
30395             if (localSymbol) {
30396                 var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=");
30397                 if (exportedEqualsSymbol) {
30398                     getSymbolIfSameReference(exportedEqualsSymbol, localSymbol) ? reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) :
30399                         error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName);
30400                 }
30401                 else {
30402                     var exportedSymbol = exports ? ts.find(symbolsToArray(exports), function (symbol) { return !!getSymbolIfSameReference(symbol, localSymbol); }) : undefined;
30403                     var diagnostic = exportedSymbol ? error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_exported_as_2, moduleName, declarationName, symbolToString(exportedSymbol)) :
30404                         error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported, moduleName, declarationName);
30405                     ts.addRelatedInfo.apply(void 0, __spreadArrays([diagnostic], ts.map(localSymbol.declarations, function (decl, index) {
30406                         return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName);
30407                     })));
30408                 }
30409             }
30410             else {
30411                 error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName);
30412             }
30413         }
30414         function reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) {
30415             if (moduleKind >= ts.ModuleKind.ES2015) {
30416                 var message = compilerOptions.esModuleInterop ? ts.Diagnostics._0_can_only_be_imported_by_using_a_default_import :
30417                     ts.Diagnostics._0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
30418                 error(name, message, declarationName);
30419             }
30420             else {
30421                 if (ts.isInJSFile(node)) {
30422                     var message = compilerOptions.esModuleInterop ? ts.Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import :
30423                         ts.Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
30424                     error(name, message, declarationName);
30425                 }
30426                 else {
30427                     var message = compilerOptions.esModuleInterop ? ts.Diagnostics._0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import :
30428                         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;
30429                     error(name, message, declarationName, declarationName, moduleName);
30430                 }
30431             }
30432         }
30433         function getTargetOfImportSpecifier(node, dontResolveAlias) {
30434             var resolved = getExternalModuleMember(node.parent.parent.parent, node, dontResolveAlias);
30435             markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false);
30436             return resolved;
30437         }
30438         function getTargetOfNamespaceExportDeclaration(node, dontResolveAlias) {
30439             var resolved = resolveExternalModuleSymbol(node.parent.symbol, dontResolveAlias);
30440             markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false);
30441             return resolved;
30442         }
30443         function getTargetOfExportSpecifier(node, meaning, dontResolveAlias) {
30444             var resolved = node.parent.parent.moduleSpecifier ?
30445                 getExternalModuleMember(node.parent.parent, node, dontResolveAlias) :
30446                 resolveEntityName(node.propertyName || node.name, meaning, false, dontResolveAlias);
30447             markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false);
30448             return resolved;
30449         }
30450         function getTargetOfExportAssignment(node, dontResolveAlias) {
30451             var expression = ts.isExportAssignment(node) ? node.expression : node.right;
30452             var resolved = getTargetOfAliasLikeExpression(expression, dontResolveAlias);
30453             markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false);
30454             return resolved;
30455         }
30456         function getTargetOfAliasLikeExpression(expression, dontResolveAlias) {
30457             if (ts.isClassExpression(expression)) {
30458                 return checkExpressionCached(expression).symbol;
30459             }
30460             if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) {
30461                 return undefined;
30462             }
30463             var aliasLike = resolveEntityName(expression, 111551 | 788968 | 1920, true, dontResolveAlias);
30464             if (aliasLike) {
30465                 return aliasLike;
30466             }
30467             checkExpressionCached(expression);
30468             return getNodeLinks(expression).resolvedSymbol;
30469         }
30470         function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) {
30471             var expression = node.initializer;
30472             return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve);
30473         }
30474         function getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve) {
30475             if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62)) {
30476                 return undefined;
30477             }
30478             return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve);
30479         }
30480         function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) {
30481             if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; }
30482             switch (node.kind) {
30483                 case 253:
30484                     return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve);
30485                 case 255:
30486                     return getTargetOfImportClause(node, dontRecursivelyResolve);
30487                 case 256:
30488                     return getTargetOfNamespaceImport(node, dontRecursivelyResolve);
30489                 case 262:
30490                     return getTargetOfNamespaceExport(node, dontRecursivelyResolve);
30491                 case 258:
30492                     return getTargetOfImportSpecifier(node, dontRecursivelyResolve);
30493                 case 263:
30494                     return getTargetOfExportSpecifier(node, 111551 | 788968 | 1920, dontRecursivelyResolve);
30495                 case 259:
30496                 case 209:
30497                     return getTargetOfExportAssignment(node, dontRecursivelyResolve);
30498                 case 252:
30499                     return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve);
30500                 case 282:
30501                     return resolveEntityName(node.name, 111551 | 788968 | 1920, true, dontRecursivelyResolve);
30502                 case 281:
30503                     return getTargetOfPropertyAssignment(node, dontRecursivelyResolve);
30504                 case 194:
30505                     return getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve);
30506                 default:
30507                     return ts.Debug.fail();
30508             }
30509         }
30510         function isNonLocalAlias(symbol, excludes) {
30511             if (excludes === void 0) { excludes = 111551 | 788968 | 1920; }
30512             if (!symbol)
30513                 return false;
30514             return (symbol.flags & (2097152 | excludes)) === 2097152 || !!(symbol.flags & 2097152 && symbol.flags & 67108864);
30515         }
30516         function resolveSymbol(symbol, dontResolveAlias) {
30517             return !dontResolveAlias && isNonLocalAlias(symbol) ? resolveAlias(symbol) : symbol;
30518         }
30519         function resolveAlias(symbol) {
30520             ts.Debug.assert((symbol.flags & 2097152) !== 0, "Should only get Alias here.");
30521             var links = getSymbolLinks(symbol);
30522             if (!links.target) {
30523                 links.target = resolvingSymbol;
30524                 var node = getDeclarationOfAliasSymbol(symbol);
30525                 if (!node)
30526                     return ts.Debug.fail();
30527                 var target = getTargetOfAliasDeclaration(node);
30528                 if (links.target === resolvingSymbol) {
30529                     links.target = target || unknownSymbol;
30530                 }
30531                 else {
30532                     error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol));
30533                 }
30534             }
30535             else if (links.target === resolvingSymbol) {
30536                 links.target = unknownSymbol;
30537             }
30538             return links.target;
30539         }
30540         function tryResolveAlias(symbol) {
30541             var links = getSymbolLinks(symbol);
30542             if (links.target !== resolvingSymbol) {
30543                 return resolveAlias(symbol);
30544             }
30545             return undefined;
30546         }
30547         function markSymbolOfAliasDeclarationIfTypeOnly(aliasDeclaration, immediateTarget, finalTarget, overwriteEmpty) {
30548             if (!aliasDeclaration)
30549                 return false;
30550             var sourceSymbol = getSymbolOfNode(aliasDeclaration);
30551             if (ts.isTypeOnlyImportOrExportDeclaration(aliasDeclaration)) {
30552                 var links_1 = getSymbolLinks(sourceSymbol);
30553                 links_1.typeOnlyDeclaration = aliasDeclaration;
30554                 return true;
30555             }
30556             var links = getSymbolLinks(sourceSymbol);
30557             return markSymbolOfAliasDeclarationIfTypeOnlyWorker(links, immediateTarget, overwriteEmpty)
30558                 || markSymbolOfAliasDeclarationIfTypeOnlyWorker(links, finalTarget, overwriteEmpty);
30559         }
30560         function markSymbolOfAliasDeclarationIfTypeOnlyWorker(aliasDeclarationLinks, target, overwriteEmpty) {
30561             var _a, _b, _c;
30562             if (target && (aliasDeclarationLinks.typeOnlyDeclaration === undefined || overwriteEmpty && aliasDeclarationLinks.typeOnlyDeclaration === false)) {
30563                 var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=")) !== null && _b !== void 0 ? _b : target;
30564                 var typeOnly = exportSymbol.declarations && ts.find(exportSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration);
30565                 aliasDeclarationLinks.typeOnlyDeclaration = (_c = typeOnly !== null && typeOnly !== void 0 ? typeOnly : getSymbolLinks(exportSymbol).typeOnlyDeclaration) !== null && _c !== void 0 ? _c : false;
30566             }
30567             return !!aliasDeclarationLinks.typeOnlyDeclaration;
30568         }
30569         function getTypeOnlyAliasDeclaration(symbol) {
30570             if (!(symbol.flags & 2097152)) {
30571                 return undefined;
30572             }
30573             var links = getSymbolLinks(symbol);
30574             return links.typeOnlyDeclaration || undefined;
30575         }
30576         function markExportAsReferenced(node) {
30577             var symbol = getSymbolOfNode(node);
30578             var target = resolveAlias(symbol);
30579             if (target) {
30580                 var markAlias = target === unknownSymbol ||
30581                     ((target.flags & 111551) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol));
30582                 if (markAlias) {
30583                     markAliasSymbolAsReferenced(symbol);
30584                 }
30585             }
30586         }
30587         function markAliasSymbolAsReferenced(symbol) {
30588             var links = getSymbolLinks(symbol);
30589             if (!links.referenced) {
30590                 links.referenced = true;
30591                 var node = getDeclarationOfAliasSymbol(symbol);
30592                 if (!node)
30593                     return ts.Debug.fail();
30594                 if (ts.isInternalModuleImportEqualsDeclaration(node)) {
30595                     var target = resolveSymbol(symbol);
30596                     if (target === unknownSymbol || target.flags & 111551) {
30597                         checkExpressionCached(node.moduleReference);
30598                     }
30599                 }
30600             }
30601         }
30602         function markConstEnumAliasAsReferenced(symbol) {
30603             var links = getSymbolLinks(symbol);
30604             if (!links.constEnumReferenced) {
30605                 links.constEnumReferenced = true;
30606             }
30607         }
30608         function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) {
30609             if (entityName.kind === 75 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) {
30610                 entityName = entityName.parent;
30611             }
30612             if (entityName.kind === 75 || entityName.parent.kind === 153) {
30613                 return resolveEntityName(entityName, 1920, false, dontResolveAlias);
30614             }
30615             else {
30616                 ts.Debug.assert(entityName.parent.kind === 253);
30617                 return resolveEntityName(entityName, 111551 | 788968 | 1920, false, dontResolveAlias);
30618             }
30619         }
30620         function getFullyQualifiedName(symbol, containingLocation) {
30621             return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, undefined, 16 | 4);
30622         }
30623         function resolveEntityName(name, meaning, ignoreErrors, dontResolveAlias, location) {
30624             if (ts.nodeIsMissing(name)) {
30625                 return undefined;
30626             }
30627             var namespaceMeaning = 1920 | (ts.isInJSFile(name) ? meaning & 111551 : 0);
30628             var symbol;
30629             if (name.kind === 75) {
30630                 var message = meaning === namespaceMeaning || ts.nodeIsSynthesized(name) ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name));
30631                 var symbolFromJSPrototype = ts.isInJSFile(name) && !ts.nodeIsSynthesized(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined;
30632                 symbol = getMergedSymbol(resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, true));
30633                 if (!symbol) {
30634                     return getMergedSymbol(symbolFromJSPrototype);
30635                 }
30636             }
30637             else if (name.kind === 153 || name.kind === 194) {
30638                 var left = name.kind === 153 ? name.left : name.expression;
30639                 var right = name.kind === 153 ? name.right : name.name;
30640                 var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, false, location);
30641                 if (!namespace || ts.nodeIsMissing(right)) {
30642                     return undefined;
30643                 }
30644                 else if (namespace === unknownSymbol) {
30645                     return namespace;
30646                 }
30647                 if (ts.isInJSFile(name)) {
30648                     if (namespace.valueDeclaration &&
30649                         ts.isVariableDeclaration(namespace.valueDeclaration) &&
30650                         namespace.valueDeclaration.initializer &&
30651                         isCommonJsRequire(namespace.valueDeclaration.initializer)) {
30652                         var moduleName = namespace.valueDeclaration.initializer.arguments[0];
30653                         var moduleSym = resolveExternalModuleName(moduleName, moduleName);
30654                         if (moduleSym) {
30655                             var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym);
30656                             if (resolvedModuleSymbol) {
30657                                 namespace = resolvedModuleSymbol;
30658                             }
30659                         }
30660                     }
30661                 }
30662                 symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, meaning));
30663                 if (!symbol) {
30664                     if (!ignoreErrors) {
30665                         error(right, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(namespace), ts.declarationNameToString(right));
30666                     }
30667                     return undefined;
30668                 }
30669             }
30670             else {
30671                 throw ts.Debug.assertNever(name, "Unknown entity name kind.");
30672             }
30673             ts.Debug.assert((ts.getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here.");
30674             if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 || name.parent.kind === 259)) {
30675                 markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, undefined, true);
30676             }
30677             return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol);
30678         }
30679         function resolveEntityNameFromAssignmentDeclaration(name, meaning) {
30680             if (isJSDocTypeReference(name.parent)) {
30681                 var secondaryLocation = getAssignmentDeclarationLocation(name.parent);
30682                 if (secondaryLocation) {
30683                     return resolveName(secondaryLocation, name.escapedText, meaning, undefined, name, true);
30684                 }
30685             }
30686         }
30687         function getAssignmentDeclarationLocation(node) {
30688             var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 4194304) ? "quit" : ts.isJSDocTypeAlias(node); });
30689             if (typeAlias) {
30690                 return;
30691             }
30692             var host = ts.getJSDocHost(node);
30693             if (ts.isExpressionStatement(host) &&
30694                 ts.isBinaryExpression(host.expression) &&
30695                 ts.getAssignmentDeclarationKind(host.expression) === 3) {
30696                 var symbol = getSymbolOfNode(host.expression.left);
30697                 if (symbol) {
30698                     return getDeclarationOfJSPrototypeContainer(symbol);
30699                 }
30700             }
30701             if ((ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) &&
30702                 ts.isBinaryExpression(host.parent.parent) &&
30703                 ts.getAssignmentDeclarationKind(host.parent.parent) === 6) {
30704                 var symbol = getSymbolOfNode(host.parent.parent.left);
30705                 if (symbol) {
30706                     return getDeclarationOfJSPrototypeContainer(symbol);
30707                 }
30708             }
30709             var sig = ts.getEffectiveJSDocHost(node);
30710             if (sig && ts.isFunctionLike(sig)) {
30711                 var symbol = getSymbolOfNode(sig);
30712                 return symbol && symbol.valueDeclaration;
30713             }
30714         }
30715         function getDeclarationOfJSPrototypeContainer(symbol) {
30716             var decl = symbol.parent.valueDeclaration;
30717             if (!decl) {
30718                 return undefined;
30719             }
30720             var initializer = ts.isAssignmentDeclaration(decl) ? ts.getAssignedExpandoInitializer(decl) :
30721                 ts.hasOnlyExpressionInitializer(decl) ? ts.getDeclaredExpandoInitializer(decl) :
30722                     undefined;
30723             return initializer || decl;
30724         }
30725         function getExpandoSymbol(symbol) {
30726             var decl = symbol.valueDeclaration;
30727             if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 || ts.getExpandoInitializer(decl, false)) {
30728                 return undefined;
30729             }
30730             var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl);
30731             if (init) {
30732                 var initSymbol = getSymbolOfNode(init);
30733                 if (initSymbol) {
30734                     return mergeJSSymbols(initSymbol, symbol);
30735                 }
30736             }
30737         }
30738         function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) {
30739             return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : ts.Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations);
30740         }
30741         function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError, isForAugmentation) {
30742             if (isForAugmentation === void 0) { isForAugmentation = false; }
30743             return ts.isStringLiteralLike(moduleReferenceExpression)
30744                 ? resolveExternalModule(location, moduleReferenceExpression.text, moduleNotFoundError, moduleReferenceExpression, isForAugmentation)
30745                 : undefined;
30746         }
30747         function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) {
30748             if (isForAugmentation === void 0) { isForAugmentation = false; }
30749             if (ts.startsWith(moduleReference, "@types/")) {
30750                 var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
30751                 var withoutAtTypePrefix = ts.removePrefix(moduleReference, "@types/");
30752                 error(errorNode, diag, withoutAtTypePrefix, moduleReference);
30753             }
30754             var ambientModule = tryFindAmbientModule(moduleReference, true);
30755             if (ambientModule) {
30756                 return ambientModule;
30757             }
30758             var currentSourceFile = ts.getSourceFileOfNode(location);
30759             var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference);
30760             var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule);
30761             var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
30762             if (sourceFile) {
30763                 if (sourceFile.symbol) {
30764                     if (resolvedModule.isExternalLibraryImport && !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
30765                         errorOnImplicitAnyModule(false, errorNode, resolvedModule, moduleReference);
30766                     }
30767                     return getMergedSymbol(sourceFile.symbol);
30768                 }
30769                 if (moduleNotFoundError) {
30770                     error(errorNode, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName);
30771                 }
30772                 return undefined;
30773             }
30774             if (patternAmbientModules) {
30775                 var pattern = ts.findBestPatternMatch(patternAmbientModules, function (_) { return _.pattern; }, moduleReference);
30776                 if (pattern) {
30777                     var augmentation = patternAmbientModuleAugmentations && patternAmbientModuleAugmentations.get(moduleReference);
30778                     if (augmentation) {
30779                         return getMergedSymbol(augmentation);
30780                     }
30781                     return getMergedSymbol(pattern.symbol);
30782                 }
30783             }
30784             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) {
30785                 if (isForAugmentation) {
30786                     var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented;
30787                     error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName);
30788                 }
30789                 else {
30790                     errorOnImplicitAnyModule(noImplicitAny && !!moduleNotFoundError, errorNode, resolvedModule, moduleReference);
30791                 }
30792                 return undefined;
30793             }
30794             if (moduleNotFoundError) {
30795                 if (resolvedModule) {
30796                     var redirect = host.getProjectReferenceRedirect(resolvedModule.resolvedFileName);
30797                     if (redirect) {
30798                         error(errorNode, ts.Diagnostics.Output_file_0_has_not_been_built_from_source_file_1, redirect, resolvedModule.resolvedFileName);
30799                         return undefined;
30800                     }
30801                 }
30802                 if (resolutionDiagnostic) {
30803                     error(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName);
30804                 }
30805                 else {
30806                     var tsExtension = ts.tryExtractTSExtension(moduleReference);
30807                     if (tsExtension) {
30808                         var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead;
30809                         error(errorNode, diag, tsExtension, ts.removeExtension(moduleReference, tsExtension));
30810                     }
30811                     else if (!compilerOptions.resolveJsonModule &&
30812                         ts.fileExtensionIs(moduleReference, ".json") &&
30813                         ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs &&
30814                         ts.hasJsonModuleEmitEnabled(compilerOptions)) {
30815                         error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
30816                     }
30817                     else {
30818                         error(errorNode, moduleNotFoundError, moduleReference);
30819                     }
30820                 }
30821             }
30822             return undefined;
30823         }
30824         function errorOnImplicitAnyModule(isError, errorNode, _a, moduleReference) {
30825             var packageId = _a.packageId, resolvedFileName = _a.resolvedFileName;
30826             var errorInfo = !ts.isExternalModuleNameRelative(moduleReference) && packageId
30827                 ? typesPackageExists(packageId.name)
30828                     ? 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))
30829                     : 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))
30830                 : undefined;
30831             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));
30832         }
30833         function typesPackageExists(packageName) {
30834             return getPackagesSet().has(ts.getTypesPackageName(packageName));
30835         }
30836         function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) {
30837             if (moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.exports) {
30838                 var exportEquals = resolveSymbol(moduleSymbol.exports.get("export="), dontResolveAlias);
30839                 var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol));
30840                 return getMergedSymbol(exported) || moduleSymbol;
30841             }
30842             return undefined;
30843         }
30844         function getCommonJsExportEquals(exported, moduleSymbol) {
30845             if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152) {
30846                 return exported;
30847             }
30848             var links = getSymbolLinks(exported);
30849             if (links.cjsExportMerged) {
30850                 return links.cjsExportMerged;
30851             }
30852             var merged = exported.flags & 33554432 ? exported : cloneSymbol(exported);
30853             merged.flags = merged.flags | 512;
30854             if (merged.exports === undefined) {
30855                 merged.exports = ts.createSymbolTable();
30856             }
30857             moduleSymbol.exports.forEach(function (s, name) {
30858                 if (name === "export=")
30859                     return;
30860                 merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s);
30861             });
30862             getSymbolLinks(merged).cjsExportMerged = merged;
30863             return links.cjsExportMerged = merged;
30864         }
30865         function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) {
30866             var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias);
30867             if (!dontResolveAlias && symbol) {
30868                 if (!suppressInteropError && !(symbol.flags & (1536 | 3)) && !ts.getDeclarationOfKind(symbol, 290)) {
30869                     var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015
30870                         ? "allowSyntheticDefaultImports"
30871                         : "esModuleInterop";
30872                     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);
30873                     return symbol;
30874                 }
30875                 if (compilerOptions.esModuleInterop) {
30876                     var referenceParent = referencingLocation.parent;
30877                     if ((ts.isImportDeclaration(referenceParent) && ts.getNamespaceDeclarationNode(referenceParent)) ||
30878                         ts.isImportCall(referenceParent)) {
30879                         var type = getTypeOfSymbol(symbol);
30880                         var sigs = getSignaturesOfStructuredType(type, 0);
30881                         if (!sigs || !sigs.length) {
30882                             sigs = getSignaturesOfStructuredType(type, 1);
30883                         }
30884                         if (sigs && sigs.length) {
30885                             var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol);
30886                             var result = createSymbol(symbol.flags, symbol.escapedName);
30887                             result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
30888                             result.parent = symbol.parent;
30889                             result.target = symbol;
30890                             result.originatingImport = referenceParent;
30891                             if (symbol.valueDeclaration)
30892                                 result.valueDeclaration = symbol.valueDeclaration;
30893                             if (symbol.constEnumOnlyModule)
30894                                 result.constEnumOnlyModule = true;
30895                             if (symbol.members)
30896                                 result.members = ts.cloneMap(symbol.members);
30897                             if (symbol.exports)
30898                                 result.exports = ts.cloneMap(symbol.exports);
30899                             var resolvedModuleType = resolveStructuredTypeMembers(moduleType);
30900                             result.type = createAnonymousType(result, resolvedModuleType.members, ts.emptyArray, ts.emptyArray, resolvedModuleType.stringIndexInfo, resolvedModuleType.numberIndexInfo);
30901                             return result;
30902                         }
30903                     }
30904                 }
30905             }
30906             return symbol;
30907         }
30908         function hasExportAssignmentSymbol(moduleSymbol) {
30909             return moduleSymbol.exports.get("export=") !== undefined;
30910         }
30911         function getExportsOfModuleAsArray(moduleSymbol) {
30912             return symbolsToArray(getExportsOfModule(moduleSymbol));
30913         }
30914         function getExportsAndPropertiesOfModule(moduleSymbol) {
30915             var exports = getExportsOfModuleAsArray(moduleSymbol);
30916             var exportEquals = resolveExternalModuleSymbol(moduleSymbol);
30917             if (exportEquals !== moduleSymbol) {
30918                 ts.addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals)));
30919             }
30920             return exports;
30921         }
30922         function tryGetMemberInModuleExports(memberName, moduleSymbol) {
30923             var symbolTable = getExportsOfModule(moduleSymbol);
30924             if (symbolTable) {
30925                 return symbolTable.get(memberName);
30926             }
30927         }
30928         function tryGetMemberInModuleExportsAndProperties(memberName, moduleSymbol) {
30929             var symbol = tryGetMemberInModuleExports(memberName, moduleSymbol);
30930             if (symbol) {
30931                 return symbol;
30932             }
30933             var exportEquals = resolveExternalModuleSymbol(moduleSymbol);
30934             if (exportEquals === moduleSymbol) {
30935                 return undefined;
30936             }
30937             var type = getTypeOfSymbol(exportEquals);
30938             return type.flags & 131068 ||
30939                 ts.getObjectFlags(type) & 1 ||
30940                 isArrayOrTupleLikeType(type)
30941                 ? undefined
30942                 : getPropertyOfType(type, memberName);
30943         }
30944         function getExportsOfSymbol(symbol) {
30945             return symbol.flags & 6256 ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports") :
30946                 symbol.flags & 1536 ? getExportsOfModule(symbol) :
30947                     symbol.exports || emptySymbols;
30948         }
30949         function getExportsOfModule(moduleSymbol) {
30950             var links = getSymbolLinks(moduleSymbol);
30951             return links.resolvedExports || (links.resolvedExports = getExportsOfModuleWorker(moduleSymbol));
30952         }
30953         function extendExportSymbols(target, source, lookupTable, exportNode) {
30954             if (!source)
30955                 return;
30956             source.forEach(function (sourceSymbol, id) {
30957                 if (id === "default")
30958                     return;
30959                 var targetSymbol = target.get(id);
30960                 if (!targetSymbol) {
30961                     target.set(id, sourceSymbol);
30962                     if (lookupTable && exportNode) {
30963                         lookupTable.set(id, {
30964                             specifierText: ts.getTextOfNode(exportNode.moduleSpecifier)
30965                         });
30966                     }
30967                 }
30968                 else if (lookupTable && exportNode && targetSymbol && resolveSymbol(targetSymbol) !== resolveSymbol(sourceSymbol)) {
30969                     var collisionTracker = lookupTable.get(id);
30970                     if (!collisionTracker.exportsWithDuplicate) {
30971                         collisionTracker.exportsWithDuplicate = [exportNode];
30972                     }
30973                     else {
30974                         collisionTracker.exportsWithDuplicate.push(exportNode);
30975                     }
30976                 }
30977             });
30978         }
30979         function getExportsOfModuleWorker(moduleSymbol) {
30980             var visitedSymbols = [];
30981             moduleSymbol = resolveExternalModuleSymbol(moduleSymbol);
30982             return visit(moduleSymbol) || emptySymbols;
30983             function visit(symbol) {
30984                 if (!(symbol && symbol.exports && ts.pushIfUnique(visitedSymbols, symbol))) {
30985                     return;
30986                 }
30987                 var symbols = ts.cloneMap(symbol.exports);
30988                 var exportStars = symbol.exports.get("__export");
30989                 if (exportStars) {
30990                     var nestedSymbols = ts.createSymbolTable();
30991                     var lookupTable_1 = ts.createMap();
30992                     for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) {
30993                         var node = _a[_i];
30994                         var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier);
30995                         var exportedSymbols = visit(resolvedModule);
30996                         extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node);
30997                     }
30998                     lookupTable_1.forEach(function (_a, id) {
30999                         var exportsWithDuplicate = _a.exportsWithDuplicate;
31000                         if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols.has(id)) {
31001                             return;
31002                         }
31003                         for (var _i = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _i < exportsWithDuplicate_1.length; _i++) {
31004                             var node = exportsWithDuplicate_1[_i];
31005                             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)));
31006                         }
31007                     });
31008                     extendExportSymbols(symbols, nestedSymbols);
31009                 }
31010                 return symbols;
31011             }
31012         }
31013         function getMergedSymbol(symbol) {
31014             var merged;
31015             return symbol && symbol.mergeId && (merged = mergedSymbols[symbol.mergeId]) ? merged : symbol;
31016         }
31017         function getSymbolOfNode(node) {
31018             return getMergedSymbol(node.symbol && getLateBoundSymbol(node.symbol));
31019         }
31020         function getParentOfSymbol(symbol) {
31021             return getMergedSymbol(symbol.parent && getLateBoundSymbol(symbol.parent));
31022         }
31023         function getAlternativeContainingModules(symbol, enclosingDeclaration) {
31024             var containingFile = ts.getSourceFileOfNode(enclosingDeclaration);
31025             var id = "" + getNodeId(containingFile);
31026             var links = getSymbolLinks(symbol);
31027             var results;
31028             if (links.extendedContainersByFile && (results = links.extendedContainersByFile.get(id))) {
31029                 return results;
31030             }
31031             if (containingFile && containingFile.imports) {
31032                 for (var _i = 0, _a = containingFile.imports; _i < _a.length; _i++) {
31033                     var importRef = _a[_i];
31034                     if (ts.nodeIsSynthesized(importRef))
31035                         continue;
31036                     var resolvedModule = resolveExternalModuleName(enclosingDeclaration, importRef, true);
31037                     if (!resolvedModule)
31038                         continue;
31039                     var ref = getAliasForSymbolInContainer(resolvedModule, symbol);
31040                     if (!ref)
31041                         continue;
31042                     results = ts.append(results, resolvedModule);
31043                 }
31044                 if (ts.length(results)) {
31045                     (links.extendedContainersByFile || (links.extendedContainersByFile = ts.createMap())).set(id, results);
31046                     return results;
31047                 }
31048             }
31049             if (links.extendedContainers) {
31050                 return links.extendedContainers;
31051             }
31052             var otherFiles = host.getSourceFiles();
31053             for (var _b = 0, otherFiles_1 = otherFiles; _b < otherFiles_1.length; _b++) {
31054                 var file = otherFiles_1[_b];
31055                 if (!ts.isExternalModule(file))
31056                     continue;
31057                 var sym = getSymbolOfNode(file);
31058                 var ref = getAliasForSymbolInContainer(sym, symbol);
31059                 if (!ref)
31060                     continue;
31061                 results = ts.append(results, sym);
31062             }
31063             return links.extendedContainers = results || ts.emptyArray;
31064         }
31065         function getContainersOfSymbol(symbol, enclosingDeclaration) {
31066             var container = getParentOfSymbol(symbol);
31067             if (container && !(symbol.flags & 262144)) {
31068                 var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer);
31069                 var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration);
31070                 if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920, false)) {
31071                     return ts.concatenate(ts.concatenate([container], additionalContainers), reexportContainers);
31072                 }
31073                 var res = ts.append(additionalContainers, container);
31074                 return ts.concatenate(res, reexportContainers);
31075             }
31076             var candidates = ts.mapDefined(symbol.declarations, function (d) {
31077                 if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) {
31078                     return getSymbolOfNode(d.parent);
31079                 }
31080                 if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 62 && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) {
31081                     if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) {
31082                         return getSymbolOfNode(ts.getSourceFileOfNode(d));
31083                     }
31084                     checkExpressionCached(d.parent.left.expression);
31085                     return getNodeLinks(d.parent.left.expression).resolvedSymbol;
31086                 }
31087             });
31088             if (!ts.length(candidates)) {
31089                 return undefined;
31090             }
31091             return ts.mapDefined(candidates, function (candidate) { return getAliasForSymbolInContainer(candidate, symbol) ? candidate : undefined; });
31092             function fileSymbolIfFileSymbolExportEqualsContainer(d) {
31093                 return container && getFileSymbolIfFileSymbolExportEqualsContainer(d, container);
31094             }
31095         }
31096         function getFileSymbolIfFileSymbolExportEqualsContainer(d, container) {
31097             var fileSymbol = getExternalModuleContainer(d);
31098             var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=");
31099             return exported && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined;
31100         }
31101         function getAliasForSymbolInContainer(container, symbol) {
31102             if (container === getParentOfSymbol(symbol)) {
31103                 return symbol;
31104             }
31105             var exportEquals = container.exports && container.exports.get("export=");
31106             if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) {
31107                 return container;
31108             }
31109             var exports = getExportsOfSymbol(container);
31110             var quick = exports.get(symbol.escapedName);
31111             if (quick && getSymbolIfSameReference(quick, symbol)) {
31112                 return quick;
31113             }
31114             return ts.forEachEntry(exports, function (exported) {
31115                 if (getSymbolIfSameReference(exported, symbol)) {
31116                     return exported;
31117                 }
31118             });
31119         }
31120         function getSymbolIfSameReference(s1, s2) {
31121             if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) {
31122                 return s1;
31123             }
31124         }
31125         function getExportSymbolOfValueSymbolIfExported(symbol) {
31126             return getMergedSymbol(symbol && (symbol.flags & 1048576) !== 0 ? symbol.exportSymbol : symbol);
31127         }
31128         function symbolIsValue(symbol) {
31129             return !!(symbol.flags & 111551 || symbol.flags & 2097152 && resolveAlias(symbol).flags & 111551 && !getTypeOnlyAliasDeclaration(symbol));
31130         }
31131         function findConstructorDeclaration(node) {
31132             var members = node.members;
31133             for (var _i = 0, members_3 = members; _i < members_3.length; _i++) {
31134                 var member = members_3[_i];
31135                 if (member.kind === 162 && ts.nodeIsPresent(member.body)) {
31136                     return member;
31137                 }
31138             }
31139         }
31140         function createType(flags) {
31141             var result = new Type(checker, flags);
31142             typeCount++;
31143             result.id = typeCount;
31144             return result;
31145         }
31146         function createIntrinsicType(kind, intrinsicName, objectFlags) {
31147             if (objectFlags === void 0) { objectFlags = 0; }
31148             var type = createType(kind);
31149             type.intrinsicName = intrinsicName;
31150             type.objectFlags = objectFlags;
31151             return type;
31152         }
31153         function createBooleanType(trueFalseTypes) {
31154             var type = getUnionType(trueFalseTypes);
31155             type.flags |= 16;
31156             type.intrinsicName = "boolean";
31157             return type;
31158         }
31159         function createObjectType(objectFlags, symbol) {
31160             var type = createType(524288);
31161             type.objectFlags = objectFlags;
31162             type.symbol = symbol;
31163             type.members = undefined;
31164             type.properties = undefined;
31165             type.callSignatures = undefined;
31166             type.constructSignatures = undefined;
31167             type.stringIndexInfo = undefined;
31168             type.numberIndexInfo = undefined;
31169             return type;
31170         }
31171         function createTypeofType() {
31172             return getUnionType(ts.arrayFrom(typeofEQFacts.keys(), getLiteralType));
31173         }
31174         function createTypeParameter(symbol) {
31175             var type = createType(262144);
31176             if (symbol)
31177                 type.symbol = symbol;
31178             return type;
31179         }
31180         function isReservedMemberName(name) {
31181             return name.charCodeAt(0) === 95 &&
31182                 name.charCodeAt(1) === 95 &&
31183                 name.charCodeAt(2) !== 95 &&
31184                 name.charCodeAt(2) !== 64 &&
31185                 name.charCodeAt(2) !== 35;
31186         }
31187         function getNamedMembers(members) {
31188             var result;
31189             members.forEach(function (symbol, id) {
31190                 if (!isReservedMemberName(id) && symbolIsValue(symbol)) {
31191                     (result || (result = [])).push(symbol);
31192                 }
31193             });
31194             return result || ts.emptyArray;
31195         }
31196         function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) {
31197             type.members = members;
31198             type.properties = members === emptySymbols ? ts.emptyArray : getNamedMembers(members);
31199             type.callSignatures = callSignatures;
31200             type.constructSignatures = constructSignatures;
31201             type.stringIndexInfo = stringIndexInfo;
31202             type.numberIndexInfo = numberIndexInfo;
31203             return type;
31204         }
31205         function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) {
31206             return setStructuredTypeMembers(createObjectType(16, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
31207         }
31208         function forEachSymbolTableInScope(enclosingDeclaration, callback) {
31209             var result;
31210             var _loop_7 = function (location) {
31211                 if (location.locals && !isGlobalSourceFile(location)) {
31212                     if (result = callback(location.locals)) {
31213                         return { value: result };
31214                     }
31215                 }
31216                 switch (location.kind) {
31217                     case 290:
31218                         if (!ts.isExternalOrCommonJsModule(location)) {
31219                             break;
31220                         }
31221                     case 249:
31222                         var sym = getSymbolOfNode(location);
31223                         if (result = callback((sym === null || sym === void 0 ? void 0 : sym.exports) || emptySymbols)) {
31224                             return { value: result };
31225                         }
31226                         break;
31227                     case 245:
31228                     case 214:
31229                     case 246:
31230                         var table_1;
31231                         (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) {
31232                             if (memberSymbol.flags & (788968 & ~67108864)) {
31233                                 (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol);
31234                             }
31235                         });
31236                         if (table_1 && (result = callback(table_1))) {
31237                             return { value: result };
31238                         }
31239                         break;
31240                 }
31241             };
31242             for (var location = enclosingDeclaration; location; location = location.parent) {
31243                 var state_2 = _loop_7(location);
31244                 if (typeof state_2 === "object")
31245                     return state_2.value;
31246             }
31247             return callback(globals);
31248         }
31249         function getQualifiedLeftMeaning(rightMeaning) {
31250             return rightMeaning === 111551 ? 111551 : 1920;
31251         }
31252         function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) {
31253             if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = ts.createMap(); }
31254             if (!(symbol && !isPropertyOrMethodDeclarationSymbol(symbol))) {
31255                 return undefined;
31256             }
31257             var id = "" + getSymbolId(symbol);
31258             var visitedSymbolTables = visitedSymbolTablesMap.get(id);
31259             if (!visitedSymbolTables) {
31260                 visitedSymbolTablesMap.set(id, visitedSymbolTables = []);
31261             }
31262             return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable);
31263             function getAccessibleSymbolChainFromSymbolTable(symbols, ignoreQualification) {
31264                 if (!ts.pushIfUnique(visitedSymbolTables, symbols)) {
31265                     return undefined;
31266                 }
31267                 var result = trySymbolTable(symbols, ignoreQualification);
31268                 visitedSymbolTables.pop();
31269                 return result;
31270             }
31271             function canQualifySymbol(symbolFromSymbolTable, meaning) {
31272                 return !needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning) ||
31273                     !!getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing, visitedSymbolTablesMap);
31274             }
31275             function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol, ignoreQualification) {
31276                 return (symbol === (resolvedAliasSymbol || symbolFromSymbolTable) || getMergedSymbol(symbol) === getMergedSymbol(resolvedAliasSymbol || symbolFromSymbolTable)) &&
31277                     !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) &&
31278                     (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning));
31279             }
31280             function trySymbolTable(symbols, ignoreQualification) {
31281                 if (isAccessible(symbols.get(symbol.escapedName), undefined, ignoreQualification)) {
31282                     return [symbol];
31283                 }
31284                 var result = ts.forEachEntry(symbols, function (symbolFromSymbolTable) {
31285                     if (symbolFromSymbolTable.flags & 2097152
31286                         && symbolFromSymbolTable.escapedName !== "export="
31287                         && symbolFromSymbolTable.escapedName !== "default"
31288                         && !(ts.isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration)))
31289                         && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration))
31290                         && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 263))) {
31291                         var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable);
31292                         var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification);
31293                         if (candidate) {
31294                             return candidate;
31295                         }
31296                     }
31297                     if (symbolFromSymbolTable.escapedName === symbol.escapedName && symbolFromSymbolTable.exportSymbol) {
31298                         if (isAccessible(getMergedSymbol(symbolFromSymbolTable.exportSymbol), undefined, ignoreQualification)) {
31299                             return [symbol];
31300                         }
31301                     }
31302                 });
31303                 return result || (symbols === globals ? getCandidateListForSymbol(globalThisSymbol, globalThisSymbol, ignoreQualification) : undefined);
31304             }
31305             function getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification) {
31306                 if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) {
31307                     return [symbolFromSymbolTable];
31308                 }
31309                 var candidateTable = getExportsOfSymbol(resolvedImportedSymbol);
31310                 var accessibleSymbolsFromExports = candidateTable && getAccessibleSymbolChainFromSymbolTable(candidateTable, true);
31311                 if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) {
31312                     return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports);
31313                 }
31314             }
31315         }
31316         function needsQualification(symbol, enclosingDeclaration, meaning) {
31317             var qualify = false;
31318             forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) {
31319                 var symbolFromSymbolTable = getMergedSymbol(symbolTable.get(symbol.escapedName));
31320                 if (!symbolFromSymbolTable) {
31321                     return false;
31322                 }
31323                 if (symbolFromSymbolTable === symbol) {
31324                     return true;
31325                 }
31326                 symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 263)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
31327                 if (symbolFromSymbolTable.flags & meaning) {
31328                     qualify = true;
31329                     return true;
31330                 }
31331                 return false;
31332             });
31333             return qualify;
31334         }
31335         function isPropertyOrMethodDeclarationSymbol(symbol) {
31336             if (symbol.declarations && symbol.declarations.length) {
31337                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
31338                     var declaration = _a[_i];
31339                     switch (declaration.kind) {
31340                         case 159:
31341                         case 161:
31342                         case 163:
31343                         case 164:
31344                             continue;
31345                         default:
31346                             return false;
31347                     }
31348                 }
31349                 return true;
31350             }
31351             return false;
31352         }
31353         function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) {
31354             var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 788968, false);
31355             return access.accessibility === 0;
31356         }
31357         function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) {
31358             var access = isSymbolAccessible(typeSymbol, enclosingDeclaration, 111551, false);
31359             return access.accessibility === 0;
31360         }
31361         function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible) {
31362             if (!ts.length(symbols))
31363                 return;
31364             var hadAccessibleChain;
31365             var earlyModuleBail = false;
31366             for (var _i = 0, _a = symbols; _i < _a.length; _i++) {
31367                 var symbol = _a[_i];
31368                 var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, false);
31369                 if (accessibleSymbolChain) {
31370                     hadAccessibleChain = symbol;
31371                     var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0], shouldComputeAliasesToMakeVisible);
31372                     if (hasAccessibleDeclarations) {
31373                         return hasAccessibleDeclarations;
31374                     }
31375                 }
31376                 else {
31377                     if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
31378                         if (shouldComputeAliasesToMakeVisible) {
31379                             earlyModuleBail = true;
31380                             continue;
31381                         }
31382                         return {
31383                             accessibility: 0
31384                         };
31385                     }
31386                 }
31387                 var containers = getContainersOfSymbol(symbol, enclosingDeclaration);
31388                 var firstDecl = !!ts.length(symbol.declarations) && ts.first(symbol.declarations);
31389                 if (!ts.length(containers) && meaning & 111551 && firstDecl && ts.isObjectLiteralExpression(firstDecl)) {
31390                     if (firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent) && firstDecl === firstDecl.parent.initializer) {
31391                         containers = [getSymbolOfNode(firstDecl.parent)];
31392                     }
31393                 }
31394                 var parentResult = isAnySymbolAccessible(containers, enclosingDeclaration, initialSymbol, initialSymbol === symbol ? getQualifiedLeftMeaning(meaning) : meaning, shouldComputeAliasesToMakeVisible);
31395                 if (parentResult) {
31396                     return parentResult;
31397                 }
31398             }
31399             if (earlyModuleBail) {
31400                 return {
31401                     accessibility: 0
31402                 };
31403             }
31404             if (hadAccessibleChain) {
31405                 return {
31406                     accessibility: 1,
31407                     errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
31408                     errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920) : undefined,
31409                 };
31410             }
31411         }
31412         function isSymbolAccessible(symbol, enclosingDeclaration, meaning, shouldComputeAliasesToMakeVisible) {
31413             if (symbol && enclosingDeclaration) {
31414                 var result = isAnySymbolAccessible([symbol], enclosingDeclaration, symbol, meaning, shouldComputeAliasesToMakeVisible);
31415                 if (result) {
31416                     return result;
31417                 }
31418                 var symbolExternalModule = ts.forEach(symbol.declarations, getExternalModuleContainer);
31419                 if (symbolExternalModule) {
31420                     var enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration);
31421                     if (symbolExternalModule !== enclosingExternalModule) {
31422                         return {
31423                             accessibility: 2,
31424                             errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning),
31425                             errorModuleName: symbolToString(symbolExternalModule)
31426                         };
31427                     }
31428                 }
31429                 return {
31430                     accessibility: 1,
31431                     errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning),
31432                 };
31433             }
31434             return { accessibility: 0 };
31435         }
31436         function getExternalModuleContainer(declaration) {
31437             var node = ts.findAncestor(declaration, hasExternalModuleSymbol);
31438             return node && getSymbolOfNode(node);
31439         }
31440         function hasExternalModuleSymbol(declaration) {
31441             return ts.isAmbientModule(declaration) || (declaration.kind === 290 && ts.isExternalOrCommonJsModule(declaration));
31442         }
31443         function hasNonGlobalAugmentationExternalModuleSymbol(declaration) {
31444             return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 290 && ts.isExternalOrCommonJsModule(declaration));
31445         }
31446         function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) {
31447             var aliasesToMakeVisible;
31448             if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 75; }), getIsDeclarationVisible)) {
31449                 return undefined;
31450             }
31451             return { accessibility: 0, aliasesToMakeVisible: aliasesToMakeVisible };
31452             function getIsDeclarationVisible(declaration) {
31453                 if (!isDeclarationVisible(declaration)) {
31454                     var anyImportSyntax = getAnyImportSyntax(declaration);
31455                     if (anyImportSyntax &&
31456                         !ts.hasModifier(anyImportSyntax, 1) &&
31457                         isDeclarationVisible(anyImportSyntax.parent)) {
31458                         return addVisibleAlias(declaration, anyImportSyntax);
31459                     }
31460                     else if (ts.isVariableDeclaration(declaration) && ts.isVariableStatement(declaration.parent.parent) &&
31461                         !ts.hasModifier(declaration.parent.parent, 1) &&
31462                         isDeclarationVisible(declaration.parent.parent.parent)) {
31463                         return addVisibleAlias(declaration, declaration.parent.parent);
31464                     }
31465                     else if (ts.isLateVisibilityPaintedStatement(declaration)
31466                         && !ts.hasModifier(declaration, 1)
31467                         && isDeclarationVisible(declaration.parent)) {
31468                         return addVisibleAlias(declaration, declaration);
31469                     }
31470                     return false;
31471                 }
31472                 return true;
31473             }
31474             function addVisibleAlias(declaration, aliasingStatement) {
31475                 if (shouldComputeAliasToMakeVisible) {
31476                     getNodeLinks(declaration).isVisible = true;
31477                     aliasesToMakeVisible = ts.appendIfUnique(aliasesToMakeVisible, aliasingStatement);
31478                 }
31479                 return true;
31480             }
31481         }
31482         function isEntityNameVisible(entityName, enclosingDeclaration) {
31483             var meaning;
31484             if (entityName.parent.kind === 172 ||
31485                 ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) ||
31486                 entityName.parent.kind === 154) {
31487                 meaning = 111551 | 1048576;
31488             }
31489             else if (entityName.kind === 153 || entityName.kind === 194 ||
31490                 entityName.parent.kind === 253) {
31491                 meaning = 1920;
31492             }
31493             else {
31494                 meaning = 788968;
31495             }
31496             var firstIdentifier = ts.getFirstIdentifier(entityName);
31497             var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, undefined, undefined, false);
31498             return (symbol && hasVisibleDeclarations(symbol, true)) || {
31499                 accessibility: 1,
31500                 errorSymbolName: ts.getTextOfNode(firstIdentifier),
31501                 errorNode: firstIdentifier
31502             };
31503         }
31504         function symbolToString(symbol, enclosingDeclaration, meaning, flags, writer) {
31505             if (flags === void 0) { flags = 4; }
31506             var nodeFlags = 70221824;
31507             if (flags & 2) {
31508                 nodeFlags |= 128;
31509             }
31510             if (flags & 1) {
31511                 nodeFlags |= 512;
31512             }
31513             if (flags & 8) {
31514                 nodeFlags |= 16384;
31515             }
31516             if (flags & 16) {
31517                 nodeFlags |= 134217728;
31518             }
31519             var builder = flags & 4 ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName;
31520             return writer ? symbolToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(symbolToStringWorker);
31521             function symbolToStringWorker(writer) {
31522                 var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags);
31523                 var printer = ts.createPrinter({ removeComments: true });
31524                 var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
31525                 printer.writeNode(4, entity, sourceFile, writer);
31526                 return writer;
31527             }
31528         }
31529         function signatureToString(signature, enclosingDeclaration, flags, kind, writer) {
31530             if (flags === void 0) { flags = 0; }
31531             return writer ? signatureToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(signatureToStringWorker);
31532             function signatureToStringWorker(writer) {
31533                 var sigOutput;
31534                 if (flags & 262144) {
31535                     sigOutput = kind === 1 ? 171 : 170;
31536                 }
31537                 else {
31538                     sigOutput = kind === 1 ? 166 : 165;
31539                 }
31540                 var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 | 512);
31541                 var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
31542                 var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
31543                 printer.writeNode(4, sig, sourceFile, ts.getTrailingSemicolonDeferringWriter(writer));
31544                 return writer;
31545             }
31546         }
31547         function typeToString(type, enclosingDeclaration, flags, writer) {
31548             if (flags === void 0) { flags = 1048576 | 16384; }
31549             if (writer === void 0) { writer = ts.createTextWriter(""); }
31550             var noTruncation = compilerOptions.noErrorTruncation || flags & 1;
31551             var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 | (noTruncation ? 1 : 0), writer);
31552             if (typeNode === undefined)
31553                 return ts.Debug.fail("should always get typenode");
31554             var options = { removeComments: true };
31555             var printer = ts.createPrinter(options);
31556             var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
31557             printer.writeNode(4, typeNode, sourceFile, writer);
31558             var result = writer.getText();
31559             var maxLength = noTruncation ? ts.noTruncationMaximumTruncationLength * 2 : ts.defaultMaximumTruncationLength * 2;
31560             if (maxLength && result && result.length >= maxLength) {
31561                 return result.substr(0, maxLength - "...".length) + "...";
31562             }
31563             return result;
31564         }
31565         function getTypeNamesForErrorDisplay(left, right) {
31566             var leftStr = symbolValueDeclarationIsContextSensitive(left.symbol) ? typeToString(left, left.symbol.valueDeclaration) : typeToString(left);
31567             var rightStr = symbolValueDeclarationIsContextSensitive(right.symbol) ? typeToString(right, right.symbol.valueDeclaration) : typeToString(right);
31568             if (leftStr === rightStr) {
31569                 leftStr = typeToString(left, undefined, 64);
31570                 rightStr = typeToString(right, undefined, 64);
31571             }
31572             return [leftStr, rightStr];
31573         }
31574         function symbolValueDeclarationIsContextSensitive(symbol) {
31575             return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration);
31576         }
31577         function toNodeBuilderFlags(flags) {
31578             if (flags === void 0) { flags = 0; }
31579             return flags & 814775659;
31580         }
31581         function createNodeBuilder() {
31582             return {
31583                 typeToTypeNode: function (type, enclosingDeclaration, flags, tracker) {
31584                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeToTypeNodeHelper(type, context); });
31585                 },
31586                 indexInfoToIndexSignatureDeclaration: function (indexInfo, kind, enclosingDeclaration, flags, tracker) {
31587                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); });
31588                 },
31589                 signatureToSignatureDeclaration: function (signature, kind, enclosingDeclaration, flags, tracker) {
31590                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return signatureToSignatureDeclarationHelper(signature, kind, context); });
31591                 },
31592                 symbolToEntityName: function (symbol, meaning, enclosingDeclaration, flags, tracker) {
31593                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToName(symbol, context, meaning, false); });
31594                 },
31595                 symbolToExpression: function (symbol, meaning, enclosingDeclaration, flags, tracker) {
31596                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToExpression(symbol, context, meaning); });
31597                 },
31598                 symbolToTypeParameterDeclarations: function (symbol, enclosingDeclaration, flags, tracker) {
31599                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParametersToTypeParameterDeclarations(symbol, context); });
31600                 },
31601                 symbolToParameterDeclaration: function (symbol, enclosingDeclaration, flags, tracker) {
31602                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToParameterDeclaration(symbol, context); });
31603                 },
31604                 typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) {
31605                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); });
31606                 },
31607                 symbolTableToDeclarationStatements: function (symbolTable, enclosingDeclaration, flags, tracker, bundled) {
31608                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolTableToDeclarationStatements(symbolTable, context, bundled); });
31609                 },
31610             };
31611             function withContext(enclosingDeclaration, flags, tracker, cb) {
31612                 ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0);
31613                 var context = {
31614                     enclosingDeclaration: enclosingDeclaration,
31615                     flags: flags || 0,
31616                     tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 ? {
31617                             getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; },
31618                             getSourceFiles: function () { return host.getSourceFiles(); },
31619                             getCurrentDirectory: function () { return host.getCurrentDirectory(); },
31620                             getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks),
31621                             useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames),
31622                             redirectTargetsMap: host.redirectTargetsMap,
31623                             getProjectReferenceRedirect: function (fileName) { return host.getProjectReferenceRedirect(fileName); },
31624                             isSourceOfProjectReferenceRedirect: function (fileName) { return host.isSourceOfProjectReferenceRedirect(fileName); },
31625                             fileExists: function (fileName) { return host.fileExists(fileName); },
31626                         } : undefined },
31627                     encounteredError: false,
31628                     visitedTypes: undefined,
31629                     symbolDepth: undefined,
31630                     inferTypeParameters: undefined,
31631                     approximateLength: 0
31632                 };
31633                 var resultingNode = cb(context);
31634                 return context.encounteredError ? undefined : resultingNode;
31635             }
31636             function checkTruncationLength(context) {
31637                 if (context.truncating)
31638                     return context.truncating;
31639                 return context.truncating = context.approximateLength > ((context.flags & 1) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength);
31640             }
31641             function typeToTypeNodeHelper(type, context) {
31642                 if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
31643                     cancellationToken.throwIfCancellationRequested();
31644                 }
31645                 var inTypeAlias = context.flags & 8388608;
31646                 context.flags &= ~8388608;
31647                 if (!type) {
31648                     if (!(context.flags & 262144)) {
31649                         context.encounteredError = true;
31650                         return undefined;
31651                     }
31652                     context.approximateLength += 3;
31653                     return ts.createKeywordTypeNode(125);
31654                 }
31655                 if (!(context.flags & 536870912)) {
31656                     type = getReducedType(type);
31657                 }
31658                 if (type.flags & 1) {
31659                     context.approximateLength += 3;
31660                     return ts.createKeywordTypeNode(125);
31661                 }
31662                 if (type.flags & 2) {
31663                     return ts.createKeywordTypeNode(148);
31664                 }
31665                 if (type.flags & 4) {
31666                     context.approximateLength += 6;
31667                     return ts.createKeywordTypeNode(143);
31668                 }
31669                 if (type.flags & 8) {
31670                     context.approximateLength += 6;
31671                     return ts.createKeywordTypeNode(140);
31672                 }
31673                 if (type.flags & 64) {
31674                     context.approximateLength += 6;
31675                     return ts.createKeywordTypeNode(151);
31676                 }
31677                 if (type.flags & 16) {
31678                     context.approximateLength += 7;
31679                     return ts.createKeywordTypeNode(128);
31680                 }
31681                 if (type.flags & 1024 && !(type.flags & 1048576)) {
31682                     var parentSymbol = getParentOfSymbol(type.symbol);
31683                     var parentName = symbolToTypeNode(parentSymbol, context, 788968);
31684                     var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type
31685                         ? parentName
31686                         : appendReferenceToType(parentName, ts.createTypeReferenceNode(ts.symbolName(type.symbol), undefined));
31687                     return enumLiteralName;
31688                 }
31689                 if (type.flags & 1056) {
31690                     return symbolToTypeNode(type.symbol, context, 788968);
31691                 }
31692                 if (type.flags & 128) {
31693                     context.approximateLength += (type.value.length + 2);
31694                     return ts.createLiteralTypeNode(ts.setEmitFlags(ts.createLiteral(type.value, !!(context.flags & 268435456)), 16777216));
31695                 }
31696                 if (type.flags & 256) {
31697                     var value = type.value;
31698                     context.approximateLength += ("" + value).length;
31699                     return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(40, ts.createLiteral(-value)) : ts.createLiteral(value));
31700                 }
31701                 if (type.flags & 2048) {
31702                     context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1;
31703                     return ts.createLiteralTypeNode((ts.createLiteral(type.value)));
31704                 }
31705                 if (type.flags & 512) {
31706                     context.approximateLength += type.intrinsicName.length;
31707                     return type.intrinsicName === "true" ? ts.createTrue() : ts.createFalse();
31708                 }
31709                 if (type.flags & 8192) {
31710                     if (!(context.flags & 1048576)) {
31711                         if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
31712                             context.approximateLength += 6;
31713                             return symbolToTypeNode(type.symbol, context, 111551);
31714                         }
31715                         if (context.tracker.reportInaccessibleUniqueSymbolError) {
31716                             context.tracker.reportInaccessibleUniqueSymbolError();
31717                         }
31718                     }
31719                     context.approximateLength += 13;
31720                     return ts.createTypeOperatorNode(147, ts.createKeywordTypeNode(144));
31721                 }
31722                 if (type.flags & 16384) {
31723                     context.approximateLength += 4;
31724                     return ts.createKeywordTypeNode(110);
31725                 }
31726                 if (type.flags & 32768) {
31727                     context.approximateLength += 9;
31728                     return ts.createKeywordTypeNode(146);
31729                 }
31730                 if (type.flags & 65536) {
31731                     context.approximateLength += 4;
31732                     return ts.createKeywordTypeNode(100);
31733                 }
31734                 if (type.flags & 131072) {
31735                     context.approximateLength += 5;
31736                     return ts.createKeywordTypeNode(137);
31737                 }
31738                 if (type.flags & 4096) {
31739                     context.approximateLength += 6;
31740                     return ts.createKeywordTypeNode(144);
31741                 }
31742                 if (type.flags & 67108864) {
31743                     context.approximateLength += 6;
31744                     return ts.createKeywordTypeNode(141);
31745                 }
31746                 if (isThisTypeParameter(type)) {
31747                     if (context.flags & 4194304) {
31748                         if (!context.encounteredError && !(context.flags & 32768)) {
31749                             context.encounteredError = true;
31750                         }
31751                         if (context.tracker.reportInaccessibleThisError) {
31752                             context.tracker.reportInaccessibleThisError();
31753                         }
31754                     }
31755                     context.approximateLength += 4;
31756                     return ts.createThis();
31757                 }
31758                 if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) {
31759                     var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
31760                     if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32))
31761                         return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes);
31762                     return symbolToTypeNode(type.aliasSymbol, context, 788968, typeArgumentNodes);
31763                 }
31764                 var objectFlags = ts.getObjectFlags(type);
31765                 if (objectFlags & 4) {
31766                     ts.Debug.assert(!!(type.flags & 524288));
31767                     return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type);
31768                 }
31769                 if (type.flags & 262144 || objectFlags & 3) {
31770                     if (type.flags & 262144 && ts.contains(context.inferTypeParameters, type)) {
31771                         context.approximateLength += (ts.symbolName(type.symbol).length + 6);
31772                         return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, undefined));
31773                     }
31774                     if (context.flags & 4 &&
31775                         type.flags & 262144 &&
31776                         !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
31777                         var name = typeParameterToName(type, context);
31778                         context.approximateLength += ts.idText(name).length;
31779                         return ts.createTypeReferenceNode(ts.createIdentifier(ts.idText(name)), undefined);
31780                     }
31781                     return type.symbol
31782                         ? symbolToTypeNode(type.symbol, context, 788968)
31783                         : ts.createTypeReferenceNode(ts.createIdentifier("?"), undefined);
31784                 }
31785                 if (type.flags & (1048576 | 2097152)) {
31786                     var types = type.flags & 1048576 ? formatUnionTypes(type.types) : type.types;
31787                     if (ts.length(types) === 1) {
31788                         return typeToTypeNodeHelper(types[0], context);
31789                     }
31790                     var typeNodes = mapToTypeNodes(types, context, true);
31791                     if (typeNodes && typeNodes.length > 0) {
31792                         var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 ? 178 : 179, typeNodes);
31793                         return unionOrIntersectionTypeNode;
31794                     }
31795                     else {
31796                         if (!context.encounteredError && !(context.flags & 262144)) {
31797                             context.encounteredError = true;
31798                         }
31799                         return undefined;
31800                     }
31801                 }
31802                 if (objectFlags & (16 | 32)) {
31803                     ts.Debug.assert(!!(type.flags & 524288));
31804                     return createAnonymousTypeNode(type);
31805                 }
31806                 if (type.flags & 4194304) {
31807                     var indexedType = type.type;
31808                     context.approximateLength += 6;
31809                     var indexTypeNode = typeToTypeNodeHelper(indexedType, context);
31810                     return ts.createTypeOperatorNode(indexTypeNode);
31811                 }
31812                 if (type.flags & 8388608) {
31813                     var objectTypeNode = typeToTypeNodeHelper(type.objectType, context);
31814                     var indexTypeNode = typeToTypeNodeHelper(type.indexType, context);
31815                     context.approximateLength += 2;
31816                     return ts.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode);
31817                 }
31818                 if (type.flags & 16777216) {
31819                     var checkTypeNode = typeToTypeNodeHelper(type.checkType, context);
31820                     var saveInferTypeParameters = context.inferTypeParameters;
31821                     context.inferTypeParameters = type.root.inferTypeParameters;
31822                     var extendsTypeNode = typeToTypeNodeHelper(type.extendsType, context);
31823                     context.inferTypeParameters = saveInferTypeParameters;
31824                     var trueTypeNode = typeToTypeNodeOrCircularityElision(getTrueTypeFromConditionalType(type));
31825                     var falseTypeNode = typeToTypeNodeOrCircularityElision(getFalseTypeFromConditionalType(type));
31826                     context.approximateLength += 15;
31827                     return ts.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode);
31828                 }
31829                 if (type.flags & 33554432) {
31830                     return typeToTypeNodeHelper(type.baseType, context);
31831                 }
31832                 return ts.Debug.fail("Should be unreachable.");
31833                 function typeToTypeNodeOrCircularityElision(type) {
31834                     var _a, _b;
31835                     if (type.flags & 1048576) {
31836                         if (context.visitedTypes && context.visitedTypes.has("" + getTypeId(type))) {
31837                             if (!(context.flags & 131072)) {
31838                                 context.encounteredError = true;
31839                                 (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.reportCyclicStructureError) === null || _b === void 0 ? void 0 : _b.call(_a);
31840                             }
31841                             return createElidedInformationPlaceholder(context);
31842                         }
31843                         return visitAndTransformType(type, function (type) { return typeToTypeNodeHelper(type, context); });
31844                     }
31845                     return typeToTypeNodeHelper(type, context);
31846                 }
31847                 function createMappedTypeNodeFromType(type) {
31848                     ts.Debug.assert(!!(type.flags & 524288));
31849                     var readonlyToken = type.declaration.readonlyToken ? ts.createToken(type.declaration.readonlyToken.kind) : undefined;
31850                     var questionToken = type.declaration.questionToken ? ts.createToken(type.declaration.questionToken.kind) : undefined;
31851                     var appropriateConstraintTypeNode;
31852                     if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
31853                         appropriateConstraintTypeNode = ts.createTypeOperatorNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context));
31854                     }
31855                     else {
31856                         appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type), context);
31857                     }
31858                     var typeParameterNode = typeParameterToDeclarationWithConstraint(getTypeParameterFromMappedType(type), context, appropriateConstraintTypeNode);
31859                     var templateTypeNode = typeToTypeNodeHelper(getTemplateTypeFromMappedType(type), context);
31860                     var mappedTypeNode = ts.createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode);
31861                     context.approximateLength += 10;
31862                     return ts.setEmitFlags(mappedTypeNode, 1);
31863                 }
31864                 function createAnonymousTypeNode(type) {
31865                     var typeId = "" + type.id;
31866                     var symbol = type.symbol;
31867                     if (symbol) {
31868                         if (isJSConstructor(symbol.valueDeclaration)) {
31869                             var isInstanceType = type === getDeclaredTypeOfClassOrInterface(symbol) ? 788968 : 111551;
31870                             return symbolToTypeNode(symbol, context, isInstanceType);
31871                         }
31872                         else if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 214 && context.flags & 2048) ||
31873                             symbol.flags & (384 | 512) ||
31874                             shouldWriteTypeOfFunctionSymbol()) {
31875                             return symbolToTypeNode(symbol, context, 111551);
31876                         }
31877                         else if (context.visitedTypes && context.visitedTypes.has(typeId)) {
31878                             var typeAlias = getTypeAliasForTypeLiteral(type);
31879                             if (typeAlias) {
31880                                 return symbolToTypeNode(typeAlias, context, 788968);
31881                             }
31882                             else {
31883                                 return createElidedInformationPlaceholder(context);
31884                             }
31885                         }
31886                         else {
31887                             return visitAndTransformType(type, createTypeNodeFromObjectType);
31888                         }
31889                     }
31890                     else {
31891                         return createTypeNodeFromObjectType(type);
31892                     }
31893                     function shouldWriteTypeOfFunctionSymbol() {
31894                         var isStaticMethodSymbol = !!(symbol.flags & 8192) &&
31895                             ts.some(symbol.declarations, function (declaration) { return ts.hasModifier(declaration, 32); });
31896                         var isNonLocalFunctionSymbol = !!(symbol.flags & 16) &&
31897                             (symbol.parent ||
31898                                 ts.forEach(symbol.declarations, function (declaration) {
31899                                     return declaration.parent.kind === 290 || declaration.parent.kind === 250;
31900                                 }));
31901                         if (isStaticMethodSymbol || isNonLocalFunctionSymbol) {
31902                             return (!!(context.flags & 4096) || (context.visitedTypes && context.visitedTypes.has(typeId))) &&
31903                                 (!(context.flags & 8) || isValueSymbolAccessible(symbol, context.enclosingDeclaration));
31904                         }
31905                     }
31906                 }
31907                 function visitAndTransformType(type, transform) {
31908                     var typeId = "" + type.id;
31909                     var isConstructorObject = ts.getObjectFlags(type) & 16 && type.symbol && type.symbol.flags & 32;
31910                     var id = ts.getObjectFlags(type) & 4 && type.node ? "N" + getNodeId(type.node) :
31911                         type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) :
31912                             undefined;
31913                     if (!context.visitedTypes) {
31914                         context.visitedTypes = ts.createMap();
31915                     }
31916                     if (id && !context.symbolDepth) {
31917                         context.symbolDepth = ts.createMap();
31918                     }
31919                     var depth;
31920                     if (id) {
31921                         depth = context.symbolDepth.get(id) || 0;
31922                         if (depth > 10) {
31923                             return createElidedInformationPlaceholder(context);
31924                         }
31925                         context.symbolDepth.set(id, depth + 1);
31926                     }
31927                     context.visitedTypes.set(typeId, true);
31928                     var result = transform(type);
31929                     context.visitedTypes.delete(typeId);
31930                     if (id) {
31931                         context.symbolDepth.set(id, depth);
31932                     }
31933                     return result;
31934                 }
31935                 function createTypeNodeFromObjectType(type) {
31936                     if (isGenericMappedType(type)) {
31937                         return createMappedTypeNodeFromType(type);
31938                     }
31939                     var resolved = resolveStructuredTypeMembers(type);
31940                     if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) {
31941                         if (!resolved.callSignatures.length && !resolved.constructSignatures.length) {
31942                             context.approximateLength += 2;
31943                             return ts.setEmitFlags(ts.createTypeLiteralNode(undefined), 1);
31944                         }
31945                         if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) {
31946                             var signature = resolved.callSignatures[0];
31947                             var signatureNode = signatureToSignatureDeclarationHelper(signature, 170, context);
31948                             return signatureNode;
31949                         }
31950                         if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) {
31951                             var signature = resolved.constructSignatures[0];
31952                             var signatureNode = signatureToSignatureDeclarationHelper(signature, 171, context);
31953                             return signatureNode;
31954                         }
31955                     }
31956                     var savedFlags = context.flags;
31957                     context.flags |= 4194304;
31958                     var members = createTypeNodesFromResolvedType(resolved);
31959                     context.flags = savedFlags;
31960                     var typeLiteralNode = ts.createTypeLiteralNode(members);
31961                     context.approximateLength += 2;
31962                     return ts.setEmitFlags(typeLiteralNode, (context.flags & 1024) ? 0 : 1);
31963                 }
31964                 function typeReferenceToTypeNode(type) {
31965                     var typeArguments = getTypeArguments(type);
31966                     if (type.target === globalArrayType || type.target === globalReadonlyArrayType) {
31967                         if (context.flags & 2) {
31968                             var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context);
31969                             return ts.createTypeReferenceNode(type.target === globalArrayType ? "Array" : "ReadonlyArray", [typeArgumentNode]);
31970                         }
31971                         var elementType = typeToTypeNodeHelper(typeArguments[0], context);
31972                         var arrayType = ts.createArrayTypeNode(elementType);
31973                         return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(138, arrayType);
31974                     }
31975                     else if (type.target.objectFlags & 8) {
31976                         if (typeArguments.length > 0) {
31977                             var arity = getTypeReferenceArity(type);
31978                             var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context);
31979                             var hasRestElement = type.target.hasRestElement;
31980                             if (tupleConstituentNodes) {
31981                                 for (var i = type.target.minLength; i < Math.min(arity, tupleConstituentNodes.length); i++) {
31982                                     tupleConstituentNodes[i] = hasRestElement && i === arity - 1 ?
31983                                         ts.createRestTypeNode(ts.createArrayTypeNode(tupleConstituentNodes[i])) :
31984                                         ts.createOptionalTypeNode(tupleConstituentNodes[i]);
31985                                 }
31986                                 var tupleTypeNode = ts.createTupleTypeNode(tupleConstituentNodes);
31987                                 return type.target.readonly ? ts.createTypeOperatorNode(138, tupleTypeNode) : tupleTypeNode;
31988                             }
31989                         }
31990                         if (context.encounteredError || (context.flags & 524288)) {
31991                             var tupleTypeNode = ts.createTupleTypeNode([]);
31992                             return type.target.readonly ? ts.createTypeOperatorNode(138, tupleTypeNode) : tupleTypeNode;
31993                         }
31994                         context.encounteredError = true;
31995                         return undefined;
31996                     }
31997                     else if (context.flags & 2048 &&
31998                         type.symbol.valueDeclaration &&
31999                         ts.isClassLike(type.symbol.valueDeclaration) &&
32000                         !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
32001                         return createAnonymousTypeNode(type);
32002                     }
32003                     else {
32004                         var outerTypeParameters = type.target.outerTypeParameters;
32005                         var i = 0;
32006                         var resultType = void 0;
32007                         if (outerTypeParameters) {
32008                             var length_2 = outerTypeParameters.length;
32009                             while (i < length_2) {
32010                                 var start = i;
32011                                 var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]);
32012                                 do {
32013                                     i++;
32014                                 } while (i < length_2 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent);
32015                                 if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) {
32016                                     var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context);
32017                                     var flags_2 = context.flags;
32018                                     context.flags |= 16;
32019                                     var ref = symbolToTypeNode(parent, context, 788968, typeArgumentSlice);
32020                                     context.flags = flags_2;
32021                                     resultType = !resultType ? ref : appendReferenceToType(resultType, ref);
32022                                 }
32023                             }
32024                         }
32025                         var typeArgumentNodes = void 0;
32026                         if (typeArguments.length > 0) {
32027                             var typeParameterCount = (type.target.typeParameters || ts.emptyArray).length;
32028                             typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context);
32029                         }
32030                         var flags = context.flags;
32031                         context.flags |= 16;
32032                         var finalRef = symbolToTypeNode(type.symbol, context, 788968, typeArgumentNodes);
32033                         context.flags = flags;
32034                         return !resultType ? finalRef : appendReferenceToType(resultType, finalRef);
32035                     }
32036                 }
32037                 function appendReferenceToType(root, ref) {
32038                     if (ts.isImportTypeNode(root)) {
32039                         var innerParams = root.typeArguments;
32040                         if (root.qualifier) {
32041                             (ts.isIdentifier(root.qualifier) ? root.qualifier : root.qualifier.right).typeArguments = innerParams;
32042                         }
32043                         root.typeArguments = ref.typeArguments;
32044                         var ids = getAccessStack(ref);
32045                         for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
32046                             var id = ids_1[_i];
32047                             root.qualifier = root.qualifier ? ts.createQualifiedName(root.qualifier, id) : id;
32048                         }
32049                         return root;
32050                     }
32051                     else {
32052                         var innerParams = root.typeArguments;
32053                         (ts.isIdentifier(root.typeName) ? root.typeName : root.typeName.right).typeArguments = innerParams;
32054                         root.typeArguments = ref.typeArguments;
32055                         var ids = getAccessStack(ref);
32056                         for (var _a = 0, ids_2 = ids; _a < ids_2.length; _a++) {
32057                             var id = ids_2[_a];
32058                             root.typeName = ts.createQualifiedName(root.typeName, id);
32059                         }
32060                         return root;
32061                     }
32062                 }
32063                 function getAccessStack(ref) {
32064                     var state = ref.typeName;
32065                     var ids = [];
32066                     while (!ts.isIdentifier(state)) {
32067                         ids.unshift(state.right);
32068                         state = state.left;
32069                     }
32070                     ids.unshift(state);
32071                     return ids;
32072                 }
32073                 function createTypeNodesFromResolvedType(resolvedType) {
32074                     if (checkTruncationLength(context)) {
32075                         return [ts.createPropertySignature(undefined, "...", undefined, undefined, undefined)];
32076                     }
32077                     var typeElements = [];
32078                     for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) {
32079                         var signature = _a[_i];
32080                         typeElements.push(signatureToSignatureDeclarationHelper(signature, 165, context));
32081                     }
32082                     for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) {
32083                         var signature = _c[_b];
32084                         typeElements.push(signatureToSignatureDeclarationHelper(signature, 166, context));
32085                     }
32086                     if (resolvedType.stringIndexInfo) {
32087                         var indexSignature = void 0;
32088                         if (resolvedType.objectFlags & 2048) {
32089                             indexSignature = indexInfoToIndexSignatureDeclarationHelper(createIndexInfo(anyType, resolvedType.stringIndexInfo.isReadonly, resolvedType.stringIndexInfo.declaration), 0, context);
32090                             indexSignature.type = createElidedInformationPlaceholder(context);
32091                         }
32092                         else {
32093                             indexSignature = indexInfoToIndexSignatureDeclarationHelper(resolvedType.stringIndexInfo, 0, context);
32094                         }
32095                         typeElements.push(indexSignature);
32096                     }
32097                     if (resolvedType.numberIndexInfo) {
32098                         typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.numberIndexInfo, 1, context));
32099                     }
32100                     var properties = resolvedType.properties;
32101                     if (!properties) {
32102                         return typeElements;
32103                     }
32104                     var i = 0;
32105                     for (var _d = 0, properties_1 = properties; _d < properties_1.length; _d++) {
32106                         var propertySymbol = properties_1[_d];
32107                         i++;
32108                         if (context.flags & 2048) {
32109                             if (propertySymbol.flags & 4194304) {
32110                                 continue;
32111                             }
32112                             if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 | 16) && context.tracker.reportPrivateInBaseOfClassExpression) {
32113                                 context.tracker.reportPrivateInBaseOfClassExpression(ts.unescapeLeadingUnderscores(propertySymbol.escapedName));
32114                             }
32115                         }
32116                         if (checkTruncationLength(context) && (i + 2 < properties.length - 1)) {
32117                             typeElements.push(ts.createPropertySignature(undefined, "... " + (properties.length - i) + " more ...", undefined, undefined, undefined));
32118                             addPropertyToElementList(properties[properties.length - 1], context, typeElements);
32119                             break;
32120                         }
32121                         addPropertyToElementList(propertySymbol, context, typeElements);
32122                     }
32123                     return typeElements.length ? typeElements : undefined;
32124                 }
32125             }
32126             function createElidedInformationPlaceholder(context) {
32127                 context.approximateLength += 3;
32128                 if (!(context.flags & 1)) {
32129                     return ts.createTypeReferenceNode(ts.createIdentifier("..."), undefined);
32130                 }
32131                 return ts.createKeywordTypeNode(125);
32132             }
32133             function addPropertyToElementList(propertySymbol, context, typeElements) {
32134                 var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192);
32135                 var propertyType = propertyIsReverseMapped && context.flags & 33554432 ?
32136                     anyType : getTypeOfSymbol(propertySymbol);
32137                 var saveEnclosingDeclaration = context.enclosingDeclaration;
32138                 context.enclosingDeclaration = undefined;
32139                 if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096) {
32140                     var decl = ts.first(propertySymbol.declarations);
32141                     if (hasLateBindableName(decl)) {
32142                         if (ts.isBinaryExpression(decl)) {
32143                             var name = ts.getNameOfDeclaration(decl);
32144                             if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) {
32145                                 trackComputedName(name.argumentExpression, saveEnclosingDeclaration, context);
32146                             }
32147                         }
32148                         else {
32149                             trackComputedName(decl.name.expression, saveEnclosingDeclaration, context);
32150                         }
32151                     }
32152                 }
32153                 context.enclosingDeclaration = saveEnclosingDeclaration;
32154                 var propertyName = getPropertyNameNodeForSymbol(propertySymbol, context);
32155                 context.approximateLength += (ts.symbolName(propertySymbol).length + 1);
32156                 var optionalToken = propertySymbol.flags & 16777216 ? ts.createToken(57) : undefined;
32157                 if (propertySymbol.flags & (16 | 8192) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) {
32158                     var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768); }), 0);
32159                     for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) {
32160                         var signature = signatures_1[_i];
32161                         var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 160, context);
32162                         methodDeclaration.name = propertyName;
32163                         methodDeclaration.questionToken = optionalToken;
32164                         typeElements.push(preserveCommentsOn(methodDeclaration));
32165                     }
32166                 }
32167                 else {
32168                     var savedFlags = context.flags;
32169                     context.flags |= propertyIsReverseMapped ? 33554432 : 0;
32170                     var propertyTypeNode = void 0;
32171                     if (propertyIsReverseMapped && !!(savedFlags & 33554432)) {
32172                         propertyTypeNode = createElidedInformationPlaceholder(context);
32173                     }
32174                     else {
32175                         propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.createKeywordTypeNode(125);
32176                     }
32177                     context.flags = savedFlags;
32178                     var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(138)] : undefined;
32179                     if (modifiers) {
32180                         context.approximateLength += 9;
32181                     }
32182                     var propertySignature = ts.createPropertySignature(modifiers, propertyName, optionalToken, propertyTypeNode, undefined);
32183                     typeElements.push(preserveCommentsOn(propertySignature));
32184                 }
32185                 function preserveCommentsOn(node) {
32186                     if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 323; })) {
32187                         var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 323; });
32188                         var commentText = d.comment;
32189                         if (commentText) {
32190                             ts.setSyntheticLeadingComments(node, [{ kind: 3, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]);
32191                         }
32192                     }
32193                     else if (propertySymbol.valueDeclaration) {
32194                         ts.setCommentRange(node, propertySymbol.valueDeclaration);
32195                     }
32196                     return node;
32197                 }
32198             }
32199             function mapToTypeNodes(types, context, isBareList) {
32200                 if (ts.some(types)) {
32201                     if (checkTruncationLength(context)) {
32202                         if (!isBareList) {
32203                             return [ts.createTypeReferenceNode("...", undefined)];
32204                         }
32205                         else if (types.length > 2) {
32206                             return [
32207                                 typeToTypeNodeHelper(types[0], context),
32208                                 ts.createTypeReferenceNode("... " + (types.length - 2) + " more ...", undefined),
32209                                 typeToTypeNodeHelper(types[types.length - 1], context)
32210                             ];
32211                         }
32212                     }
32213                     var mayHaveNameCollisions = !(context.flags & 64);
32214                     var seenNames = mayHaveNameCollisions ? ts.createUnderscoreEscapedMultiMap() : undefined;
32215                     var result_3 = [];
32216                     var i = 0;
32217                     for (var _i = 0, types_1 = types; _i < types_1.length; _i++) {
32218                         var type = types_1[_i];
32219                         i++;
32220                         if (checkTruncationLength(context) && (i + 2 < types.length - 1)) {
32221                             result_3.push(ts.createTypeReferenceNode("... " + (types.length - i) + " more ...", undefined));
32222                             var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context);
32223                             if (typeNode_1) {
32224                                 result_3.push(typeNode_1);
32225                             }
32226                             break;
32227                         }
32228                         context.approximateLength += 2;
32229                         var typeNode = typeToTypeNodeHelper(type, context);
32230                         if (typeNode) {
32231                             result_3.push(typeNode);
32232                             if (seenNames && ts.isIdentifierTypeReference(typeNode)) {
32233                                 seenNames.add(typeNode.typeName.escapedText, [type, result_3.length - 1]);
32234                             }
32235                         }
32236                     }
32237                     if (seenNames) {
32238                         var saveContextFlags = context.flags;
32239                         context.flags |= 64;
32240                         seenNames.forEach(function (types) {
32241                             if (!ts.arrayIsHomogeneous(types, function (_a, _b) {
32242                                 var a = _a[0];
32243                                 var b = _b[0];
32244                                 return typesAreSameReference(a, b);
32245                             })) {
32246                                 for (var _i = 0, types_2 = types; _i < types_2.length; _i++) {
32247                                     var _a = types_2[_i], type = _a[0], resultIndex = _a[1];
32248                                     result_3[resultIndex] = typeToTypeNodeHelper(type, context);
32249                                 }
32250                             }
32251                         });
32252                         context.flags = saveContextFlags;
32253                     }
32254                     return result_3;
32255                 }
32256             }
32257             function typesAreSameReference(a, b) {
32258                 return a === b
32259                     || !!a.symbol && a.symbol === b.symbol
32260                     || !!a.aliasSymbol && a.aliasSymbol === b.aliasSymbol;
32261             }
32262             function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context) {
32263                 var name = ts.getNameFromIndexInfo(indexInfo) || "x";
32264                 var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 ? 143 : 140);
32265                 var indexingParameter = ts.createParameter(undefined, undefined, undefined, name, undefined, indexerTypeNode, undefined);
32266                 var typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context);
32267                 if (!indexInfo.type && !(context.flags & 2097152)) {
32268                     context.encounteredError = true;
32269                 }
32270                 context.approximateLength += (name.length + 4);
32271                 return ts.createIndexSignature(undefined, indexInfo.isReadonly ? [ts.createToken(138)] : undefined, [indexingParameter], typeNode);
32272             }
32273             function signatureToSignatureDeclarationHelper(signature, kind, context, privateSymbolVisitor, bundledImports) {
32274                 var suppressAny = context.flags & 256;
32275                 if (suppressAny)
32276                     context.flags &= ~256;
32277                 var typeParameters;
32278                 var typeArguments;
32279                 if (context.flags & 32 && signature.target && signature.mapper && signature.target.typeParameters) {
32280                     typeArguments = signature.target.typeParameters.map(function (parameter) { return typeToTypeNodeHelper(instantiateType(parameter, signature.mapper), context); });
32281                 }
32282                 else {
32283                     typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); });
32284                 }
32285                 var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 162, privateSymbolVisitor, bundledImports); });
32286                 if (signature.thisParameter) {
32287                     var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context);
32288                     parameters.unshift(thisParameter);
32289                 }
32290                 var returnTypeNode;
32291                 var typePredicate = getTypePredicateOfSignature(signature);
32292                 if (typePredicate) {
32293                     var assertsModifier = typePredicate.kind === 2 || typePredicate.kind === 3 ?
32294                         ts.createToken(124) :
32295                         undefined;
32296                     var parameterName = typePredicate.kind === 1 || typePredicate.kind === 3 ?
32297                         ts.setEmitFlags(ts.createIdentifier(typePredicate.parameterName), 16777216) :
32298                         ts.createThisTypeNode();
32299                     var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context);
32300                     returnTypeNode = ts.createTypePredicateNodeWithModifier(assertsModifier, parameterName, typeNode);
32301                 }
32302                 else {
32303                     var returnType = getReturnTypeOfSignature(signature);
32304                     if (returnType && !(suppressAny && isTypeAny(returnType))) {
32305                         returnTypeNode = serializeReturnTypeForSignature(context, returnType, signature, privateSymbolVisitor, bundledImports);
32306                     }
32307                     else if (!suppressAny) {
32308                         returnTypeNode = ts.createKeywordTypeNode(125);
32309                     }
32310                 }
32311                 context.approximateLength += 3;
32312                 return ts.createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNode, typeArguments);
32313             }
32314             function typeParameterToDeclarationWithConstraint(type, context, constraintNode) {
32315                 var savedContextFlags = context.flags;
32316                 context.flags &= ~512;
32317                 var name = typeParameterToName(type, context);
32318                 var defaultParameter = getDefaultFromTypeParameter(type);
32319                 var defaultParameterNode = defaultParameter && typeToTypeNodeHelper(defaultParameter, context);
32320                 context.flags = savedContextFlags;
32321                 return ts.createTypeParameterDeclaration(name, constraintNode, defaultParameterNode);
32322             }
32323             function typeParameterToDeclaration(type, context, constraint) {
32324                 if (constraint === void 0) { constraint = getConstraintOfTypeParameter(type); }
32325                 var constraintNode = constraint && typeToTypeNodeHelper(constraint, context);
32326                 return typeParameterToDeclarationWithConstraint(type, context, constraintNode);
32327             }
32328             function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) {
32329                 var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 156);
32330                 if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) {
32331                     parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 317);
32332                 }
32333                 var parameterType = getTypeOfSymbol(parameterSymbol);
32334                 if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
32335                     parameterType = getOptionalType(parameterType);
32336                 }
32337                 var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports);
32338                 var modifiers = !(context.flags & 8192) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined;
32339                 var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768;
32340                 var dotDotDotToken = isRest ? ts.createToken(25) : undefined;
32341                 var name = parameterDeclaration ? parameterDeclaration.name ?
32342                     parameterDeclaration.name.kind === 75 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216) :
32343                         parameterDeclaration.name.kind === 153 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216) :
32344                             cloneBindingName(parameterDeclaration.name) :
32345                     ts.symbolName(parameterSymbol) :
32346                     ts.symbolName(parameterSymbol);
32347                 var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384;
32348                 var questionToken = isOptional ? ts.createToken(57) : undefined;
32349                 var parameterNode = ts.createParameter(undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, undefined);
32350                 context.approximateLength += ts.symbolName(parameterSymbol).length + 3;
32351                 return parameterNode;
32352                 function cloneBindingName(node) {
32353                     return elideInitializerAndSetEmitFlags(node);
32354                     function elideInitializerAndSetEmitFlags(node) {
32355                         if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) {
32356                             trackComputedName(node.expression, context.enclosingDeclaration, context);
32357                         }
32358                         var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, undefined, elideInitializerAndSetEmitFlags);
32359                         var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited);
32360                         if (clone.kind === 191) {
32361                             clone.initializer = undefined;
32362                         }
32363                         return ts.setEmitFlags(clone, 1 | 16777216);
32364                     }
32365                 }
32366             }
32367             function trackComputedName(accessExpression, enclosingDeclaration, context) {
32368                 if (!context.tracker.trackSymbol)
32369                     return;
32370                 var firstIdentifier = ts.getFirstIdentifier(accessExpression);
32371                 var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 | 1048576, undefined, undefined, true);
32372                 if (name) {
32373                     context.tracker.trackSymbol(name, enclosingDeclaration, 111551);
32374                 }
32375             }
32376             function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) {
32377                 context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning);
32378                 return lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol);
32379             }
32380             function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) {
32381                 var chain;
32382                 var isTypeParameter = symbol.flags & 262144;
32383                 if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64) && !(context.flags & 134217728)) {
32384                     chain = ts.Debug.checkDefined(getSymbolChain(symbol, meaning, true));
32385                     ts.Debug.assert(chain && chain.length > 0);
32386                 }
32387                 else {
32388                     chain = [symbol];
32389                 }
32390                 return chain;
32391                 function getSymbolChain(symbol, meaning, endOfChain) {
32392                     var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128));
32393                     var parentSpecifiers;
32394                     if (!accessibleSymbolChain ||
32395                         needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) {
32396                         var parents_1 = getContainersOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol, context.enclosingDeclaration);
32397                         if (ts.length(parents_1)) {
32398                             parentSpecifiers = parents_1.map(function (symbol) {
32399                                 return ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)
32400                                     ? getSpecifierForModuleSymbol(symbol, context)
32401                                     : undefined;
32402                             });
32403                             var indices = parents_1.map(function (_, i) { return i; });
32404                             indices.sort(sortByBestName);
32405                             var sortedParents = indices.map(function (i) { return parents_1[i]; });
32406                             for (var _i = 0, sortedParents_1 = sortedParents; _i < sortedParents_1.length; _i++) {
32407                                 var parent = sortedParents_1[_i];
32408                                 var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), false);
32409                                 if (parentChain) {
32410                                     if (parent.exports && parent.exports.get("export=") &&
32411                                         getSymbolIfSameReference(parent.exports.get("export="), symbol)) {
32412                                         accessibleSymbolChain = parentChain;
32413                                         break;
32414                                     }
32415                                     accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]);
32416                                     break;
32417                                 }
32418                             }
32419                         }
32420                     }
32421                     if (accessibleSymbolChain) {
32422                         return accessibleSymbolChain;
32423                     }
32424                     if (endOfChain ||
32425                         !(symbol.flags & (2048 | 4096))) {
32426                         if (!endOfChain && !yieldModuleSymbol && !!ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
32427                             return;
32428                         }
32429                         return [symbol];
32430                     }
32431                     function sortByBestName(a, b) {
32432                         var specifierA = parentSpecifiers[a];
32433                         var specifierB = parentSpecifiers[b];
32434                         if (specifierA && specifierB) {
32435                             var isBRelative = ts.pathIsRelative(specifierB);
32436                             if (ts.pathIsRelative(specifierA) === isBRelative) {
32437                                 return ts.moduleSpecifiers.countPathComponents(specifierA) - ts.moduleSpecifiers.countPathComponents(specifierB);
32438                             }
32439                             if (isBRelative) {
32440                                 return -1;
32441                             }
32442                             return 1;
32443                         }
32444                         return 0;
32445                     }
32446                 }
32447             }
32448             function typeParametersToTypeParameterDeclarations(symbol, context) {
32449                 var typeParameterNodes;
32450                 var targetSymbol = getTargetSymbol(symbol);
32451                 if (targetSymbol.flags & (32 | 64 | 524288)) {
32452                     typeParameterNodes = ts.createNodeArray(ts.map(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), function (tp) { return typeParameterToDeclaration(tp, context); }));
32453                 }
32454                 return typeParameterNodes;
32455             }
32456             function lookupTypeParameterNodes(chain, index, context) {
32457                 ts.Debug.assert(chain && 0 <= index && index < chain.length);
32458                 var symbol = chain[index];
32459                 var symbolId = "" + getSymbolId(symbol);
32460                 if (context.typeParameterSymbolList && context.typeParameterSymbolList.get(symbolId)) {
32461                     return undefined;
32462                 }
32463                 (context.typeParameterSymbolList || (context.typeParameterSymbolList = ts.createMap())).set(symbolId, true);
32464                 var typeParameterNodes;
32465                 if (context.flags & 512 && index < (chain.length - 1)) {
32466                     var parentSymbol = symbol;
32467                     var nextSymbol_1 = chain[index + 1];
32468                     if (ts.getCheckFlags(nextSymbol_1) & 1) {
32469                         var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 ? resolveAlias(parentSymbol) : parentSymbol);
32470                         typeParameterNodes = mapToTypeNodes(ts.map(params, function (t) { return getMappedType(t, nextSymbol_1.mapper); }), context);
32471                     }
32472                     else {
32473                         typeParameterNodes = typeParametersToTypeParameterDeclarations(symbol, context);
32474                     }
32475                 }
32476                 return typeParameterNodes;
32477             }
32478             function getTopmostIndexedAccessType(top) {
32479                 if (ts.isIndexedAccessTypeNode(top.objectType)) {
32480                     return getTopmostIndexedAccessType(top.objectType);
32481                 }
32482                 return top;
32483             }
32484             function getSpecifierForModuleSymbol(symbol, context) {
32485                 var file = ts.getDeclarationOfKind(symbol, 290);
32486                 if (!file) {
32487                     var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); });
32488                     if (equivalentFileSymbol) {
32489                         file = ts.getDeclarationOfKind(equivalentFileSymbol, 290);
32490                     }
32491                 }
32492                 if (file && file.moduleName !== undefined) {
32493                     return file.moduleName;
32494                 }
32495                 if (!file) {
32496                     if (context.tracker.trackReferencedAmbientModule) {
32497                         var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule);
32498                         if (ts.length(ambientDecls)) {
32499                             for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) {
32500                                 var decl = ambientDecls_1[_i];
32501                                 context.tracker.trackReferencedAmbientModule(decl, symbol);
32502                             }
32503                         }
32504                     }
32505                     if (ambientModuleSymbolRegex.test(symbol.escapedName)) {
32506                         return symbol.escapedName.substring(1, symbol.escapedName.length - 1);
32507                     }
32508                 }
32509                 if (!context.enclosingDeclaration || !context.tracker.moduleResolverHost) {
32510                     if (ambientModuleSymbolRegex.test(symbol.escapedName)) {
32511                         return symbol.escapedName.substring(1, symbol.escapedName.length - 1);
32512                     }
32513                     return ts.getSourceFileOfNode(ts.getNonAugmentationDeclaration(symbol)).fileName;
32514                 }
32515                 var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration));
32516                 var links = getSymbolLinks(symbol);
32517                 var specifier = links.specifierCache && links.specifierCache.get(contextFile.path);
32518                 if (!specifier) {
32519                     var isBundle_1 = (compilerOptions.out || compilerOptions.outFile);
32520                     var moduleResolverHost = context.tracker.moduleResolverHost;
32521                     var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions;
32522                     specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, specifierCompilerOptions, contextFile, moduleResolverHost, { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative" }));
32523                     links.specifierCache = links.specifierCache || ts.createMap();
32524                     links.specifierCache.set(contextFile.path, specifier);
32525                 }
32526                 return specifier;
32527             }
32528             function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
32529                 var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384));
32530                 var isTypeOf = meaning === 111551;
32531                 if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
32532                     var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined;
32533                     var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context);
32534                     var specifier = getSpecifierForModuleSymbol(chain[0], context);
32535                     if (!(context.flags & 67108864) && ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs && specifier.indexOf("/node_modules/") >= 0) {
32536                         context.encounteredError = true;
32537                         if (context.tracker.reportLikelyUnsafeImportRequiredError) {
32538                             context.tracker.reportLikelyUnsafeImportRequiredError(specifier);
32539                         }
32540                     }
32541                     var lit = ts.createLiteralTypeNode(ts.createLiteral(specifier));
32542                     if (context.tracker.trackExternalModuleSymbolOfImportTypeNode)
32543                         context.tracker.trackExternalModuleSymbolOfImportTypeNode(chain[0]);
32544                     context.approximateLength += specifier.length + 10;
32545                     if (!nonRootParts || ts.isEntityName(nonRootParts)) {
32546                         if (nonRootParts) {
32547                             var lastId = ts.isIdentifier(nonRootParts) ? nonRootParts : nonRootParts.right;
32548                             lastId.typeArguments = undefined;
32549                         }
32550                         return ts.createImportTypeNode(lit, nonRootParts, typeParameterNodes, isTypeOf);
32551                     }
32552                     else {
32553                         var splitNode = getTopmostIndexedAccessType(nonRootParts);
32554                         var qualifier = splitNode.objectType.typeName;
32555                         return ts.createIndexedAccessTypeNode(ts.createImportTypeNode(lit, qualifier, typeParameterNodes, isTypeOf), splitNode.indexType);
32556                     }
32557                 }
32558                 var entityName = createAccessFromSymbolChain(chain, chain.length - 1, 0);
32559                 if (ts.isIndexedAccessTypeNode(entityName)) {
32560                     return entityName;
32561                 }
32562                 if (isTypeOf) {
32563                     return ts.createTypeQueryNode(entityName);
32564                 }
32565                 else {
32566                     var lastId = ts.isIdentifier(entityName) ? entityName : entityName.right;
32567                     var lastTypeArgs = lastId.typeArguments;
32568                     lastId.typeArguments = undefined;
32569                     return ts.createTypeReferenceNode(entityName, lastTypeArgs);
32570                 }
32571                 function createAccessFromSymbolChain(chain, index, stopper) {
32572                     var typeParameterNodes = index === (chain.length - 1) ? overrideTypeArguments : lookupTypeParameterNodes(chain, index, context);
32573                     var symbol = chain[index];
32574                     var parent = chain[index - 1];
32575                     var symbolName;
32576                     if (index === 0) {
32577                         context.flags |= 16777216;
32578                         symbolName = getNameOfSymbolAsWritten(symbol, context);
32579                         context.approximateLength += (symbolName ? symbolName.length : 0) + 1;
32580                         context.flags ^= 16777216;
32581                     }
32582                     else {
32583                         if (parent && getExportsOfSymbol(parent)) {
32584                             var exports_1 = getExportsOfSymbol(parent);
32585                             ts.forEachEntry(exports_1, function (ex, name) {
32586                                 if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=") {
32587                                     symbolName = ts.unescapeLeadingUnderscores(name);
32588                                     return true;
32589                                 }
32590                             });
32591                         }
32592                     }
32593                     if (!symbolName) {
32594                         symbolName = getNameOfSymbolAsWritten(symbol, context);
32595                     }
32596                     context.approximateLength += symbolName.length + 1;
32597                     if (!(context.flags & 16) && parent &&
32598                         getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) &&
32599                         getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) {
32600                         var LHS = createAccessFromSymbolChain(chain, index - 1, stopper);
32601                         if (ts.isIndexedAccessTypeNode(LHS)) {
32602                             return ts.createIndexedAccessTypeNode(LHS, ts.createLiteralTypeNode(ts.createLiteral(symbolName)));
32603                         }
32604                         else {
32605                             return ts.createIndexedAccessTypeNode(ts.createTypeReferenceNode(LHS, typeParameterNodes), ts.createLiteralTypeNode(ts.createLiteral(symbolName)));
32606                         }
32607                     }
32608                     var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216);
32609                     identifier.symbol = symbol;
32610                     if (index > stopper) {
32611                         var LHS = createAccessFromSymbolChain(chain, index - 1, stopper);
32612                         if (!ts.isEntityName(LHS)) {
32613                             return ts.Debug.fail("Impossible construct - an export of an indexed access cannot be reachable");
32614                         }
32615                         return ts.createQualifiedName(LHS, identifier);
32616                     }
32617                     return identifier;
32618                 }
32619             }
32620             function typeParameterShadowsNameInScope(escapedName, context, type) {
32621                 var result = resolveName(context.enclosingDeclaration, escapedName, 788968, undefined, escapedName, false);
32622                 if (result) {
32623                     if (result.flags & 262144 && result === type.symbol) {
32624                         return false;
32625                     }
32626                     return true;
32627                 }
32628                 return false;
32629             }
32630             function typeParameterToName(type, context) {
32631                 if (context.flags & 4 && context.typeParameterNames) {
32632                     var cached = context.typeParameterNames.get("" + getTypeId(type));
32633                     if (cached) {
32634                         return cached;
32635                     }
32636                 }
32637                 var result = symbolToName(type.symbol, context, 788968, true);
32638                 if (!(result.kind & 75)) {
32639                     return ts.createIdentifier("(Missing type parameter)");
32640                 }
32641                 if (context.flags & 4) {
32642                     var rawtext = result.escapedText;
32643                     var i = 0;
32644                     var text = rawtext;
32645                     while ((context.typeParameterNamesByText && context.typeParameterNamesByText.get(text)) || typeParameterShadowsNameInScope(text, context, type)) {
32646                         i++;
32647                         text = rawtext + "_" + i;
32648                     }
32649                     if (text !== rawtext) {
32650                         result = ts.createIdentifier(text, result.typeArguments);
32651                     }
32652                     (context.typeParameterNames || (context.typeParameterNames = ts.createMap())).set("" + getTypeId(type), result);
32653                     (context.typeParameterNamesByText || (context.typeParameterNamesByText = ts.createMap())).set(result.escapedText, true);
32654                 }
32655                 return result;
32656             }
32657             function symbolToName(symbol, context, meaning, expectsIdentifier) {
32658                 var chain = lookupSymbolChain(symbol, context, meaning);
32659                 if (expectsIdentifier && chain.length !== 1
32660                     && !context.encounteredError
32661                     && !(context.flags & 65536)) {
32662                     context.encounteredError = true;
32663                 }
32664                 return createEntityNameFromSymbolChain(chain, chain.length - 1);
32665                 function createEntityNameFromSymbolChain(chain, index) {
32666                     var typeParameterNodes = lookupTypeParameterNodes(chain, index, context);
32667                     var symbol = chain[index];
32668                     if (index === 0) {
32669                         context.flags |= 16777216;
32670                     }
32671                     var symbolName = getNameOfSymbolAsWritten(symbol, context);
32672                     if (index === 0) {
32673                         context.flags ^= 16777216;
32674                     }
32675                     var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216);
32676                     identifier.symbol = symbol;
32677                     return index > 0 ? ts.createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier;
32678                 }
32679             }
32680             function symbolToExpression(symbol, context, meaning) {
32681                 var chain = lookupSymbolChain(symbol, context, meaning);
32682                 return createExpressionFromSymbolChain(chain, chain.length - 1);
32683                 function createExpressionFromSymbolChain(chain, index) {
32684                     var typeParameterNodes = lookupTypeParameterNodes(chain, index, context);
32685                     var symbol = chain[index];
32686                     if (index === 0) {
32687                         context.flags |= 16777216;
32688                     }
32689                     var symbolName = getNameOfSymbolAsWritten(symbol, context);
32690                     if (index === 0) {
32691                         context.flags ^= 16777216;
32692                     }
32693                     var firstChar = symbolName.charCodeAt(0);
32694                     if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
32695                         return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context));
32696                     }
32697                     var canUsePropertyAccess = firstChar === 35 ?
32698                         symbolName.length > 1 && ts.isIdentifierStart(symbolName.charCodeAt(1), languageVersion) :
32699                         ts.isIdentifierStart(firstChar, languageVersion);
32700                     if (index === 0 || canUsePropertyAccess) {
32701                         var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216);
32702                         identifier.symbol = symbol;
32703                         return index > 0 ? ts.createPropertyAccess(createExpressionFromSymbolChain(chain, index - 1), identifier) : identifier;
32704                     }
32705                     else {
32706                         if (firstChar === 91) {
32707                             symbolName = symbolName.substring(1, symbolName.length - 1);
32708                             firstChar = symbolName.charCodeAt(0);
32709                         }
32710                         var expression = void 0;
32711                         if (ts.isSingleOrDoubleQuote(firstChar)) {
32712                             expression = ts.createLiteral(symbolName.substring(1, symbolName.length - 1).replace(/\\./g, function (s) { return s.substring(1); }));
32713                             expression.singleQuote = firstChar === 39;
32714                         }
32715                         else if (("" + +symbolName) === symbolName) {
32716                             expression = ts.createLiteral(+symbolName);
32717                         }
32718                         if (!expression) {
32719                             expression = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216);
32720                             expression.symbol = symbol;
32721                         }
32722                         return ts.createElementAccess(createExpressionFromSymbolChain(chain, index - 1), expression);
32723                     }
32724                 }
32725             }
32726             function isSingleQuotedStringNamed(d) {
32727                 var name = ts.getNameOfDeclaration(d);
32728                 if (name && ts.isStringLiteral(name) && (name.singleQuote ||
32729                     (!ts.nodeIsSynthesized(name) && ts.startsWith(ts.getTextOfNode(name, false), "'")))) {
32730                     return true;
32731                 }
32732                 return false;
32733             }
32734             function getPropertyNameNodeForSymbol(symbol, context) {
32735                 var singleQuote = !!ts.length(symbol.declarations) && ts.every(symbol.declarations, isSingleQuotedStringNamed);
32736                 var fromNameType = getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote);
32737                 if (fromNameType) {
32738                     return fromNameType;
32739                 }
32740                 if (ts.isKnownSymbol(symbol)) {
32741                     return ts.createComputedPropertyName(ts.createPropertyAccess(ts.createIdentifier("Symbol"), symbol.escapedName.substr(3)));
32742                 }
32743                 var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName);
32744                 return createPropertyNameNodeForIdentifierOrLiteral(rawName, singleQuote);
32745             }
32746             function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote) {
32747                 var nameType = getSymbolLinks(symbol).nameType;
32748                 if (nameType) {
32749                     if (nameType.flags & 384) {
32750                         var name = "" + nameType.value;
32751                         if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) {
32752                             return ts.createLiteral(name, !!singleQuote);
32753                         }
32754                         if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
32755                             return ts.createComputedPropertyName(ts.createLiteral(+name));
32756                         }
32757                         return createPropertyNameNodeForIdentifierOrLiteral(name);
32758                     }
32759                     if (nameType.flags & 8192) {
32760                         return ts.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551));
32761                     }
32762                 }
32763             }
32764             function createPropertyNameNodeForIdentifierOrLiteral(name, singleQuote) {
32765                 return ts.isIdentifierText(name, compilerOptions.target) ? ts.createIdentifier(name) : ts.createLiteral(isNumericLiteralName(name) && +name >= 0 ? +name : name, !!singleQuote);
32766             }
32767             function cloneNodeBuilderContext(context) {
32768                 var initial = __assign({}, context);
32769                 if (initial.typeParameterNames) {
32770                     initial.typeParameterNames = ts.cloneMap(initial.typeParameterNames);
32771                 }
32772                 if (initial.typeParameterNamesByText) {
32773                     initial.typeParameterNamesByText = ts.cloneMap(initial.typeParameterNamesByText);
32774                 }
32775                 if (initial.typeParameterSymbolList) {
32776                     initial.typeParameterSymbolList = ts.cloneMap(initial.typeParameterSymbolList);
32777                 }
32778                 return initial;
32779             }
32780             function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) {
32781                 return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; })); });
32782             }
32783             function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) {
32784                 return !(ts.getObjectFlags(type) & 4) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters);
32785             }
32786             function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) {
32787                 if (type !== errorType && enclosingDeclaration) {
32788                     var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration);
32789                     if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) {
32790                         var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation);
32791                         if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
32792                             var result_4 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled);
32793                             if (result_4) {
32794                                 return result_4;
32795                             }
32796                         }
32797                     }
32798                 }
32799                 var oldFlags = context.flags;
32800                 if (type.flags & 8192 &&
32801                     type.symbol === symbol) {
32802                     context.flags |= 1048576;
32803                 }
32804                 var result = typeToTypeNodeHelper(type, context);
32805                 context.flags = oldFlags;
32806                 return result;
32807             }
32808             function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) {
32809                 if (type !== errorType && context.enclosingDeclaration) {
32810                     var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
32811                     if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) {
32812                         var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled);
32813                         if (result) {
32814                             return result;
32815                         }
32816                     }
32817                 }
32818                 return typeToTypeNodeHelper(type, context);
32819             }
32820             function serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled) {
32821                 if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
32822                     cancellationToken.throwIfCancellationRequested();
32823                 }
32824                 var hadError = false;
32825                 var transformed = ts.visitNode(existing, visitExistingNodeTreeSymbols);
32826                 if (hadError) {
32827                     return undefined;
32828                 }
32829                 return transformed === existing ? ts.getMutableClone(existing) : transformed;
32830                 function visitExistingNodeTreeSymbols(node) {
32831                     var _a, _b;
32832                     if (ts.isJSDocAllType(node) || node.kind === 302) {
32833                         return ts.createKeywordTypeNode(125);
32834                     }
32835                     if (ts.isJSDocUnknownType(node)) {
32836                         return ts.createKeywordTypeNode(148);
32837                     }
32838                     if (ts.isJSDocNullableType(node)) {
32839                         return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(100)]);
32840                     }
32841                     if (ts.isJSDocOptionalType(node)) {
32842                         return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(146)]);
32843                     }
32844                     if (ts.isJSDocNonNullableType(node)) {
32845                         return ts.visitNode(node.type, visitExistingNodeTreeSymbols);
32846                     }
32847                     if (ts.isJSDocVariadicType(node)) {
32848                         return ts.createArrayTypeNode(ts.visitNode(node.type, visitExistingNodeTreeSymbols));
32849                     }
32850                     if (ts.isJSDocTypeLiteral(node)) {
32851                         return ts.createTypeLiteralNode(ts.map(node.jsDocPropertyTags, function (t) {
32852                             var name = ts.isIdentifier(t.name) ? t.name : t.name.right;
32853                             var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText);
32854                             var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined;
32855                             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);
32856                         }));
32857                     }
32858                     if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") {
32859                         return ts.setOriginalNode(ts.createKeywordTypeNode(125), node);
32860                     }
32861                     if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) {
32862                         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))]);
32863                     }
32864                     if (ts.isJSDocFunctionType(node)) {
32865                         if (ts.isJSDocConstructSignature(node)) {
32866                             var newTypeNode_1;
32867                             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));
32868                         }
32869                         else {
32870                             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));
32871                         }
32872                     }
32873                     if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968, true))) {
32874                         return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
32875                     }
32876                     if (ts.isLiteralImportTypeNode(node)) {
32877                         return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf);
32878                     }
32879                     if (ts.isEntityName(node) || ts.isEntityNameExpression(node)) {
32880                         var leftmost = ts.getFirstIdentifier(node);
32881                         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)))) {
32882                             hadError = true;
32883                             return node;
32884                         }
32885                         var sym = resolveEntityName(leftmost, 67108863, true, true);
32886                         if (sym) {
32887                             if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863, false).accessibility !== 0) {
32888                                 hadError = true;
32889                             }
32890                             else {
32891                                 (_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);
32892                                 includePrivateSymbol === null || includePrivateSymbol === void 0 ? void 0 : includePrivateSymbol(sym);
32893                             }
32894                             if (ts.isIdentifier(node)) {
32895                                 var name = sym.flags & 262144 ? typeParameterToName(getDeclaredTypeOfSymbol(sym), context) : ts.getMutableClone(node);
32896                                 name.symbol = sym;
32897                                 return ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216);
32898                             }
32899                         }
32900                     }
32901                     return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext);
32902                     function getEffectiveDotDotDotForParameter(p) {
32903                         return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.createToken(25) : undefined);
32904                     }
32905                     function rewriteModuleSpecifier(parent, lit) {
32906                         if (bundled) {
32907                             if (context.tracker && context.tracker.moduleResolverHost) {
32908                                 var targetFile = getExternalModuleFileFromDeclaration(parent);
32909                                 if (targetFile) {
32910                                     var getCanonicalFileName = ts.createGetCanonicalFileName(!!host.useCaseSensitiveFileNames);
32911                                     var resolverHost = {
32912                                         getCanonicalFileName: getCanonicalFileName,
32913                                         getCurrentDirectory: function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); },
32914                                         getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); }
32915                                     };
32916                                     var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile);
32917                                     return ts.createLiteral(newName);
32918                                 }
32919                             }
32920                         }
32921                         else {
32922                             if (context.tracker && context.tracker.trackExternalModuleSymbolOfImportTypeNode) {
32923                                 var moduleSym = resolveExternalModuleNameWorker(lit, lit, undefined);
32924                                 if (moduleSym) {
32925                                     context.tracker.trackExternalModuleSymbolOfImportTypeNode(moduleSym);
32926                                 }
32927                             }
32928                         }
32929                         return lit;
32930                     }
32931                 }
32932             }
32933             function symbolTableToDeclarationStatements(symbolTable, context, bundled) {
32934                 var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.createProperty, 161, true);
32935                 var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type, initializer) { return ts.createPropertySignature(mods, name, question, type, initializer); }, 160, false);
32936                 var enclosingDeclaration = context.enclosingDeclaration;
32937                 var results = [];
32938                 var visitedSymbols = ts.createMap();
32939                 var deferredPrivates;
32940                 var oldcontext = context;
32941                 context = __assign(__assign({}, oldcontext), { usedSymbolNames: ts.createMap(), remappedSymbolNames: ts.createMap(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) {
32942                             var accessibleResult = isSymbolAccessible(sym, decl, meaning, false);
32943                             if (accessibleResult.accessibility === 0) {
32944                                 var chain = lookupSymbolChainWorker(sym, context, meaning);
32945                                 if (!(sym.flags & 4)) {
32946                                     includePrivateSymbol(chain[0]);
32947                                 }
32948                             }
32949                             else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) {
32950                                 oldcontext.tracker.trackSymbol(sym, decl, meaning);
32951                             }
32952                         } }) });
32953                 if (oldcontext.usedSymbolNames) {
32954                     oldcontext.usedSymbolNames.forEach(function (_, name) {
32955                         context.usedSymbolNames.set(name, true);
32956                     });
32957                 }
32958                 ts.forEachEntry(symbolTable, function (symbol, name) {
32959                     var baseName = ts.unescapeLeadingUnderscores(name);
32960                     void getInternalSymbolName(symbol, baseName);
32961                 });
32962                 var addingDeclare = !bundled;
32963                 var exportEquals = symbolTable.get("export=");
32964                 if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152) {
32965                     symbolTable = ts.createSymbolTable();
32966                     symbolTable.set("export=", exportEquals);
32967                 }
32968                 visitSymbolTable(symbolTable);
32969                 return mergeRedundantStatements(results);
32970                 function isIdentifierAndNotUndefined(node) {
32971                     return !!node && node.kind === 75;
32972                 }
32973                 function getNamesOfDeclaration(statement) {
32974                     if (ts.isVariableStatement(statement)) {
32975                         return ts.filter(ts.map(statement.declarationList.declarations, ts.getNameOfDeclaration), isIdentifierAndNotUndefined);
32976                     }
32977                     return ts.filter([ts.getNameOfDeclaration(statement)], isIdentifierAndNotUndefined);
32978                 }
32979                 function flattenExportAssignedNamespace(statements) {
32980                     var exportAssignment = ts.find(statements, ts.isExportAssignment);
32981                     var ns = ts.find(statements, ts.isModuleDeclaration);
32982                     if (ns && exportAssignment && exportAssignment.isExportEquals &&
32983                         ts.isIdentifier(exportAssignment.expression) && ts.isIdentifier(ns.name) && ts.idText(ns.name) === ts.idText(exportAssignment.expression) &&
32984                         ns.body && ts.isModuleBlock(ns.body)) {
32985                         var excessExports = ts.filter(statements, function (s) { return !!(ts.getModifierFlags(s) & 1); });
32986                         if (ts.length(excessExports)) {
32987                             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)]));
32988                         }
32989                         if (!ts.find(statements, function (s) { return s !== ns && ts.nodeHasName(s, ns.name); })) {
32990                             results = [];
32991                             ts.forEach(ns.body.statements, function (s) {
32992                                 addResult(s, 0);
32993                             });
32994                             statements = __spreadArrays(ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), results);
32995                         }
32996                     }
32997                     return statements;
32998                 }
32999                 function mergeExportDeclarations(statements) {
33000                     var exports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause && ts.isNamedExports(d.exportClause); });
33001                     if (ts.length(exports) > 1) {
33002                         var nonExports = ts.filter(statements, function (d) { return !ts.isExportDeclaration(d) || !!d.moduleSpecifier || !d.exportClause; });
33003                         statements = __spreadArrays(nonExports, [ts.createExportDeclaration(undefined, undefined, ts.createNamedExports(ts.flatMap(exports, function (e) { return ts.cast(e.exportClause, ts.isNamedExports).elements; })), undefined)]);
33004                     }
33005                     var reexports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !!d.moduleSpecifier && !!d.exportClause && ts.isNamedExports(d.exportClause); });
33006                     if (ts.length(reexports) > 1) {
33007                         var groups = ts.group(reexports, function (decl) { return ts.isStringLiteral(decl.moduleSpecifier) ? ">" + decl.moduleSpecifier.text : ">"; });
33008                         if (groups.length !== reexports.length) {
33009                             var _loop_8 = function (group_1) {
33010                                 if (group_1.length > 1) {
33011                                     statements = __spreadArrays(ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), [
33012                                         ts.createExportDeclaration(undefined, undefined, ts.createNamedExports(ts.flatMap(group_1, function (e) { return ts.cast(e.exportClause, ts.isNamedExports).elements; })), group_1[0].moduleSpecifier)
33013                                     ]);
33014                                 }
33015                             };
33016                             for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) {
33017                                 var group_1 = groups_1[_i];
33018                                 _loop_8(group_1);
33019                             }
33020                         }
33021                     }
33022                     return statements;
33023                 }
33024                 function inlineExportModifiers(statements) {
33025                     var exportDecl = ts.find(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; });
33026                     if (exportDecl && exportDecl.exportClause && ts.isNamedExports(exportDecl.exportClause)) {
33027                         var replacements = ts.mapDefined(exportDecl.exportClause.elements, function (e) {
33028                             if (!e.propertyName) {
33029                                 var associated = ts.filter(statements, function (s) { return ts.nodeHasName(s, e.name); });
33030                                 if (ts.length(associated) && ts.every(associated, canHaveExportModifier)) {
33031                                     ts.forEach(associated, addExportModifier);
33032                                     return undefined;
33033                                 }
33034                             }
33035                             return e;
33036                         });
33037                         if (!ts.length(replacements)) {
33038                             statements = ts.filter(statements, function (s) { return s !== exportDecl; });
33039                         }
33040                         else {
33041                             exportDecl.exportClause.elements = ts.createNodeArray(replacements);
33042                         }
33043                     }
33044                     return statements;
33045                 }
33046                 function mergeRedundantStatements(statements) {
33047                     statements = flattenExportAssignedNamespace(statements);
33048                     statements = mergeExportDeclarations(statements);
33049                     statements = inlineExportModifiers(statements);
33050                     if (enclosingDeclaration &&
33051                         ((ts.isSourceFile(enclosingDeclaration) && ts.isExternalOrCommonJsModule(enclosingDeclaration)) || ts.isModuleDeclaration(enclosingDeclaration)) &&
33052                         (!ts.some(statements, ts.isExternalModuleIndicator) || (!ts.hasScopeMarker(statements) && ts.some(statements, ts.needsScopeMarker)))) {
33053                         statements.push(ts.createEmptyExports());
33054                     }
33055                     return statements;
33056                 }
33057                 function canHaveExportModifier(node) {
33058                     return ts.isEnumDeclaration(node) ||
33059                         ts.isVariableStatement(node) ||
33060                         ts.isFunctionDeclaration(node) ||
33061                         ts.isClassDeclaration(node) ||
33062                         (ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) ||
33063                         ts.isInterfaceDeclaration(node) ||
33064                         isTypeDeclaration(node);
33065                 }
33066                 function addExportModifier(statement) {
33067                     var flags = (ts.getModifierFlags(statement) | 1) & ~2;
33068                     statement.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(flags));
33069                     statement.modifierFlagsCache = 0;
33070                 }
33071                 function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) {
33072                     var oldDeferredPrivates = deferredPrivates;
33073                     if (!suppressNewPrivateContext) {
33074                         deferredPrivates = ts.createMap();
33075                     }
33076                     symbolTable.forEach(function (symbol) {
33077                         serializeSymbol(symbol, false, !!propertyAsAlias);
33078                     });
33079                     if (!suppressNewPrivateContext) {
33080                         deferredPrivates.forEach(function (symbol) {
33081                             serializeSymbol(symbol, true, !!propertyAsAlias);
33082                         });
33083                     }
33084                     deferredPrivates = oldDeferredPrivates;
33085                 }
33086                 function serializeSymbol(symbol, isPrivate, propertyAsAlias) {
33087                     var visitedSym = getMergedSymbol(symbol);
33088                     if (visitedSymbols.has("" + getSymbolId(visitedSym))) {
33089                         return;
33090                     }
33091                     visitedSymbols.set("" + getSymbolId(visitedSym), true);
33092                     var skipMembershipCheck = !isPrivate;
33093                     if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) {
33094                         var oldContext = context;
33095                         context = cloneNodeBuilderContext(context);
33096                         var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias);
33097                         context = oldContext;
33098                         return result;
33099                     }
33100                 }
33101                 function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) {
33102                     var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName);
33103                     var isDefault = symbol.escapedName === "default";
33104                     if (!(context.flags & 131072) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) {
33105                         context.encounteredError = true;
33106                         return;
33107                     }
33108                     var needsPostExportDefault = isDefault && !!(symbol.flags & -113
33109                         || (symbol.flags & 16 && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152);
33110                     if (needsPostExportDefault) {
33111                         isPrivate = true;
33112                     }
33113                     var modifierFlags = (!isPrivate ? 1 : 0) | (isDefault && !needsPostExportDefault ? 512 : 0);
33114                     var isConstMergedWithNS = symbol.flags & 1536 &&
33115                         symbol.flags & (2 | 1 | 4) &&
33116                         symbol.escapedName !== "export=";
33117                     var isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol);
33118                     if (symbol.flags & (16 | 8192) || isConstMergedWithNSPrintableAsSignatureMerge) {
33119                         serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
33120                     }
33121                     if (symbol.flags & 524288) {
33122                         serializeTypeAlias(symbol, symbolName, modifierFlags);
33123                     }
33124                     if (symbol.flags & (2 | 1 | 4)
33125                         && symbol.escapedName !== "export="
33126                         && !(symbol.flags & 4194304)
33127                         && !(symbol.flags & 32)
33128                         && !isConstMergedWithNSPrintableAsSignatureMerge) {
33129                         serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags);
33130                     }
33131                     if (symbol.flags & 384) {
33132                         serializeEnum(symbol, symbolName, modifierFlags);
33133                     }
33134                     if (symbol.flags & 32) {
33135                         if (symbol.flags & 4 && ts.isBinaryExpression(symbol.valueDeclaration.parent) && ts.isClassExpression(symbol.valueDeclaration.parent.right)) {
33136                             serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
33137                         }
33138                         else {
33139                             serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
33140                         }
33141                     }
33142                     if ((symbol.flags & (512 | 1024) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) {
33143                         serializeModule(symbol, symbolName, modifierFlags);
33144                     }
33145                     if (symbol.flags & 64) {
33146                         serializeInterface(symbol, symbolName, modifierFlags);
33147                     }
33148                     if (symbol.flags & 2097152) {
33149                         serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
33150                     }
33151                     if (symbol.flags & 4 && symbol.escapedName === "export=") {
33152                         serializeMaybeAliasAssignment(symbol);
33153                     }
33154                     if (symbol.flags & 8388608) {
33155                         for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
33156                             var node = _a[_i];
33157                             var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier);
33158                             if (!resolvedModule)
33159                                 continue;
33160                             addResult(ts.createExportDeclaration(undefined, undefined, undefined, ts.createLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0);
33161                         }
33162                     }
33163                     if (needsPostExportDefault) {
33164                         addResult(ts.createExportAssignment(undefined, undefined, false, ts.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0);
33165                     }
33166                 }
33167                 function includePrivateSymbol(symbol) {
33168                     if (ts.some(symbol.declarations, ts.isParameterDeclaration))
33169                         return;
33170                     ts.Debug.assertIsDefined(deferredPrivates);
33171                     getUnusedName(ts.unescapeLeadingUnderscores(symbol.escapedName), symbol);
33172                     deferredPrivates.set("" + getSymbolId(symbol), symbol);
33173                 }
33174                 function isExportingScope(enclosingDeclaration) {
33175                     return ((ts.isSourceFile(enclosingDeclaration) && (ts.isExternalOrCommonJsModule(enclosingDeclaration) || ts.isJsonSourceFile(enclosingDeclaration))) ||
33176                         (ts.isAmbientModule(enclosingDeclaration) && !ts.isGlobalScopeAugmentation(enclosingDeclaration)));
33177                 }
33178                 function addResult(node, additionalModifierFlags) {
33179                     var newModifierFlags = 0;
33180                     if (additionalModifierFlags & 1 &&
33181                         enclosingDeclaration &&
33182                         isExportingScope(enclosingDeclaration) &&
33183                         canHaveExportModifier(node)) {
33184                         newModifierFlags |= 1;
33185                     }
33186                     if (addingDeclare && !(newModifierFlags & 1) &&
33187                         (!enclosingDeclaration || !(enclosingDeclaration.flags & 8388608)) &&
33188                         (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) {
33189                         newModifierFlags |= 2;
33190                     }
33191                     if ((additionalModifierFlags & 512) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) {
33192                         newModifierFlags |= 512;
33193                     }
33194                     if (newModifierFlags) {
33195                         node.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(newModifierFlags | ts.getModifierFlags(node)));
33196                         node.modifierFlagsCache = 0;
33197                     }
33198                     results.push(node);
33199                 }
33200                 function serializeTypeAlias(symbol, symbolName, modifierFlags) {
33201                     var aliasType = getDeclaredTypeOfTypeAlias(symbol);
33202                     var typeParams = getSymbolLinks(symbol).typeParameters;
33203                     var typeParamDecls = ts.map(typeParams, function (p) { return typeParameterToDeclaration(p, context); });
33204                     var jsdocAliasDecl = ts.find(symbol.declarations, ts.isJSDocTypeAlias);
33205                     var commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined;
33206                     var oldFlags = context.flags;
33207                     context.flags |= 8388608;
33208                     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);
33209                     context.flags = oldFlags;
33210                 }
33211                 function serializeInterface(symbol, symbolName, modifierFlags) {
33212                     var interfaceType = getDeclaredTypeOfClassOrInterface(symbol);
33213                     var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
33214                     var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); });
33215                     var baseTypes = getBaseTypes(interfaceType);
33216                     var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined;
33217                     var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); });
33218                     var callSignatures = serializeSignatures(0, interfaceType, baseType, 165);
33219                     var constructSignatures = serializeSignatures(1, interfaceType, baseType, 166);
33220                     var indexSignatures = serializeIndexSignatures(interfaceType, baseType);
33221                     var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(90, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b); }))];
33222                     addResult(ts.createInterfaceDeclaration(undefined, undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, constructSignatures, callSignatures, members)), modifierFlags);
33223                 }
33224                 function getNamespaceMembersForSerialization(symbol) {
33225                     return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember);
33226                 }
33227                 function isTypeOnlyNamespace(symbol) {
33228                     return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551); });
33229                 }
33230                 function serializeModule(symbol, symbolName, modifierFlags) {
33231                     var members = getNamespaceMembersForSerialization(symbol);
33232                     var locationMap = ts.arrayToMultiMap(members, function (m) { return m.parent && m.parent === symbol ? "real" : "merged"; });
33233                     var realMembers = locationMap.get("real") || ts.emptyArray;
33234                     var mergedMembers = locationMap.get("merged") || ts.emptyArray;
33235                     if (ts.length(realMembers)) {
33236                         var localName = getInternalSymbolName(symbol, symbolName);
33237                         serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 | 67108864)));
33238                     }
33239                     if (ts.length(mergedMembers)) {
33240                         var containingFile_1 = ts.getSourceFileOfNode(context.enclosingDeclaration);
33241                         var localName = getInternalSymbolName(symbol, symbolName);
33242                         var nsBody = ts.createModuleBlock([ts.createExportDeclaration(undefined, undefined, ts.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export="; }), function (s) {
33243                                 var _a, _b;
33244                                 var name = ts.unescapeLeadingUnderscores(s.escapedName);
33245                                 var localName = getInternalSymbolName(s, name);
33246                                 var aliasDecl = s.declarations && getDeclarationOfAliasSymbol(s);
33247                                 if (containingFile_1 && (aliasDecl ? containingFile_1 !== ts.getSourceFileOfNode(aliasDecl) : !ts.some(s.declarations, function (d) { return ts.getSourceFileOfNode(d) === containingFile_1; }))) {
33248                                     (_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);
33249                                     return undefined;
33250                                 }
33251                                 var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, true);
33252                                 includePrivateSymbol(target || s);
33253                                 var targetName = target ? getInternalSymbolName(target, ts.unescapeLeadingUnderscores(target.escapedName)) : localName;
33254                                 return ts.createExportSpecifier(name === targetName ? undefined : targetName, name);
33255                             })))]);
33256                         addResult(ts.createModuleDeclaration(undefined, undefined, ts.createIdentifier(localName), nsBody, 16), 0);
33257                     }
33258                 }
33259                 function serializeEnum(symbol, symbolName, modifierFlags) {
33260                     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) {
33261                         var initializedValue = p.declarations && p.declarations[0] && ts.isEnumMember(p.declarations[0]) && getConstantValue(p.declarations[0]);
33262                         return ts.createEnumMember(ts.unescapeLeadingUnderscores(p.escapedName), initializedValue === undefined ? undefined : ts.createLiteral(initializedValue));
33263                     })), modifierFlags);
33264                 }
33265                 function serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags) {
33266                     if (propertyAsAlias) {
33267                         serializeMaybeAliasAssignment(symbol);
33268                     }
33269                     else {
33270                         var type = getTypeOfSymbol(symbol);
33271                         var localName = getInternalSymbolName(symbol, symbolName);
33272                         if (!(symbol.flags & 16) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) {
33273                             serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags);
33274                         }
33275                         else {
33276                             var flags = !(symbol.flags & 2) ? undefined
33277                                 : isConstVariable(symbol) ? 2
33278                                     : 1;
33279                             var name = (needsPostExportDefault || !(symbol.flags & 4)) ? localName : getUnusedName(localName, symbol);
33280                             var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); });
33281                             if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) {
33282                                 textRange = textRange.parent.parent;
33283                             }
33284                             var statement = ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
33285                                 ts.createVariableDeclaration(name, serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled))
33286                             ], flags)), textRange);
33287                             addResult(statement, name !== localName ? modifierFlags & ~1 : modifierFlags);
33288                             if (name !== localName && !isPrivate) {
33289                                 addResult(ts.createExportDeclaration(undefined, undefined, ts.createNamedExports([ts.createExportSpecifier(name, localName)])), 0);
33290                             }
33291                         }
33292                     }
33293                 }
33294                 function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) {
33295                     var signatures = getSignaturesOfType(type, 0);
33296                     for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) {
33297                         var sig = signatures_2[_i];
33298                         var decl = signatureToSignatureDeclarationHelper(sig, 244, context, includePrivateSymbol, bundled);
33299                         decl.name = ts.createIdentifier(localName);
33300                         addResult(ts.setTextRange(decl, sig.declaration && ts.isVariableDeclaration(sig.declaration.parent) && sig.declaration.parent.parent || sig.declaration), modifierFlags);
33301                     }
33302                     if (!(symbol.flags & (512 | 1024) && !!symbol.exports && !!symbol.exports.size)) {
33303                         var props = ts.filter(getPropertiesOfType(type), isNamespaceMember);
33304                         serializeAsNamespaceDeclaration(props, localName, modifierFlags, true);
33305                     }
33306                 }
33307                 function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) {
33308                     if (ts.length(props)) {
33309                         var localVsRemoteMap = ts.arrayToMultiMap(props, function (p) {
33310                             return !ts.length(p.declarations) || ts.some(p.declarations, function (d) {
33311                                 return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration);
33312                             }) ? "local" : "remote";
33313                         });
33314                         var localProps = localVsRemoteMap.get("local") || ts.emptyArray;
33315                         var fakespace = ts.createModuleDeclaration(undefined, undefined, ts.createIdentifier(localName), ts.createModuleBlock([]), 16);
33316                         fakespace.flags ^= 8;
33317                         fakespace.parent = enclosingDeclaration;
33318                         fakespace.locals = ts.createSymbolTable(props);
33319                         fakespace.symbol = props[0].parent;
33320                         var oldResults = results;
33321                         results = [];
33322                         var oldAddingDeclare = addingDeclare;
33323                         addingDeclare = false;
33324                         var subcontext = __assign(__assign({}, context), { enclosingDeclaration: fakespace });
33325                         var oldContext = context;
33326                         context = subcontext;
33327                         visitSymbolTable(ts.createSymbolTable(localProps), suppressNewPrivateContext, true);
33328                         context = oldContext;
33329                         addingDeclare = oldAddingDeclare;
33330                         var declarations = results;
33331                         results = oldResults;
33332                         fakespace.flags ^= 8;
33333                         fakespace.parent = undefined;
33334                         fakespace.locals = undefined;
33335                         fakespace.symbol = undefined;
33336                         fakespace.body = ts.createModuleBlock(declarations);
33337                         addResult(fakespace, modifierFlags);
33338                     }
33339                 }
33340                 function isNamespaceMember(p) {
33341                     return !(p.flags & 4194304 || p.escapedName === "prototype" || p.valueDeclaration && ts.isClassLike(p.valueDeclaration.parent));
33342                 }
33343                 function serializeAsClass(symbol, localName, modifierFlags) {
33344                     var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
33345                     var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); });
33346                     var classType = getDeclaredTypeOfClassOrInterface(symbol);
33347                     var baseTypes = getBaseTypes(classType);
33348                     var implementsTypes = getImplementsTypes(classType);
33349                     var staticType = getTypeOfSymbol(symbol);
33350                     var staticBaseType = getBaseConstructorTypeOfClass(staticType);
33351                     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); }))]);
33352                     var symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType));
33353                     var publicSymbolProps = ts.filter(symbolProps, function (s) {
33354                         var valueDecl = s.valueDeclaration;
33355                         return valueDecl && !(ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name));
33356                     });
33357                     var hasPrivateIdentifier = ts.some(symbolProps, function (s) {
33358                         var valueDecl = s.valueDeclaration;
33359                         return valueDecl && ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name);
33360                     });
33361                     var privateProperties = hasPrivateIdentifier ?
33362                         [ts.createProperty(undefined, undefined, ts.createPrivateIdentifier("#private"), undefined, undefined, undefined)] :
33363                         ts.emptyArray;
33364                     var publicProperties = ts.flatMap(publicSymbolProps, function (p) { return serializePropertySymbolForClass(p, false, baseTypes[0]); });
33365                     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); });
33366                     var constructors = serializeSignatures(1, staticType, baseTypes[0], 162);
33367                     for (var _i = 0, constructors_1 = constructors; _i < constructors_1.length; _i++) {
33368                         var c = constructors_1[_i];
33369                         c.type = undefined;
33370                         c.typeParameters = undefined;
33371                     }
33372                     var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]);
33373                     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);
33374                 }
33375                 function serializeAsAlias(symbol, localName, modifierFlags) {
33376                     var node = getDeclarationOfAliasSymbol(symbol);
33377                     if (!node)
33378                         return ts.Debug.fail();
33379                     var target = getMergedSymbol(getTargetOfAliasDeclaration(node, true));
33380                     if (!target) {
33381                         return;
33382                     }
33383                     var verbatimTargetName = ts.unescapeLeadingUnderscores(target.escapedName);
33384                     if (verbatimTargetName === "export=" && (compilerOptions.esModuleInterop || compilerOptions.allowSyntheticDefaultImports)) {
33385                         verbatimTargetName = "default";
33386                     }
33387                     var targetName = getInternalSymbolName(target, verbatimTargetName);
33388                     includePrivateSymbol(target);
33389                     switch (node.kind) {
33390                         case 253:
33391                             var isLocalImport = !(target.flags & 512);
33392                             addResult(ts.createImportEqualsDeclaration(undefined, undefined, ts.createIdentifier(localName), isLocalImport
33393                                 ? symbolToName(target, context, 67108863, false)
33394                                 : ts.createExternalModuleReference(ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)))), isLocalImport ? modifierFlags : 0);
33395                             break;
33396                         case 252:
33397                             addResult(ts.createNamespaceExportDeclaration(ts.idText(node.name)), 0);
33398                             break;
33399                         case 255:
33400                             addResult(ts.createImportDeclaration(undefined, undefined, ts.createImportClause(ts.createIdentifier(localName), undefined), ts.createLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0);
33401                             break;
33402                         case 256:
33403                             addResult(ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(ts.createIdentifier(localName))), ts.createLiteral(getSpecifierForModuleSymbol(target, context))), 0);
33404                             break;
33405                         case 262:
33406                             addResult(ts.createExportDeclaration(undefined, undefined, ts.createNamespaceExport(ts.createIdentifier(localName)), ts.createLiteral(getSpecifierForModuleSymbol(target, context))), 0);
33407                             break;
33408                         case 258:
33409                             addResult(ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamedImports([
33410                                 ts.createImportSpecifier(localName !== verbatimTargetName ? ts.createIdentifier(verbatimTargetName) : undefined, ts.createIdentifier(localName))
33411                             ])), ts.createLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0);
33412                             break;
33413                         case 263:
33414                             var specifier = node.parent.parent.moduleSpecifier;
33415                             serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.createLiteral(specifier.text) : undefined);
33416                             break;
33417                         case 259:
33418                             serializeMaybeAliasAssignment(symbol);
33419                             break;
33420                         case 209:
33421                         case 194:
33422                             if (symbol.escapedName === "default" || symbol.escapedName === "export=") {
33423                                 serializeMaybeAliasAssignment(symbol);
33424                             }
33425                             else {
33426                                 serializeExportSpecifier(localName, targetName);
33427                             }
33428                             break;
33429                         default:
33430                             return ts.Debug.failBadSyntaxKind(node, "Unhandled alias declaration kind in symbol serializer!");
33431                     }
33432                 }
33433                 function serializeExportSpecifier(localName, targetName, specifier) {
33434                     addResult(ts.createExportDeclaration(undefined, undefined, ts.createNamedExports([ts.createExportSpecifier(localName !== targetName ? targetName : undefined, localName)]), specifier), 0);
33435                 }
33436                 function serializeMaybeAliasAssignment(symbol) {
33437                     if (symbol.flags & 4194304) {
33438                         return;
33439                     }
33440                     var name = ts.unescapeLeadingUnderscores(symbol.escapedName);
33441                     var isExportEquals = name === "export=";
33442                     var isDefault = name === "default";
33443                     var isExportAssignment = isExportEquals || isDefault;
33444                     var aliasDecl = symbol.declarations && getDeclarationOfAliasSymbol(symbol);
33445                     var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, true);
33446                     if (target && ts.length(target.declarations) && ts.some(target.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(enclosingDeclaration); })) {
33447                         var expr = isExportAssignment ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl);
33448                         var first_1 = ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined;
33449                         var referenced = first_1 && resolveEntityName(first_1, 67108863, true, true, enclosingDeclaration);
33450                         if (referenced || target) {
33451                             includePrivateSymbol(referenced || target);
33452                         }
33453                         var oldTrack = context.tracker.trackSymbol;
33454                         context.tracker.trackSymbol = ts.noop;
33455                         if (isExportAssignment) {
33456                             results.push(ts.createExportAssignment(undefined, undefined, isExportEquals, symbolToExpression(target, context, 67108863)));
33457                         }
33458                         else {
33459                             if (first_1 === expr) {
33460                                 serializeExportSpecifier(name, ts.idText(first_1));
33461                             }
33462                             else if (ts.isClassExpression(expr)) {
33463                                 serializeExportSpecifier(name, getInternalSymbolName(target, ts.symbolName(target)));
33464                             }
33465                             else {
33466                                 var varName = getUnusedName(name, symbol);
33467                                 addResult(ts.createImportEqualsDeclaration(undefined, undefined, ts.createIdentifier(varName), symbolToName(target, context, 67108863, false)), 0);
33468                                 serializeExportSpecifier(name, varName);
33469                             }
33470                         }
33471                         context.tracker.trackSymbol = oldTrack;
33472                     }
33473                     else {
33474                         var varName = getUnusedName(name, symbol);
33475                         var typeToSerialize = getWidenedType(getTypeOfSymbol(getMergedSymbol(symbol)));
33476                         if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) {
33477                             serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignment ? 0 : 1);
33478                         }
33479                         else {
33480                             var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
33481                                 ts.createVariableDeclaration(varName, serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled))
33482                             ], 2));
33483                             addResult(statement, name === varName ? 1 : 0);
33484                         }
33485                         if (isExportAssignment) {
33486                             results.push(ts.createExportAssignment(undefined, undefined, isExportEquals, ts.createIdentifier(varName)));
33487                         }
33488                         else if (name !== varName) {
33489                             serializeExportSpecifier(name, varName);
33490                         }
33491                     }
33492                 }
33493                 function isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, hostSymbol) {
33494                     var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration);
33495                     return ts.getObjectFlags(typeToSerialize) & (16 | 32) &&
33496                         !getIndexInfoOfType(typeToSerialize, 0) &&
33497                         !getIndexInfoOfType(typeToSerialize, 1) &&
33498                         !!(ts.length(getPropertiesOfType(typeToSerialize)) || ts.length(getSignaturesOfType(typeToSerialize, 0))) &&
33499                         !ts.length(getSignaturesOfType(typeToSerialize, 1)) &&
33500                         !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) &&
33501                         !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) &&
33502                         !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) &&
33503                         !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return ts.some(p.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; }); }) &&
33504                         ts.every(getPropertiesOfType(typeToSerialize), function (p) { return ts.isIdentifierText(ts.symbolName(p), languageVersion) && !ts.isStringAKeyword(ts.symbolName(p)); });
33505                 }
33506                 function makeSerializePropertySymbol(createProperty, methodKind, useAccessors) {
33507                     return function serializePropertySymbol(p, isStatic, baseType) {
33508                         var modifierFlags = ts.getDeclarationModifierFlagsFromSymbol(p);
33509                         var isPrivate = !!(modifierFlags & 8);
33510                         if (isStatic && (p.flags & (788968 | 1920 | 2097152))) {
33511                             return [];
33512                         }
33513                         if (p.flags & 4194304 ||
33514                             (baseType && getPropertyOfType(baseType, p.escapedName)
33515                                 && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p)
33516                                 && (p.flags & 16777216) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216)
33517                                 && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) {
33518                             return [];
33519                         }
33520                         var flag = (modifierFlags & ~256) | (isStatic ? 32 : 0);
33521                         var name = getPropertyNameNodeForSymbol(p, context);
33522                         var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression));
33523                         if (p.flags & 98304 && useAccessors) {
33524                             var result = [];
33525                             if (p.flags & 65536) {
33526                                 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));
33527                             }
33528                             if (p.flags & 32768) {
33529                                 var isPrivate_1 = modifierFlags & 8;
33530                                 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));
33531                             }
33532                             return result;
33533                         }
33534                         else if (p.flags & (4 | 3)) {
33535                             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);
33536                         }
33537                         if (p.flags & (8192 | 16)) {
33538                             var type = getTypeOfSymbol(p);
33539                             var signatures = getSignaturesOfType(type, 0);
33540                             if (flag & 8) {
33541                                 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]);
33542                             }
33543                             var results_1 = [];
33544                             for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) {
33545                                 var sig = signatures_3[_i];
33546                                 var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context);
33547                                 decl.name = name;
33548                                 if (flag) {
33549                                     decl.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(flag));
33550                                 }
33551                                 if (p.flags & 16777216) {
33552                                     decl.questionToken = ts.createToken(57);
33553                                 }
33554                                 results_1.push(ts.setTextRange(decl, sig.declaration));
33555                             }
33556                             return results_1;
33557                         }
33558                         return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags));
33559                     };
33560                 }
33561                 function serializePropertySymbolForInterface(p, baseType) {
33562                     return serializePropertySymbolForInterfaceWorker(p, false, baseType);
33563                 }
33564                 function serializeSignatures(kind, input, baseType, outputKind) {
33565                     var signatures = getSignaturesOfType(input, kind);
33566                     if (kind === 1) {
33567                         if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) {
33568                             return [];
33569                         }
33570                         if (baseType) {
33571                             var baseSigs = getSignaturesOfType(baseType, 1);
33572                             if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) {
33573                                 return [];
33574                             }
33575                             if (baseSigs.length === signatures.length) {
33576                                 var failed = false;
33577                                 for (var i = 0; i < baseSigs.length; i++) {
33578                                     if (!compareSignaturesIdentical(signatures[i], baseSigs[i], false, false, true, compareTypesIdentical)) {
33579                                         failed = true;
33580                                         break;
33581                                     }
33582                                 }
33583                                 if (!failed) {
33584                                     return [];
33585                                 }
33586                             }
33587                         }
33588                         var privateProtected = 0;
33589                         for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) {
33590                             var s = signatures_4[_i];
33591                             if (s.declaration) {
33592                                 privateProtected |= ts.getSelectedModifierFlags(s.declaration, 8 | 16);
33593                             }
33594                         }
33595                         if (privateProtected) {
33596                             return [ts.setTextRange(ts.createConstructor(undefined, ts.createModifiersFromModifierFlags(privateProtected), [], undefined), signatures[0].declaration)];
33597                         }
33598                     }
33599                     var results = [];
33600                     for (var _a = 0, signatures_5 = signatures; _a < signatures_5.length; _a++) {
33601                         var sig = signatures_5[_a];
33602                         var decl = signatureToSignatureDeclarationHelper(sig, outputKind, context);
33603                         results.push(ts.setTextRange(decl, sig.declaration));
33604                     }
33605                     return results;
33606                 }
33607                 function serializeIndexSignatures(input, baseType) {
33608                     var results = [];
33609                     for (var _i = 0, _a = [0, 1]; _i < _a.length; _i++) {
33610                         var type = _a[_i];
33611                         var info = getIndexInfoOfType(input, type);
33612                         if (info) {
33613                             if (baseType) {
33614                                 var baseInfo = getIndexInfoOfType(baseType, type);
33615                                 if (baseInfo) {
33616                                     if (isTypeIdenticalTo(info.type, baseInfo.type)) {
33617                                         continue;
33618                                     }
33619                                 }
33620                             }
33621                             results.push(indexInfoToIndexSignatureDeclarationHelper(info, type, context));
33622                         }
33623                     }
33624                     return results;
33625                 }
33626                 function serializeBaseType(t, staticType, rootName) {
33627                     var ref = trySerializeAsTypeReference(t);
33628                     if (ref) {
33629                         return ref;
33630                     }
33631                     var tempName = getUnusedName(rootName + "_base");
33632                     var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
33633                         ts.createVariableDeclaration(tempName, typeToTypeNodeHelper(staticType, context))
33634                     ], 2));
33635                     addResult(statement, 0);
33636                     return ts.createExpressionWithTypeArguments(undefined, ts.createIdentifier(tempName));
33637                 }
33638                 function trySerializeAsTypeReference(t) {
33639                     var typeArgs;
33640                     var reference;
33641                     if (t.target && getAccessibleSymbolChain(t.target.symbol, enclosingDeclaration, 111551, false)) {
33642                         typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); });
33643                         reference = symbolToExpression(t.target.symbol, context, 788968);
33644                     }
33645                     else if (t.symbol && getAccessibleSymbolChain(t.symbol, enclosingDeclaration, 111551, false)) {
33646                         reference = symbolToExpression(t.symbol, context, 788968);
33647                     }
33648                     if (reference) {
33649                         return ts.createExpressionWithTypeArguments(typeArgs, reference);
33650                     }
33651                 }
33652                 function getUnusedName(input, symbol) {
33653                     if (symbol) {
33654                         if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) {
33655                             return context.remappedSymbolNames.get("" + getSymbolId(symbol));
33656                         }
33657                     }
33658                     if (symbol) {
33659                         input = getNameCandidateWorker(symbol, input);
33660                     }
33661                     var i = 0;
33662                     var original = input;
33663                     while (context.usedSymbolNames.has(input)) {
33664                         i++;
33665                         input = original + "_" + i;
33666                     }
33667                     context.usedSymbolNames.set(input, true);
33668                     if (symbol) {
33669                         context.remappedSymbolNames.set("" + getSymbolId(symbol), input);
33670                     }
33671                     return input;
33672                 }
33673                 function getNameCandidateWorker(symbol, localName) {
33674                     if (localName === "default" || localName === "__class" || localName === "__function") {
33675                         var flags = context.flags;
33676                         context.flags |= 16777216;
33677                         var nameCandidate = getNameOfSymbolAsWritten(symbol, context);
33678                         context.flags = flags;
33679                         localName = nameCandidate.length > 0 && ts.isSingleOrDoubleQuote(nameCandidate.charCodeAt(0)) ? ts.stripQuotes(nameCandidate) : nameCandidate;
33680                     }
33681                     if (localName === "default") {
33682                         localName = "_default";
33683                     }
33684                     else if (localName === "export=") {
33685                         localName = "_exports";
33686                     }
33687                     localName = ts.isIdentifierText(localName, languageVersion) && !ts.isStringANonContextualKeyword(localName) ? localName : "_" + localName.replace(/[^a-zA-Z0-9]/g, "_");
33688                     return localName;
33689                 }
33690                 function getInternalSymbolName(symbol, localName) {
33691                     if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) {
33692                         return context.remappedSymbolNames.get("" + getSymbolId(symbol));
33693                     }
33694                     localName = getNameCandidateWorker(symbol, localName);
33695                     context.remappedSymbolNames.set("" + getSymbolId(symbol), localName);
33696                     return localName;
33697                 }
33698             }
33699         }
33700         function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) {
33701             if (flags === void 0) { flags = 16384; }
33702             return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker);
33703             function typePredicateToStringWorker(writer) {
33704                 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));
33705                 var printer = ts.createPrinter({ removeComments: true });
33706                 var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
33707                 printer.writeNode(4, predicate, sourceFile, writer);
33708                 return writer;
33709             }
33710         }
33711         function formatUnionTypes(types) {
33712             var result = [];
33713             var flags = 0;
33714             for (var i = 0; i < types.length; i++) {
33715                 var t = types[i];
33716                 flags |= t.flags;
33717                 if (!(t.flags & 98304)) {
33718                     if (t.flags & (512 | 1024)) {
33719                         var baseType = t.flags & 512 ? booleanType : getBaseTypeOfEnumLiteralType(t);
33720                         if (baseType.flags & 1048576) {
33721                             var count = baseType.types.length;
33722                             if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) {
33723                                 result.push(baseType);
33724                                 i += count - 1;
33725                                 continue;
33726                             }
33727                         }
33728                     }
33729                     result.push(t);
33730                 }
33731             }
33732             if (flags & 65536)
33733                 result.push(nullType);
33734             if (flags & 32768)
33735                 result.push(undefinedType);
33736             return result || types;
33737         }
33738         function visibilityToString(flags) {
33739             if (flags === 8) {
33740                 return "private";
33741             }
33742             if (flags === 16) {
33743                 return "protected";
33744             }
33745             return "public";
33746         }
33747         function getTypeAliasForTypeLiteral(type) {
33748             if (type.symbol && type.symbol.flags & 2048) {
33749                 var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 182; });
33750                 if (node.kind === 247) {
33751                     return getSymbolOfNode(node);
33752                 }
33753             }
33754             return undefined;
33755         }
33756         function isTopLevelInExternalModuleAugmentation(node) {
33757             return node && node.parent &&
33758                 node.parent.kind === 250 &&
33759                 ts.isExternalModuleAugmentation(node.parent.parent);
33760         }
33761         function isDefaultBindingContext(location) {
33762             return location.kind === 290 || ts.isAmbientModule(location);
33763         }
33764         function getNameOfSymbolFromNameType(symbol, context) {
33765             var nameType = getSymbolLinks(symbol).nameType;
33766             if (nameType) {
33767                 if (nameType.flags & 384) {
33768                     var name = "" + nameType.value;
33769                     if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) {
33770                         return "\"" + ts.escapeString(name, 34) + "\"";
33771                     }
33772                     if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
33773                         return "[" + name + "]";
33774                     }
33775                     return name;
33776                 }
33777                 if (nameType.flags & 8192) {
33778                     return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]";
33779                 }
33780             }
33781         }
33782         function getNameOfSymbolAsWritten(symbol, context) {
33783             if (context && symbol.escapedName === "default" && !(context.flags & 16384) &&
33784                 (!(context.flags & 16777216) ||
33785                     !symbol.declarations ||
33786                     (context.enclosingDeclaration && ts.findAncestor(symbol.declarations[0], isDefaultBindingContext) !== ts.findAncestor(context.enclosingDeclaration, isDefaultBindingContext)))) {
33787                 return "default";
33788             }
33789             if (symbol.declarations && symbol.declarations.length) {
33790                 var declaration = ts.firstDefined(symbol.declarations, function (d) { return ts.getNameOfDeclaration(d) ? d : undefined; });
33791                 var name_2 = declaration && ts.getNameOfDeclaration(declaration);
33792                 if (declaration && name_2) {
33793                     if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) {
33794                         return ts.symbolName(symbol);
33795                     }
33796                     if (ts.isComputedPropertyName(name_2) && !(ts.getCheckFlags(symbol) & 4096)) {
33797                         var nameType = getSymbolLinks(symbol).nameType;
33798                         if (nameType && nameType.flags & 384) {
33799                             var result = getNameOfSymbolFromNameType(symbol, context);
33800                             if (result !== undefined) {
33801                                 return result;
33802                             }
33803                         }
33804                     }
33805                     return ts.declarationNameToString(name_2);
33806                 }
33807                 if (!declaration) {
33808                     declaration = symbol.declarations[0];
33809                 }
33810                 if (declaration.parent && declaration.parent.kind === 242) {
33811                     return ts.declarationNameToString(declaration.parent.name);
33812                 }
33813                 switch (declaration.kind) {
33814                     case 214:
33815                     case 201:
33816                     case 202:
33817                         if (context && !context.encounteredError && !(context.flags & 131072)) {
33818                             context.encounteredError = true;
33819                         }
33820                         return declaration.kind === 214 ? "(Anonymous class)" : "(Anonymous function)";
33821                 }
33822             }
33823             var name = getNameOfSymbolFromNameType(symbol, context);
33824             return name !== undefined ? name : ts.symbolName(symbol);
33825         }
33826         function isDeclarationVisible(node) {
33827             if (node) {
33828                 var links = getNodeLinks(node);
33829                 if (links.isVisible === undefined) {
33830                     links.isVisible = !!determineIfDeclarationIsVisible();
33831                 }
33832                 return links.isVisible;
33833             }
33834             return false;
33835             function determineIfDeclarationIsVisible() {
33836                 switch (node.kind) {
33837                     case 315:
33838                     case 322:
33839                     case 316:
33840                         return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent));
33841                     case 191:
33842                         return isDeclarationVisible(node.parent.parent);
33843                     case 242:
33844                         if (ts.isBindingPattern(node.name) &&
33845                             !node.name.elements.length) {
33846                             return false;
33847                         }
33848                     case 249:
33849                     case 245:
33850                     case 246:
33851                     case 247:
33852                     case 244:
33853                     case 248:
33854                     case 253:
33855                         if (ts.isExternalModuleAugmentation(node)) {
33856                             return true;
33857                         }
33858                         var parent = getDeclarationContainer(node);
33859                         if (!(ts.getCombinedModifierFlags(node) & 1) &&
33860                             !(node.kind !== 253 && parent.kind !== 290 && parent.flags & 8388608)) {
33861                             return isGlobalSourceFile(parent);
33862                         }
33863                         return isDeclarationVisible(parent);
33864                     case 159:
33865                     case 158:
33866                     case 163:
33867                     case 164:
33868                     case 161:
33869                     case 160:
33870                         if (ts.hasModifier(node, 8 | 16)) {
33871                             return false;
33872                         }
33873                     case 162:
33874                     case 166:
33875                     case 165:
33876                     case 167:
33877                     case 156:
33878                     case 250:
33879                     case 170:
33880                     case 171:
33881                     case 173:
33882                     case 169:
33883                     case 174:
33884                     case 175:
33885                     case 178:
33886                     case 179:
33887                     case 182:
33888                         return isDeclarationVisible(node.parent);
33889                     case 255:
33890                     case 256:
33891                     case 258:
33892                         return false;
33893                     case 155:
33894                     case 290:
33895                     case 252:
33896                         return true;
33897                     case 259:
33898                         return false;
33899                     default:
33900                         return false;
33901                 }
33902             }
33903         }
33904         function collectLinkedAliases(node, setVisibility) {
33905             var exportSymbol;
33906             if (node.parent && node.parent.kind === 259) {
33907                 exportSymbol = resolveName(node, node.escapedText, 111551 | 788968 | 1920 | 2097152, undefined, node, false);
33908             }
33909             else if (node.parent.kind === 263) {
33910                 exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 | 788968 | 1920 | 2097152);
33911             }
33912             var result;
33913             var visited;
33914             if (exportSymbol) {
33915                 visited = ts.createMap();
33916                 visited.set("" + getSymbolId(exportSymbol), true);
33917                 buildVisibleNodeList(exportSymbol.declarations);
33918             }
33919             return result;
33920             function buildVisibleNodeList(declarations) {
33921                 ts.forEach(declarations, function (declaration) {
33922                     var resultNode = getAnyImportSyntax(declaration) || declaration;
33923                     if (setVisibility) {
33924                         getNodeLinks(declaration).isVisible = true;
33925                     }
33926                     else {
33927                         result = result || [];
33928                         ts.pushIfUnique(result, resultNode);
33929                     }
33930                     if (ts.isInternalModuleImportEqualsDeclaration(declaration)) {
33931                         var internalModuleReference = declaration.moduleReference;
33932                         var firstIdentifier = ts.getFirstIdentifier(internalModuleReference);
33933                         var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 | 788968 | 1920, undefined, undefined, false);
33934                         var id = importSymbol && "" + getSymbolId(importSymbol);
33935                         if (importSymbol && !visited.has(id)) {
33936                             visited.set(id, true);
33937                             buildVisibleNodeList(importSymbol.declarations);
33938                         }
33939                     }
33940                 });
33941             }
33942         }
33943         function pushTypeResolution(target, propertyName) {
33944             var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName);
33945             if (resolutionCycleStartIndex >= 0) {
33946                 var length_3 = resolutionTargets.length;
33947                 for (var i = resolutionCycleStartIndex; i < length_3; i++) {
33948                     resolutionResults[i] = false;
33949                 }
33950                 return false;
33951             }
33952             resolutionTargets.push(target);
33953             resolutionResults.push(true);
33954             resolutionPropertyNames.push(propertyName);
33955             return true;
33956         }
33957         function findResolutionCycleStartIndex(target, propertyName) {
33958             for (var i = resolutionTargets.length - 1; i >= 0; i--) {
33959                 if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) {
33960                     return -1;
33961                 }
33962                 if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) {
33963                     return i;
33964                 }
33965             }
33966             return -1;
33967         }
33968         function hasType(target, propertyName) {
33969             switch (propertyName) {
33970                 case 0:
33971                     return !!getSymbolLinks(target).type;
33972                 case 5:
33973                     return !!(getNodeLinks(target).resolvedEnumType);
33974                 case 2:
33975                     return !!getSymbolLinks(target).declaredType;
33976                 case 1:
33977                     return !!target.resolvedBaseConstructorType;
33978                 case 3:
33979                     return !!target.resolvedReturnType;
33980                 case 4:
33981                     return !!target.immediateBaseConstraint;
33982                 case 6:
33983                     return !!target.resolvedTypeArguments;
33984             }
33985             return ts.Debug.assertNever(propertyName);
33986         }
33987         function popTypeResolution() {
33988             resolutionTargets.pop();
33989             resolutionPropertyNames.pop();
33990             return resolutionResults.pop();
33991         }
33992         function getDeclarationContainer(node) {
33993             return ts.findAncestor(ts.getRootDeclaration(node), function (node) {
33994                 switch (node.kind) {
33995                     case 242:
33996                     case 243:
33997                     case 258:
33998                     case 257:
33999                     case 256:
34000                     case 255:
34001                         return false;
34002                     default:
34003                         return true;
34004                 }
34005             }).parent;
34006         }
34007         function getTypeOfPrototypeProperty(prototype) {
34008             var classType = getDeclaredTypeOfSymbol(getParentOfSymbol(prototype));
34009             return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType;
34010         }
34011         function getTypeOfPropertyOfType(type, name) {
34012             var prop = getPropertyOfType(type, name);
34013             return prop ? getTypeOfSymbol(prop) : undefined;
34014         }
34015         function getTypeOfPropertyOrIndexSignature(type, name) {
34016             return getTypeOfPropertyOfType(type, name) || isNumericLiteralName(name) && getIndexTypeOfType(type, 1) || getIndexTypeOfType(type, 0) || unknownType;
34017         }
34018         function isTypeAny(type) {
34019             return type && (type.flags & 1) !== 0;
34020         }
34021         function getTypeForBindingElementParent(node) {
34022             var symbol = getSymbolOfNode(node);
34023             return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false);
34024         }
34025         function getRestType(source, properties, symbol) {
34026             source = filterType(source, function (t) { return !(t.flags & 98304); });
34027             if (source.flags & 131072) {
34028                 return emptyObjectType;
34029             }
34030             if (source.flags & 1048576) {
34031                 return mapType(source, function (t) { return getRestType(t, properties, symbol); });
34032             }
34033             var omitKeyType = getUnionType(ts.map(properties, getLiteralTypeFromPropertyName));
34034             if (isGenericObjectType(source) || isGenericIndexType(omitKeyType)) {
34035                 if (omitKeyType.flags & 131072) {
34036                     return source;
34037                 }
34038                 var omitTypeAlias = getGlobalOmitSymbol();
34039                 if (!omitTypeAlias) {
34040                     return errorType;
34041                 }
34042                 return getTypeAliasInstantiation(omitTypeAlias, [source, omitKeyType]);
34043             }
34044             var members = ts.createSymbolTable();
34045             for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) {
34046                 var prop = _a[_i];
34047                 if (!isTypeAssignableTo(getLiteralTypeFromProperty(prop, 8576), omitKeyType)
34048                     && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16))
34049                     && isSpreadableProperty(prop)) {
34050                     members.set(prop.escapedName, getSpreadSymbol(prop, false));
34051                 }
34052             }
34053             var stringIndexInfo = getIndexInfoOfType(source, 0);
34054             var numberIndexInfo = getIndexInfoOfType(source, 1);
34055             var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo);
34056             result.objectFlags |= 131072;
34057             return result;
34058         }
34059         function getFlowTypeOfDestructuring(node, declaredType) {
34060             var reference = getSyntheticElementAccess(node);
34061             return reference ? getFlowTypeOfReference(reference, declaredType) : declaredType;
34062         }
34063         function getSyntheticElementAccess(node) {
34064             var parentAccess = getParentElementAccess(node);
34065             if (parentAccess && parentAccess.flowNode) {
34066                 var propName = getDestructuringPropertyName(node);
34067                 if (propName) {
34068                     var result = ts.createNode(195, node.pos, node.end);
34069                     result.parent = node;
34070                     result.expression = parentAccess;
34071                     var literal = ts.createNode(10, node.pos, node.end);
34072                     literal.parent = result;
34073                     literal.text = propName;
34074                     result.argumentExpression = literal;
34075                     result.flowNode = parentAccess.flowNode;
34076                     return result;
34077                 }
34078             }
34079         }
34080         function getParentElementAccess(node) {
34081             var ancestor = node.parent.parent;
34082             switch (ancestor.kind) {
34083                 case 191:
34084                 case 281:
34085                     return getSyntheticElementAccess(ancestor);
34086                 case 192:
34087                     return getSyntheticElementAccess(node.parent);
34088                 case 242:
34089                     return ancestor.initializer;
34090                 case 209:
34091                     return ancestor.right;
34092             }
34093         }
34094         function getDestructuringPropertyName(node) {
34095             var parent = node.parent;
34096             if (node.kind === 191 && parent.kind === 189) {
34097                 return getLiteralPropertyNameText(node.propertyName || node.name);
34098             }
34099             if (node.kind === 281 || node.kind === 282) {
34100                 return getLiteralPropertyNameText(node.name);
34101             }
34102             return "" + parent.elements.indexOf(node);
34103         }
34104         function getLiteralPropertyNameText(name) {
34105             var type = getLiteralTypeFromPropertyName(name);
34106             return type.flags & (128 | 256) ? "" + type.value : undefined;
34107         }
34108         function getTypeForBindingElement(declaration) {
34109             var pattern = declaration.parent;
34110             var parentType = getTypeForBindingElementParent(pattern.parent);
34111             if (!parentType || isTypeAny(parentType)) {
34112                 return parentType;
34113             }
34114             if (strictNullChecks && declaration.flags & 8388608 && ts.isParameterDeclaration(declaration)) {
34115                 parentType = getNonNullableType(parentType);
34116             }
34117             else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536)) {
34118                 parentType = getTypeWithFacts(parentType, 524288);
34119             }
34120             var type;
34121             if (pattern.kind === 189) {
34122                 if (declaration.dotDotDotToken) {
34123                     parentType = getReducedType(parentType);
34124                     if (parentType.flags & 2 || !isValidSpreadType(parentType)) {
34125                         error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types);
34126                         return errorType;
34127                     }
34128                     var literalMembers = [];
34129                     for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
34130                         var element = _a[_i];
34131                         if (!element.dotDotDotToken) {
34132                             literalMembers.push(element.propertyName || element.name);
34133                         }
34134                     }
34135                     type = getRestType(parentType, literalMembers, declaration.symbol);
34136                 }
34137                 else {
34138                     var name = declaration.propertyName || declaration.name;
34139                     var indexType = getLiteralTypeFromPropertyName(name);
34140                     var declaredType = getConstraintForLocation(getIndexedAccessType(parentType, indexType, name), declaration.name);
34141                     type = getFlowTypeOfDestructuring(declaration, declaredType);
34142                 }
34143             }
34144             else {
34145                 var elementType = checkIteratedTypeOrElementType(65, parentType, undefinedType, pattern);
34146                 var index_1 = pattern.elements.indexOf(declaration);
34147                 if (declaration.dotDotDotToken) {
34148                     type = everyType(parentType, isTupleType) ?
34149                         mapType(parentType, function (t) { return sliceTupleType(t, index_1); }) :
34150                         createArrayType(elementType);
34151                 }
34152                 else if (isArrayLikeType(parentType)) {
34153                     var indexType = getLiteralType(index_1);
34154                     var accessFlags = hasDefaultValue(declaration) ? 8 : 0;
34155                     var declaredType = getConstraintForLocation(getIndexedAccessTypeOrUndefined(parentType, indexType, declaration.name, accessFlags) || errorType, declaration.name);
34156                     type = getFlowTypeOfDestructuring(declaration, declaredType);
34157                 }
34158                 else {
34159                     type = elementType;
34160                 }
34161             }
34162             if (!declaration.initializer) {
34163                 return type;
34164             }
34165             if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
34166                 return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768) ?
34167                     getTypeWithFacts(type, 524288) :
34168                     type;
34169             }
34170             return widenTypeInferredFromInitializer(declaration, getUnionType([getTypeWithFacts(type, 524288), checkDeclarationInitializer(declaration)], 2));
34171         }
34172         function getTypeForDeclarationFromJSDocComment(declaration) {
34173             var jsdocType = ts.getJSDocType(declaration);
34174             if (jsdocType) {
34175                 return getTypeFromTypeNode(jsdocType);
34176             }
34177             return undefined;
34178         }
34179         function isNullOrUndefined(node) {
34180             var expr = ts.skipParentheses(node);
34181             return expr.kind === 100 || expr.kind === 75 && getResolvedSymbol(expr) === undefinedSymbol;
34182         }
34183         function isEmptyArrayLiteral(node) {
34184             var expr = ts.skipParentheses(node);
34185             return expr.kind === 192 && expr.elements.length === 0;
34186         }
34187         function addOptionality(type, optional) {
34188             if (optional === void 0) { optional = true; }
34189             return strictNullChecks && optional ? getOptionalType(type) : type;
34190         }
34191         function getTypeForVariableLikeDeclaration(declaration, includeOptionality) {
34192             if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 231) {
34193                 var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression)));
34194                 return indexType.flags & (262144 | 4194304) ? getExtractStringType(indexType) : stringType;
34195             }
34196             if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 232) {
34197                 var forOfStatement = declaration.parent.parent;
34198                 return checkRightHandSideOfForOf(forOfStatement) || anyType;
34199             }
34200             if (ts.isBindingPattern(declaration.parent)) {
34201                 return getTypeForBindingElement(declaration);
34202             }
34203             var isOptional = includeOptionality && (ts.isParameter(declaration) && isJSDocOptionalParameter(declaration)
34204                 || !ts.isBindingElement(declaration) && !ts.isVariableDeclaration(declaration) && !!declaration.questionToken);
34205             var declaredType = tryGetTypeFromEffectiveTypeNode(declaration);
34206             if (declaredType) {
34207                 return addOptionality(declaredType, isOptional);
34208             }
34209             if ((noImplicitAny || ts.isInJSFile(declaration)) &&
34210                 declaration.kind === 242 && !ts.isBindingPattern(declaration.name) &&
34211                 !(ts.getCombinedModifierFlags(declaration) & 1) && !(declaration.flags & 8388608)) {
34212                 if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) {
34213                     return autoType;
34214                 }
34215                 if (declaration.initializer && isEmptyArrayLiteral(declaration.initializer)) {
34216                     return autoArrayType;
34217                 }
34218             }
34219             if (declaration.kind === 156) {
34220                 var func = declaration.parent;
34221                 if (func.kind === 164 && !hasNonBindableDynamicName(func)) {
34222                     var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 163);
34223                     if (getter) {
34224                         var getterSignature = getSignatureFromDeclaration(getter);
34225                         var thisParameter = getAccessorThisParameter(func);
34226                         if (thisParameter && declaration === thisParameter) {
34227                             ts.Debug.assert(!thisParameter.type);
34228                             return getTypeOfSymbol(getterSignature.thisParameter);
34229                         }
34230                         return getReturnTypeOfSignature(getterSignature);
34231                     }
34232                 }
34233                 if (ts.isInJSFile(declaration)) {
34234                     var typeTag = ts.getJSDocType(func);
34235                     if (typeTag && ts.isFunctionTypeNode(typeTag)) {
34236                         return getTypeAtPosition(getSignatureFromDeclaration(typeTag), func.parameters.indexOf(declaration));
34237                     }
34238                 }
34239                 var type = declaration.symbol.escapedName === "this" ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
34240                 if (type) {
34241                     return addOptionality(type, isOptional);
34242                 }
34243             }
34244             else if (ts.isInJSFile(declaration)) {
34245                 var containerObjectType = getJSContainerObjectType(declaration, getSymbolOfNode(declaration), ts.getDeclaredExpandoInitializer(declaration));
34246                 if (containerObjectType) {
34247                     return containerObjectType;
34248                 }
34249             }
34250             if (declaration.initializer) {
34251                 var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration));
34252                 return addOptionality(type, isOptional);
34253             }
34254             if (ts.isJsxAttribute(declaration)) {
34255                 return trueType;
34256             }
34257             if (ts.isBindingPattern(declaration.name)) {
34258                 return getTypeFromBindingPattern(declaration.name, false, true);
34259             }
34260             return undefined;
34261         }
34262         function getWidenedTypeForAssignmentDeclaration(symbol, resolvedSymbol) {
34263             var container = ts.getAssignedExpandoInitializer(symbol.valueDeclaration);
34264             if (container) {
34265                 var tag = ts.getJSDocTypeTag(container);
34266                 if (tag && tag.typeExpression) {
34267                     return getTypeFromTypeNode(tag.typeExpression);
34268                 }
34269                 var containerObjectType = getJSContainerObjectType(symbol.valueDeclaration, symbol, container);
34270                 return containerObjectType || getWidenedLiteralType(checkExpressionCached(container));
34271             }
34272             var definedInConstructor = false;
34273             var definedInMethod = false;
34274             var jsdocType;
34275             var types;
34276             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
34277                 var declaration = _a[_i];
34278                 var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration :
34279                     ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration :
34280                         undefined;
34281                 if (!expression) {
34282                     continue;
34283                 }
34284                 var kind = ts.isAccessExpression(expression)
34285                     ? ts.getAssignmentDeclarationPropertyAccessKind(expression)
34286                     : ts.getAssignmentDeclarationKind(expression);
34287                 if (kind === 4) {
34288                     if (isDeclarationInConstructor(expression)) {
34289                         definedInConstructor = true;
34290                     }
34291                     else {
34292                         definedInMethod = true;
34293                     }
34294                 }
34295                 if (!ts.isCallExpression(expression)) {
34296                     jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration);
34297                 }
34298                 if (!jsdocType) {
34299                     (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType);
34300                 }
34301             }
34302             var type = jsdocType;
34303             if (!type) {
34304                 if (!ts.length(types)) {
34305                     return errorType;
34306                 }
34307                 var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined;
34308                 if (definedInMethod) {
34309                     var propType = getTypeOfAssignmentDeclarationPropertyOfBaseType(symbol);
34310                     if (propType) {
34311                         (constructorTypes || (constructorTypes = [])).push(propType);
34312                         definedInConstructor = true;
34313                     }
34314                 }
34315                 var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304); }) ? constructorTypes : types;
34316                 type = getUnionType(sourceTypes, 2);
34317             }
34318             var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor));
34319             if (filterType(widened, function (t) { return !!(t.flags & ~98304); }) === neverType) {
34320                 reportImplicitAny(symbol.valueDeclaration, anyType);
34321                 return anyType;
34322             }
34323             return widened;
34324         }
34325         function getJSContainerObjectType(decl, symbol, init) {
34326             if (!ts.isInJSFile(decl) || !init || !ts.isObjectLiteralExpression(init) || init.properties.length) {
34327                 return undefined;
34328             }
34329             var exports = ts.createSymbolTable();
34330             while (ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl)) {
34331                 var s_2 = getSymbolOfNode(decl);
34332                 if (s_2 && ts.hasEntries(s_2.exports)) {
34333                     mergeSymbolTable(exports, s_2.exports);
34334                 }
34335                 decl = ts.isBinaryExpression(decl) ? decl.parent : decl.parent.parent;
34336             }
34337             var s = getSymbolOfNode(decl);
34338             if (s && ts.hasEntries(s.exports)) {
34339                 mergeSymbolTable(exports, s.exports);
34340             }
34341             var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, undefined, undefined);
34342             type.objectFlags |= 16384;
34343             return type;
34344         }
34345         function getAnnotatedTypeForAssignmentDeclaration(declaredType, expression, symbol, declaration) {
34346             var typeNode = ts.getEffectiveTypeAnnotationNode(expression.parent);
34347             if (typeNode) {
34348                 var type = getWidenedType(getTypeFromTypeNode(typeNode));
34349                 if (!declaredType) {
34350                     return type;
34351                 }
34352                 else if (declaredType !== errorType && type !== errorType && !isTypeIdenticalTo(declaredType, type)) {
34353                     errorNextVariableOrPropertyDeclarationMustHaveSameType(undefined, declaredType, declaration, type);
34354                 }
34355             }
34356             if (symbol.parent) {
34357                 var typeNode_2 = ts.getEffectiveTypeAnnotationNode(symbol.parent.valueDeclaration);
34358                 if (typeNode_2) {
34359                     return getTypeOfPropertyOfType(getTypeFromTypeNode(typeNode_2), symbol.escapedName);
34360                 }
34361             }
34362             return declaredType;
34363         }
34364         function getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) {
34365             if (ts.isCallExpression(expression)) {
34366                 if (resolvedSymbol) {
34367                     return getTypeOfSymbol(resolvedSymbol);
34368                 }
34369                 var objectLitType = checkExpressionCached(expression.arguments[2]);
34370                 var valueType = getTypeOfPropertyOfType(objectLitType, "value");
34371                 if (valueType) {
34372                     return valueType;
34373                 }
34374                 var getFunc = getTypeOfPropertyOfType(objectLitType, "get");
34375                 if (getFunc) {
34376                     var getSig = getSingleCallSignature(getFunc);
34377                     if (getSig) {
34378                         return getReturnTypeOfSignature(getSig);
34379                     }
34380                 }
34381                 var setFunc = getTypeOfPropertyOfType(objectLitType, "set");
34382                 if (setFunc) {
34383                     var setSig = getSingleCallSignature(setFunc);
34384                     if (setSig) {
34385                         return getTypeOfFirstParameterOfSignature(setSig);
34386                     }
34387                 }
34388                 return anyType;
34389             }
34390             if (containsSameNamedThisProperty(expression.left, expression.right)) {
34391                 return anyType;
34392             }
34393             var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : getWidenedLiteralType(checkExpressionCached(expression.right));
34394             if (type.flags & 524288 &&
34395                 kind === 2 &&
34396                 symbol.escapedName === "export=") {
34397                 var exportedType = resolveStructuredTypeMembers(type);
34398                 var members_4 = ts.createSymbolTable();
34399                 ts.copyEntries(exportedType.members, members_4);
34400                 if (resolvedSymbol && !resolvedSymbol.exports) {
34401                     resolvedSymbol.exports = ts.createSymbolTable();
34402                 }
34403                 (resolvedSymbol || symbol).exports.forEach(function (s, name) {
34404                     var _a;
34405                     var exportedMember = members_4.get(name);
34406                     if (exportedMember && exportedMember !== s) {
34407                         if (s.flags & 111551) {
34408                             if (ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) {
34409                                 var unescapedName = ts.unescapeLeadingUnderscores(s.escapedName);
34410                                 var exportedMemberName = ((_a = ts.tryCast(exportedMember.valueDeclaration, ts.isNamedDeclaration)) === null || _a === void 0 ? void 0 : _a.name) || exportedMember.valueDeclaration;
34411                                 ts.addRelatedInfo(error(s.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(exportedMemberName, ts.Diagnostics._0_was_also_declared_here, unescapedName));
34412                                 ts.addRelatedInfo(error(exportedMemberName, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(s.valueDeclaration, ts.Diagnostics._0_was_also_declared_here, unescapedName));
34413                             }
34414                             var union = createSymbol(s.flags | exportedMember.flags, name);
34415                             union.type = getUnionType([getTypeOfSymbol(s), getTypeOfSymbol(exportedMember)]);
34416                             union.valueDeclaration = exportedMember.valueDeclaration;
34417                             union.declarations = ts.concatenate(exportedMember.declarations, s.declarations);
34418                             members_4.set(name, union);
34419                         }
34420                         else {
34421                             members_4.set(name, mergeSymbol(s, exportedMember));
34422                         }
34423                     }
34424                     else {
34425                         members_4.set(name, s);
34426                     }
34427                 });
34428                 var result = createAnonymousType(exportedType.symbol, members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.stringIndexInfo, exportedType.numberIndexInfo);
34429                 result.objectFlags |= (ts.getObjectFlags(type) & 16384);
34430                 return result;
34431             }
34432             if (isEmptyArrayLiteralType(type)) {
34433                 reportImplicitAny(expression, anyArrayType);
34434                 return anyArrayType;
34435             }
34436             return type;
34437         }
34438         function containsSameNamedThisProperty(thisProperty, expression) {
34439             return ts.isPropertyAccessExpression(thisProperty)
34440                 && thisProperty.expression.kind === 104
34441                 && ts.forEachChildRecursively(expression, function (n) { return isMatchingReference(thisProperty, n); });
34442         }
34443         function isDeclarationInConstructor(expression) {
34444             var thisContainer = ts.getThisContainer(expression, false);
34445             return thisContainer.kind === 162 ||
34446                 thisContainer.kind === 244 ||
34447                 (thisContainer.kind === 201 && !ts.isPrototypePropertyAssignment(thisContainer.parent));
34448         }
34449         function getConstructorDefinedThisAssignmentTypes(types, declarations) {
34450             ts.Debug.assert(types.length === declarations.length);
34451             return types.filter(function (_, i) {
34452                 var declaration = declarations[i];
34453                 var expression = ts.isBinaryExpression(declaration) ? declaration :
34454                     ts.isBinaryExpression(declaration.parent) ? declaration.parent : undefined;
34455                 return expression && isDeclarationInConstructor(expression);
34456             });
34457         }
34458         function getTypeOfAssignmentDeclarationPropertyOfBaseType(property) {
34459             var parentDeclaration = ts.forEach(property.declarations, function (d) {
34460                 var parent = ts.getThisContainer(d, false).parent;
34461                 return ts.isClassLike(parent) && parent;
34462             });
34463             if (parentDeclaration) {
34464                 var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(parentDeclaration));
34465                 var baseClassType = classType && getBaseTypes(classType)[0];
34466                 if (baseClassType) {
34467                     return getTypeOfPropertyOfType(baseClassType, property.escapedName);
34468                 }
34469             }
34470         }
34471         function getTypeFromBindingElement(element, includePatternInType, reportErrors) {
34472             if (element.initializer) {
34473                 var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, true, false) : unknownType;
34474                 return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, contextualType)));
34475             }
34476             if (ts.isBindingPattern(element.name)) {
34477                 return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors);
34478             }
34479             if (reportErrors && !declarationBelongsToPrivateAmbientMember(element)) {
34480                 reportImplicitAny(element, anyType);
34481             }
34482             return includePatternInType ? nonInferrableAnyType : anyType;
34483         }
34484         function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) {
34485             var members = ts.createSymbolTable();
34486             var stringIndexInfo;
34487             var objectFlags = 128 | 1048576;
34488             ts.forEach(pattern.elements, function (e) {
34489                 var name = e.propertyName || e.name;
34490                 if (e.dotDotDotToken) {
34491                     stringIndexInfo = createIndexInfo(anyType, false);
34492                     return;
34493                 }
34494                 var exprType = getLiteralTypeFromPropertyName(name);
34495                 if (!isTypeUsableAsPropertyName(exprType)) {
34496                     objectFlags |= 512;
34497                     return;
34498                 }
34499                 var text = getPropertyNameFromType(exprType);
34500                 var flags = 4 | (e.initializer ? 16777216 : 0);
34501                 var symbol = createSymbol(flags, text);
34502                 symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors);
34503                 symbol.bindingElement = e;
34504                 members.set(symbol.escapedName, symbol);
34505             });
34506             var result = createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined);
34507             result.objectFlags |= objectFlags;
34508             if (includePatternInType) {
34509                 result.pattern = pattern;
34510                 result.objectFlags |= 1048576;
34511             }
34512             return result;
34513         }
34514         function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) {
34515             var elements = pattern.elements;
34516             var lastElement = ts.lastOrUndefined(elements);
34517             var hasRestElement = !!(lastElement && lastElement.kind === 191 && lastElement.dotDotDotToken);
34518             if (elements.length === 0 || elements.length === 1 && hasRestElement) {
34519                 return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType;
34520             }
34521             var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); });
34522             var minLength = ts.findLastIndex(elements, function (e) { return !ts.isOmittedExpression(e) && !hasDefaultValue(e); }, elements.length - (hasRestElement ? 2 : 1)) + 1;
34523             var result = createTupleType(elementTypes, minLength, hasRestElement);
34524             if (includePatternInType) {
34525                 result = cloneTypeReference(result);
34526                 result.pattern = pattern;
34527                 result.objectFlags |= 1048576;
34528             }
34529             return result;
34530         }
34531         function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) {
34532             if (includePatternInType === void 0) { includePatternInType = false; }
34533             if (reportErrors === void 0) { reportErrors = false; }
34534             return pattern.kind === 189
34535                 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors)
34536                 : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors);
34537         }
34538         function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
34539             return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, true), declaration, reportErrors);
34540         }
34541         function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors) {
34542             if (type) {
34543                 if (reportErrors) {
34544                     reportErrorsFromWidening(declaration, type);
34545                 }
34546                 if (type.flags & 8192 && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) {
34547                     type = esSymbolType;
34548                 }
34549                 return getWidenedType(type);
34550             }
34551             type = ts.isParameter(declaration) && declaration.dotDotDotToken ? anyArrayType : anyType;
34552             if (reportErrors) {
34553                 if (!declarationBelongsToPrivateAmbientMember(declaration)) {
34554                     reportImplicitAny(declaration, type);
34555                 }
34556             }
34557             return type;
34558         }
34559         function declarationBelongsToPrivateAmbientMember(declaration) {
34560             var root = ts.getRootDeclaration(declaration);
34561             var memberDeclaration = root.kind === 156 ? root.parent : root;
34562             return isPrivateWithinAmbient(memberDeclaration);
34563         }
34564         function tryGetTypeFromEffectiveTypeNode(declaration) {
34565             var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
34566             if (typeNode) {
34567                 return getTypeFromTypeNode(typeNode);
34568             }
34569         }
34570         function getTypeOfVariableOrParameterOrProperty(symbol) {
34571             var links = getSymbolLinks(symbol);
34572             if (!links.type) {
34573                 var type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
34574                 if (!links.type) {
34575                     links.type = type;
34576                 }
34577             }
34578             return links.type;
34579         }
34580         function getTypeOfVariableOrParameterOrPropertyWorker(symbol) {
34581             if (symbol.flags & 4194304) {
34582                 return getTypeOfPrototypeProperty(symbol);
34583             }
34584             if (symbol === requireSymbol) {
34585                 return anyType;
34586             }
34587             if (symbol.flags & 134217728) {
34588                 var fileSymbol = getSymbolOfNode(ts.getSourceFileOfNode(symbol.valueDeclaration));
34589                 var members = ts.createSymbolTable();
34590                 members.set("exports", fileSymbol);
34591                 return createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, undefined, undefined);
34592             }
34593             var declaration = symbol.valueDeclaration;
34594             if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) {
34595                 return anyType;
34596             }
34597             if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) {
34598                 if (!declaration.statements.length) {
34599                     return emptyObjectType;
34600                 }
34601                 return getWidenedType(getWidenedLiteralType(checkExpression(declaration.statements[0].expression)));
34602             }
34603             if (!pushTypeResolution(symbol, 0)) {
34604                 if (symbol.flags & 512 && !(symbol.flags & 67108864)) {
34605                     return getTypeOfFuncClassEnumModule(symbol);
34606                 }
34607                 return reportCircularityError(symbol);
34608             }
34609             var type;
34610             if (declaration.kind === 259) {
34611                 type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration);
34612             }
34613             else if (ts.isBinaryExpression(declaration) ||
34614                 (ts.isInJSFile(declaration) &&
34615                     (ts.isCallExpression(declaration) || (ts.isPropertyAccessExpression(declaration) || ts.isBindableStaticElementAccessExpression(declaration)) && ts.isBinaryExpression(declaration.parent)))) {
34616                 type = getWidenedTypeForAssignmentDeclaration(symbol);
34617             }
34618             else if (ts.isJSDocPropertyLikeTag(declaration)
34619                 || ts.isPropertyAccessExpression(declaration)
34620                 || ts.isElementAccessExpression(declaration)
34621                 || ts.isIdentifier(declaration)
34622                 || ts.isStringLiteralLike(declaration)
34623                 || ts.isNumericLiteral(declaration)
34624                 || ts.isClassDeclaration(declaration)
34625                 || ts.isFunctionDeclaration(declaration)
34626                 || (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration))
34627                 || ts.isMethodSignature(declaration)
34628                 || ts.isSourceFile(declaration)) {
34629                 if (symbol.flags & (16 | 8192 | 32 | 384 | 512)) {
34630                     return getTypeOfFuncClassEnumModule(symbol);
34631                 }
34632                 type = ts.isBinaryExpression(declaration.parent) ?
34633                     getWidenedTypeForAssignmentDeclaration(symbol) :
34634                     tryGetTypeFromEffectiveTypeNode(declaration) || anyType;
34635             }
34636             else if (ts.isPropertyAssignment(declaration)) {
34637                 type = tryGetTypeFromEffectiveTypeNode(declaration) || checkPropertyAssignment(declaration);
34638             }
34639             else if (ts.isJsxAttribute(declaration)) {
34640                 type = tryGetTypeFromEffectiveTypeNode(declaration) || checkJsxAttribute(declaration);
34641             }
34642             else if (ts.isShorthandPropertyAssignment(declaration)) {
34643                 type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0);
34644             }
34645             else if (ts.isObjectLiteralMethod(declaration)) {
34646                 type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0);
34647             }
34648             else if (ts.isParameter(declaration)
34649                 || ts.isPropertyDeclaration(declaration)
34650                 || ts.isPropertySignature(declaration)
34651                 || ts.isVariableDeclaration(declaration)
34652                 || ts.isBindingElement(declaration)) {
34653                 type = getWidenedTypeForVariableLikeDeclaration(declaration, true);
34654             }
34655             else if (ts.isEnumDeclaration(declaration)) {
34656                 type = getTypeOfFuncClassEnumModule(symbol);
34657             }
34658             else if (ts.isEnumMember(declaration)) {
34659                 type = getTypeOfEnumMember(symbol);
34660             }
34661             else if (ts.isAccessor(declaration)) {
34662                 type = resolveTypeOfAccessors(symbol);
34663             }
34664             else {
34665                 return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol));
34666             }
34667             if (!popTypeResolution()) {
34668                 if (symbol.flags & 512 && !(symbol.flags & 67108864)) {
34669                     return getTypeOfFuncClassEnumModule(symbol);
34670                 }
34671                 return reportCircularityError(symbol);
34672             }
34673             return type;
34674         }
34675         function getAnnotatedAccessorTypeNode(accessor) {
34676             if (accessor) {
34677                 if (accessor.kind === 163) {
34678                     var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor);
34679                     return getterTypeAnnotation;
34680                 }
34681                 else {
34682                     var setterTypeAnnotation = ts.getEffectiveSetAccessorTypeAnnotationNode(accessor);
34683                     return setterTypeAnnotation;
34684                 }
34685             }
34686             return undefined;
34687         }
34688         function getAnnotatedAccessorType(accessor) {
34689             var node = getAnnotatedAccessorTypeNode(accessor);
34690             return node && getTypeFromTypeNode(node);
34691         }
34692         function getAnnotatedAccessorThisParameter(accessor) {
34693             var parameter = getAccessorThisParameter(accessor);
34694             return parameter && parameter.symbol;
34695         }
34696         function getThisTypeOfDeclaration(declaration) {
34697             return getThisTypeOfSignature(getSignatureFromDeclaration(declaration));
34698         }
34699         function getTypeOfAccessors(symbol) {
34700             var links = getSymbolLinks(symbol);
34701             return links.type || (links.type = getTypeOfAccessorsWorker(symbol));
34702         }
34703         function getTypeOfAccessorsWorker(symbol) {
34704             if (!pushTypeResolution(symbol, 0)) {
34705                 return errorType;
34706             }
34707             var type = resolveTypeOfAccessors(symbol);
34708             if (!popTypeResolution()) {
34709                 type = anyType;
34710                 if (noImplicitAny) {
34711                     var getter = ts.getDeclarationOfKind(symbol, 163);
34712                     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));
34713                 }
34714             }
34715             return type;
34716         }
34717         function resolveTypeOfAccessors(symbol) {
34718             var getter = ts.getDeclarationOfKind(symbol, 163);
34719             var setter = ts.getDeclarationOfKind(symbol, 164);
34720             if (getter && ts.isInJSFile(getter)) {
34721                 var jsDocType = getTypeForDeclarationFromJSDocComment(getter);
34722                 if (jsDocType) {
34723                     return jsDocType;
34724                 }
34725             }
34726             var getterReturnType = getAnnotatedAccessorType(getter);
34727             if (getterReturnType) {
34728                 return getterReturnType;
34729             }
34730             else {
34731                 var setterParameterType = getAnnotatedAccessorType(setter);
34732                 if (setterParameterType) {
34733                     return setterParameterType;
34734                 }
34735                 else {
34736                     if (getter && getter.body) {
34737                         return getReturnTypeFromBody(getter);
34738                     }
34739                     else {
34740                         if (setter) {
34741                             if (!isPrivateWithinAmbient(setter)) {
34742                                 errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
34743                             }
34744                         }
34745                         else {
34746                             ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function");
34747                             if (!isPrivateWithinAmbient(getter)) {
34748                                 errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
34749                             }
34750                         }
34751                         return anyType;
34752                     }
34753                 }
34754             }
34755         }
34756         function getBaseTypeVariableOfClass(symbol) {
34757             var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol));
34758             return baseConstructorType.flags & 8650752 ? baseConstructorType :
34759                 baseConstructorType.flags & 2097152 ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752); }) :
34760                     undefined;
34761         }
34762         function getTypeOfFuncClassEnumModule(symbol) {
34763             var links = getSymbolLinks(symbol);
34764             var originalLinks = links;
34765             if (!links.type) {
34766                 var jsDeclaration = symbol.valueDeclaration && ts.getDeclarationOfExpando(symbol.valueDeclaration);
34767                 if (jsDeclaration) {
34768                     var merged = mergeJSSymbols(symbol, getSymbolOfNode(jsDeclaration));
34769                     if (merged) {
34770                         symbol = links = merged;
34771                     }
34772                 }
34773                 originalLinks.type = links.type = getTypeOfFuncClassEnumModuleWorker(symbol);
34774             }
34775             return links.type;
34776         }
34777         function getTypeOfFuncClassEnumModuleWorker(symbol) {
34778             var declaration = symbol.valueDeclaration;
34779             if (symbol.flags & 1536 && ts.isShorthandAmbientModuleSymbol(symbol)) {
34780                 return anyType;
34781             }
34782             else if (declaration && (declaration.kind === 209 ||
34783                 ts.isAccessExpression(declaration) &&
34784                     declaration.parent.kind === 209)) {
34785                 return getWidenedTypeForAssignmentDeclaration(symbol);
34786             }
34787             else if (symbol.flags & 512 && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) {
34788                 var resolvedModule = resolveExternalModuleSymbol(symbol);
34789                 if (resolvedModule !== symbol) {
34790                     if (!pushTypeResolution(symbol, 0)) {
34791                         return errorType;
34792                     }
34793                     var exportEquals = getMergedSymbol(symbol.exports.get("export="));
34794                     var type_1 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
34795                     if (!popTypeResolution()) {
34796                         return reportCircularityError(symbol);
34797                     }
34798                     return type_1;
34799                 }
34800             }
34801             var type = createObjectType(16, symbol);
34802             if (symbol.flags & 32) {
34803                 var baseTypeVariable = getBaseTypeVariableOfClass(symbol);
34804                 return baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type;
34805             }
34806             else {
34807                 return strictNullChecks && symbol.flags & 16777216 ? getOptionalType(type) : type;
34808             }
34809         }
34810         function getTypeOfEnumMember(symbol) {
34811             var links = getSymbolLinks(symbol);
34812             return links.type || (links.type = getDeclaredTypeOfEnumMember(symbol));
34813         }
34814         function getTypeOfAlias(symbol) {
34815             var links = getSymbolLinks(symbol);
34816             if (!links.type) {
34817                 var targetSymbol = resolveAlias(symbol);
34818                 links.type = targetSymbol.flags & 111551
34819                     ? getTypeOfSymbol(targetSymbol)
34820                     : errorType;
34821             }
34822             return links.type;
34823         }
34824         function getTypeOfInstantiatedSymbol(symbol) {
34825             var links = getSymbolLinks(symbol);
34826             if (!links.type) {
34827                 if (!pushTypeResolution(symbol, 0)) {
34828                     return links.type = errorType;
34829                 }
34830                 var type = instantiateType(getTypeOfSymbol(links.target), links.mapper);
34831                 if (!popTypeResolution()) {
34832                     type = reportCircularityError(symbol);
34833                 }
34834                 links.type = type;
34835             }
34836             return links.type;
34837         }
34838         function reportCircularityError(symbol) {
34839             var declaration = symbol.valueDeclaration;
34840             if (ts.getEffectiveTypeAnnotationNode(declaration)) {
34841                 error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
34842                 return errorType;
34843             }
34844             if (noImplicitAny && (declaration.kind !== 156 || declaration.initializer)) {
34845                 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));
34846             }
34847             return anyType;
34848         }
34849         function getTypeOfSymbolWithDeferredType(symbol) {
34850             var links = getSymbolLinks(symbol);
34851             if (!links.type) {
34852                 ts.Debug.assertIsDefined(links.deferralParent);
34853                 ts.Debug.assertIsDefined(links.deferralConstituents);
34854                 links.type = links.deferralParent.flags & 1048576 ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents);
34855             }
34856             return links.type;
34857         }
34858         function getTypeOfSymbol(symbol) {
34859             var checkFlags = ts.getCheckFlags(symbol);
34860             if (checkFlags & 65536) {
34861                 return getTypeOfSymbolWithDeferredType(symbol);
34862             }
34863             if (checkFlags & 1) {
34864                 return getTypeOfInstantiatedSymbol(symbol);
34865             }
34866             if (checkFlags & 262144) {
34867                 return getTypeOfMappedSymbol(symbol);
34868             }
34869             if (checkFlags & 8192) {
34870                 return getTypeOfReverseMappedSymbol(symbol);
34871             }
34872             if (symbol.flags & (3 | 4)) {
34873                 return getTypeOfVariableOrParameterOrProperty(symbol);
34874             }
34875             if (symbol.flags & (16 | 8192 | 32 | 384 | 512)) {
34876                 return getTypeOfFuncClassEnumModule(symbol);
34877             }
34878             if (symbol.flags & 8) {
34879                 return getTypeOfEnumMember(symbol);
34880             }
34881             if (symbol.flags & 98304) {
34882                 return getTypeOfAccessors(symbol);
34883             }
34884             if (symbol.flags & 2097152) {
34885                 return getTypeOfAlias(symbol);
34886             }
34887             return errorType;
34888         }
34889         function isReferenceToType(type, target) {
34890             return type !== undefined
34891                 && target !== undefined
34892                 && (ts.getObjectFlags(type) & 4) !== 0
34893                 && type.target === target;
34894         }
34895         function getTargetType(type) {
34896             return ts.getObjectFlags(type) & 4 ? type.target : type;
34897         }
34898         function hasBaseType(type, checkBase) {
34899             return check(type);
34900             function check(type) {
34901                 if (ts.getObjectFlags(type) & (3 | 4)) {
34902                     var target = getTargetType(type);
34903                     return target === checkBase || ts.some(getBaseTypes(target), check);
34904                 }
34905                 else if (type.flags & 2097152) {
34906                     return ts.some(type.types, check);
34907                 }
34908                 return false;
34909             }
34910         }
34911         function appendTypeParameters(typeParameters, declarations) {
34912             for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) {
34913                 var declaration = declarations_2[_i];
34914                 typeParameters = ts.appendIfUnique(typeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)));
34915             }
34916             return typeParameters;
34917         }
34918         function getOuterTypeParameters(node, includeThisTypes) {
34919             while (true) {
34920                 node = node.parent;
34921                 if (node && ts.isBinaryExpression(node)) {
34922                     var assignmentKind = ts.getAssignmentDeclarationKind(node);
34923                     if (assignmentKind === 6 || assignmentKind === 3) {
34924                         var symbol = getSymbolOfNode(node.left);
34925                         if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) {
34926                             node = symbol.parent.valueDeclaration;
34927                         }
34928                     }
34929                 }
34930                 if (!node) {
34931                     return undefined;
34932                 }
34933                 switch (node.kind) {
34934                     case 225:
34935                     case 245:
34936                     case 214:
34937                     case 246:
34938                     case 165:
34939                     case 166:
34940                     case 160:
34941                     case 170:
34942                     case 171:
34943                     case 300:
34944                     case 244:
34945                     case 161:
34946                     case 201:
34947                     case 202:
34948                     case 247:
34949                     case 321:
34950                     case 322:
34951                     case 316:
34952                     case 315:
34953                     case 186:
34954                     case 180:
34955                         var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes);
34956                         if (node.kind === 186) {
34957                             return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)));
34958                         }
34959                         else if (node.kind === 180) {
34960                             return ts.concatenate(outerTypeParameters, getInferTypeParameters(node));
34961                         }
34962                         else if (node.kind === 225 && !ts.isInJSFile(node)) {
34963                             break;
34964                         }
34965                         var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node));
34966                         var thisType = includeThisTypes &&
34967                             (node.kind === 245 || node.kind === 214 || node.kind === 246 || isJSConstructor(node)) &&
34968                             getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType;
34969                         return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters;
34970                 }
34971             }
34972         }
34973         function getOuterTypeParametersOfClassOrInterface(symbol) {
34974             var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 246);
34975             ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations");
34976             return getOuterTypeParameters(declaration);
34977         }
34978         function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) {
34979             var result;
34980             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
34981                 var node = _a[_i];
34982                 if (node.kind === 246 ||
34983                     node.kind === 245 ||
34984                     node.kind === 214 ||
34985                     isJSConstructor(node) ||
34986                     ts.isTypeAlias(node)) {
34987                     var declaration = node;
34988                     result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration));
34989                 }
34990             }
34991             return result;
34992         }
34993         function getTypeParametersOfClassOrInterface(symbol) {
34994             return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol));
34995         }
34996         function isMixinConstructorType(type) {
34997             var signatures = getSignaturesOfType(type, 1);
34998             if (signatures.length === 1) {
34999                 var s = signatures[0];
35000                 return !s.typeParameters && s.parameters.length === 1 && signatureHasRestParameter(s) && getElementTypeOfArrayType(getTypeOfParameter(s.parameters[0])) === anyType;
35001             }
35002             return false;
35003         }
35004         function isConstructorType(type) {
35005             if (getSignaturesOfType(type, 1).length > 0) {
35006                 return true;
35007             }
35008             if (type.flags & 8650752) {
35009                 var constraint = getBaseConstraintOfType(type);
35010                 return !!constraint && isMixinConstructorType(constraint);
35011             }
35012             return false;
35013         }
35014         function getBaseTypeNodeOfClass(type) {
35015             return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration);
35016         }
35017         function getConstructorsForTypeArguments(type, typeArgumentNodes, location) {
35018             var typeArgCount = ts.length(typeArgumentNodes);
35019             var isJavascript = ts.isInJSFile(location);
35020             return ts.filter(getSignaturesOfType(type, 1), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); });
35021         }
35022         function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) {
35023             var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location);
35024             var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode);
35025             return ts.sameMap(signatures, function (sig) { return ts.some(sig.typeParameters) ? getSignatureInstantiation(sig, typeArguments, ts.isInJSFile(location)) : sig; });
35026         }
35027         function getBaseConstructorTypeOfClass(type) {
35028             if (!type.resolvedBaseConstructorType) {
35029                 var decl = type.symbol.valueDeclaration;
35030                 var extended = ts.getEffectiveBaseTypeNode(decl);
35031                 var baseTypeNode = getBaseTypeNodeOfClass(type);
35032                 if (!baseTypeNode) {
35033                     return type.resolvedBaseConstructorType = undefinedType;
35034                 }
35035                 if (!pushTypeResolution(type, 1)) {
35036                     return errorType;
35037                 }
35038                 var baseConstructorType = checkExpression(baseTypeNode.expression);
35039                 if (extended && baseTypeNode !== extended) {
35040                     ts.Debug.assert(!extended.typeArguments);
35041                     checkExpression(extended.expression);
35042                 }
35043                 if (baseConstructorType.flags & (524288 | 2097152)) {
35044                     resolveStructuredTypeMembers(baseConstructorType);
35045                 }
35046                 if (!popTypeResolution()) {
35047                     error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol));
35048                     return type.resolvedBaseConstructorType = errorType;
35049                 }
35050                 if (!(baseConstructorType.flags & 1) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) {
35051                     var err = error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType));
35052                     if (baseConstructorType.flags & 262144) {
35053                         var constraint = getConstraintFromTypeParameter(baseConstructorType);
35054                         var ctorReturn = unknownType;
35055                         if (constraint) {
35056                             var ctorSig = getSignaturesOfType(constraint, 1);
35057                             if (ctorSig[0]) {
35058                                 ctorReturn = getReturnTypeOfSignature(ctorSig[0]);
35059                             }
35060                         }
35061                         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)));
35062                     }
35063                     return type.resolvedBaseConstructorType = errorType;
35064                 }
35065                 type.resolvedBaseConstructorType = baseConstructorType;
35066             }
35067             return type.resolvedBaseConstructorType;
35068         }
35069         function getImplementsTypes(type) {
35070             var resolvedImplementsTypes = ts.emptyArray;
35071             for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) {
35072                 var declaration = _a[_i];
35073                 var implementsTypeNodes = ts.getEffectiveImplementsTypeNodes(declaration);
35074                 if (!implementsTypeNodes)
35075                     continue;
35076                 for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) {
35077                     var node = implementsTypeNodes_1[_b];
35078                     var implementsType = getTypeFromTypeNode(node);
35079                     if (implementsType !== errorType) {
35080                         if (resolvedImplementsTypes === ts.emptyArray) {
35081                             resolvedImplementsTypes = [implementsType];
35082                         }
35083                         else {
35084                             resolvedImplementsTypes.push(implementsType);
35085                         }
35086                     }
35087                 }
35088             }
35089             return resolvedImplementsTypes;
35090         }
35091         function getBaseTypes(type) {
35092             if (!type.resolvedBaseTypes) {
35093                 if (type.objectFlags & 8) {
35094                     type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters || ts.emptyArray), type.readonly)];
35095                 }
35096                 else if (type.symbol.flags & (32 | 64)) {
35097                     if (type.symbol.flags & 32) {
35098                         resolveBaseTypesOfClass(type);
35099                     }
35100                     if (type.symbol.flags & 64) {
35101                         resolveBaseTypesOfInterface(type);
35102                     }
35103                 }
35104                 else {
35105                     ts.Debug.fail("type must be class or interface");
35106                 }
35107             }
35108             return type.resolvedBaseTypes;
35109         }
35110         function resolveBaseTypesOfClass(type) {
35111             type.resolvedBaseTypes = ts.resolvingEmptyArray;
35112             var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type));
35113             if (!(baseConstructorType.flags & (524288 | 2097152 | 1))) {
35114                 return type.resolvedBaseTypes = ts.emptyArray;
35115             }
35116             var baseTypeNode = getBaseTypeNodeOfClass(type);
35117             var baseType;
35118             var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined;
35119             if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 &&
35120                 areAllOuterTypeParametersApplied(originalBaseType)) {
35121                 baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol);
35122             }
35123             else if (baseConstructorType.flags & 1) {
35124                 baseType = baseConstructorType;
35125             }
35126             else {
35127                 var constructors = getInstantiatedConstructorsForTypeArguments(baseConstructorType, baseTypeNode.typeArguments, baseTypeNode);
35128                 if (!constructors.length) {
35129                     error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments);
35130                     return type.resolvedBaseTypes = ts.emptyArray;
35131                 }
35132                 baseType = getReturnTypeOfSignature(constructors[0]);
35133             }
35134             if (baseType === errorType) {
35135                 return type.resolvedBaseTypes = ts.emptyArray;
35136             }
35137             var reducedBaseType = getReducedType(baseType);
35138             if (!isValidBaseType(reducedBaseType)) {
35139                 var elaboration = elaborateNeverIntersection(undefined, baseType);
35140                 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));
35141                 diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(baseTypeNode.expression, diagnostic));
35142                 return type.resolvedBaseTypes = ts.emptyArray;
35143             }
35144             if (type === reducedBaseType || hasBaseType(reducedBaseType, type)) {
35145                 error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 2));
35146                 return type.resolvedBaseTypes = ts.emptyArray;
35147             }
35148             if (type.resolvedBaseTypes === ts.resolvingEmptyArray) {
35149                 type.members = undefined;
35150             }
35151             return type.resolvedBaseTypes = [reducedBaseType];
35152         }
35153         function areAllOuterTypeParametersApplied(type) {
35154             var outerTypeParameters = type.outerTypeParameters;
35155             if (outerTypeParameters) {
35156                 var last_1 = outerTypeParameters.length - 1;
35157                 var typeArguments = getTypeArguments(type);
35158                 return outerTypeParameters[last_1].symbol !== typeArguments[last_1].symbol;
35159             }
35160             return true;
35161         }
35162         function isValidBaseType(type) {
35163             if (type.flags & 262144) {
35164                 var constraint = getBaseConstraintOfType(type);
35165                 if (constraint) {
35166                     return isValidBaseType(constraint);
35167                 }
35168             }
35169             return !!(type.flags & (524288 | 67108864 | 1) && !isGenericMappedType(type) ||
35170                 type.flags & 2097152 && ts.every(type.types, isValidBaseType));
35171         }
35172         function resolveBaseTypesOfInterface(type) {
35173             type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray;
35174             for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) {
35175                 var declaration = _a[_i];
35176                 if (declaration.kind === 246 && ts.getInterfaceBaseTypeNodes(declaration)) {
35177                     for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) {
35178                         var node = _c[_b];
35179                         var baseType = getReducedType(getTypeFromTypeNode(node));
35180                         if (baseType !== errorType) {
35181                             if (isValidBaseType(baseType)) {
35182                                 if (type !== baseType && !hasBaseType(baseType, type)) {
35183                                     if (type.resolvedBaseTypes === ts.emptyArray) {
35184                                         type.resolvedBaseTypes = [baseType];
35185                                     }
35186                                     else {
35187                                         type.resolvedBaseTypes.push(baseType);
35188                                     }
35189                                 }
35190                                 else {
35191                                     error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 2));
35192                                 }
35193                             }
35194                             else {
35195                                 error(node, ts.Diagnostics.An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members);
35196                             }
35197                         }
35198                     }
35199                 }
35200             }
35201         }
35202         function isThislessInterface(symbol) {
35203             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
35204                 var declaration = _a[_i];
35205                 if (declaration.kind === 246) {
35206                     if (declaration.flags & 128) {
35207                         return false;
35208                     }
35209                     var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration);
35210                     if (baseTypeNodes) {
35211                         for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) {
35212                             var node = baseTypeNodes_1[_b];
35213                             if (ts.isEntityNameExpression(node.expression)) {
35214                                 var baseSymbol = resolveEntityName(node.expression, 788968, true);
35215                                 if (!baseSymbol || !(baseSymbol.flags & 64) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) {
35216                                     return false;
35217                                 }
35218                             }
35219                         }
35220                     }
35221                 }
35222             }
35223             return true;
35224         }
35225         function getDeclaredTypeOfClassOrInterface(symbol) {
35226             var links = getSymbolLinks(symbol);
35227             var originalLinks = links;
35228             if (!links.declaredType) {
35229                 var kind = symbol.flags & 32 ? 1 : 2;
35230                 var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration));
35231                 if (merged) {
35232                     symbol = links = merged;
35233                 }
35234                 var type = originalLinks.declaredType = links.declaredType = createObjectType(kind, symbol);
35235                 var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol);
35236                 var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
35237                 if (outerTypeParameters || localTypeParameters || kind === 1 || !isThislessInterface(symbol)) {
35238                     type.objectFlags |= 4;
35239                     type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters);
35240                     type.outerTypeParameters = outerTypeParameters;
35241                     type.localTypeParameters = localTypeParameters;
35242                     type.instantiations = ts.createMap();
35243                     type.instantiations.set(getTypeListId(type.typeParameters), type);
35244                     type.target = type;
35245                     type.resolvedTypeArguments = type.typeParameters;
35246                     type.thisType = createTypeParameter(symbol);
35247                     type.thisType.isThisType = true;
35248                     type.thisType.constraint = type;
35249                 }
35250             }
35251             return links.declaredType;
35252         }
35253         function getDeclaredTypeOfTypeAlias(symbol) {
35254             var links = getSymbolLinks(symbol);
35255             if (!links.declaredType) {
35256                 if (!pushTypeResolution(symbol, 2)) {
35257                     return errorType;
35258                 }
35259                 var declaration = ts.Debug.checkDefined(ts.find(symbol.declarations, ts.isTypeAlias), "Type alias symbol with no valid declaration found");
35260                 var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type;
35261                 var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType;
35262                 if (popTypeResolution()) {
35263                     var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
35264                     if (typeParameters) {
35265                         links.typeParameters = typeParameters;
35266                         links.instantiations = ts.createMap();
35267                         links.instantiations.set(getTypeListId(typeParameters), type);
35268                     }
35269                 }
35270                 else {
35271                     type = errorType;
35272                     error(ts.isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
35273                 }
35274                 links.declaredType = type;
35275             }
35276             return links.declaredType;
35277         }
35278         function isStringConcatExpression(expr) {
35279             if (ts.isStringLiteralLike(expr)) {
35280                 return true;
35281             }
35282             else if (expr.kind === 209) {
35283                 return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right);
35284             }
35285             return false;
35286         }
35287         function isLiteralEnumMember(member) {
35288             var expr = member.initializer;
35289             if (!expr) {
35290                 return !(member.flags & 8388608);
35291             }
35292             switch (expr.kind) {
35293                 case 10:
35294                 case 8:
35295                 case 14:
35296                     return true;
35297                 case 207:
35298                     return expr.operator === 40 &&
35299                         expr.operand.kind === 8;
35300                 case 75:
35301                     return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText);
35302                 case 209:
35303                     return isStringConcatExpression(expr);
35304                 default:
35305                     return false;
35306             }
35307         }
35308         function getEnumKind(symbol) {
35309             var links = getSymbolLinks(symbol);
35310             if (links.enumKind !== undefined) {
35311                 return links.enumKind;
35312             }
35313             var hasNonLiteralMember = false;
35314             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
35315                 var declaration = _a[_i];
35316                 if (declaration.kind === 248) {
35317                     for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) {
35318                         var member = _c[_b];
35319                         if (member.initializer && ts.isStringLiteralLike(member.initializer)) {
35320                             return links.enumKind = 1;
35321                         }
35322                         if (!isLiteralEnumMember(member)) {
35323                             hasNonLiteralMember = true;
35324                         }
35325                     }
35326                 }
35327             }
35328             return links.enumKind = hasNonLiteralMember ? 0 : 1;
35329         }
35330         function getBaseTypeOfEnumLiteralType(type) {
35331             return type.flags & 1024 && !(type.flags & 1048576) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type;
35332         }
35333         function getDeclaredTypeOfEnum(symbol) {
35334             var links = getSymbolLinks(symbol);
35335             if (links.declaredType) {
35336                 return links.declaredType;
35337             }
35338             if (getEnumKind(symbol) === 1) {
35339                 enumCount++;
35340                 var memberTypeList = [];
35341                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
35342                     var declaration = _a[_i];
35343                     if (declaration.kind === 248) {
35344                         for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) {
35345                             var member = _c[_b];
35346                             var value = getEnumMemberValue(member);
35347                             var memberType = getFreshTypeOfLiteralType(getLiteralType(value !== undefined ? value : 0, enumCount, getSymbolOfNode(member)));
35348                             getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType;
35349                             memberTypeList.push(getRegularTypeOfLiteralType(memberType));
35350                         }
35351                     }
35352                 }
35353                 if (memberTypeList.length) {
35354                     var enumType_1 = getUnionType(memberTypeList, 1, symbol, undefined);
35355                     if (enumType_1.flags & 1048576) {
35356                         enumType_1.flags |= 1024;
35357                         enumType_1.symbol = symbol;
35358                     }
35359                     return links.declaredType = enumType_1;
35360                 }
35361             }
35362             var enumType = createType(32);
35363             enumType.symbol = symbol;
35364             return links.declaredType = enumType;
35365         }
35366         function getDeclaredTypeOfEnumMember(symbol) {
35367             var links = getSymbolLinks(symbol);
35368             if (!links.declaredType) {
35369                 var enumType = getDeclaredTypeOfEnum(getParentOfSymbol(symbol));
35370                 if (!links.declaredType) {
35371                     links.declaredType = enumType;
35372                 }
35373             }
35374             return links.declaredType;
35375         }
35376         function getDeclaredTypeOfTypeParameter(symbol) {
35377             var links = getSymbolLinks(symbol);
35378             return links.declaredType || (links.declaredType = createTypeParameter(symbol));
35379         }
35380         function getDeclaredTypeOfAlias(symbol) {
35381             var links = getSymbolLinks(symbol);
35382             return links.declaredType || (links.declaredType = getDeclaredTypeOfSymbol(resolveAlias(symbol)));
35383         }
35384         function getDeclaredTypeOfSymbol(symbol) {
35385             return tryGetDeclaredTypeOfSymbol(symbol) || errorType;
35386         }
35387         function tryGetDeclaredTypeOfSymbol(symbol) {
35388             if (symbol.flags & (32 | 64)) {
35389                 return getDeclaredTypeOfClassOrInterface(symbol);
35390             }
35391             if (symbol.flags & 524288) {
35392                 return getDeclaredTypeOfTypeAlias(symbol);
35393             }
35394             if (symbol.flags & 262144) {
35395                 return getDeclaredTypeOfTypeParameter(symbol);
35396             }
35397             if (symbol.flags & 384) {
35398                 return getDeclaredTypeOfEnum(symbol);
35399             }
35400             if (symbol.flags & 8) {
35401                 return getDeclaredTypeOfEnumMember(symbol);
35402             }
35403             if (symbol.flags & 2097152) {
35404                 return getDeclaredTypeOfAlias(symbol);
35405             }
35406             return undefined;
35407         }
35408         function isThislessType(node) {
35409             switch (node.kind) {
35410                 case 125:
35411                 case 148:
35412                 case 143:
35413                 case 140:
35414                 case 151:
35415                 case 128:
35416                 case 144:
35417                 case 141:
35418                 case 110:
35419                 case 146:
35420                 case 100:
35421                 case 137:
35422                 case 187:
35423                     return true;
35424                 case 174:
35425                     return isThislessType(node.elementType);
35426                 case 169:
35427                     return !node.typeArguments || node.typeArguments.every(isThislessType);
35428             }
35429             return false;
35430         }
35431         function isThislessTypeParameter(node) {
35432             var constraint = ts.getEffectiveConstraintOfTypeParameter(node);
35433             return !constraint || isThislessType(constraint);
35434         }
35435         function isThislessVariableLikeDeclaration(node) {
35436             var typeNode = ts.getEffectiveTypeAnnotationNode(node);
35437             return typeNode ? isThislessType(typeNode) : !ts.hasInitializer(node);
35438         }
35439         function isThislessFunctionLikeDeclaration(node) {
35440             var returnType = ts.getEffectiveReturnTypeNode(node);
35441             var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
35442             return (node.kind === 162 || (!!returnType && isThislessType(returnType))) &&
35443                 node.parameters.every(isThislessVariableLikeDeclaration) &&
35444                 typeParameters.every(isThislessTypeParameter);
35445         }
35446         function isThisless(symbol) {
35447             if (symbol.declarations && symbol.declarations.length === 1) {
35448                 var declaration = symbol.declarations[0];
35449                 if (declaration) {
35450                     switch (declaration.kind) {
35451                         case 159:
35452                         case 158:
35453                             return isThislessVariableLikeDeclaration(declaration);
35454                         case 161:
35455                         case 160:
35456                         case 162:
35457                         case 163:
35458                         case 164:
35459                             return isThislessFunctionLikeDeclaration(declaration);
35460                     }
35461                 }
35462             }
35463             return false;
35464         }
35465         function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) {
35466             var result = ts.createSymbolTable();
35467             for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
35468                 var symbol = symbols_2[_i];
35469                 result.set(symbol.escapedName, mappingThisOnly && isThisless(symbol) ? symbol : instantiateSymbol(symbol, mapper));
35470             }
35471             return result;
35472         }
35473         function addInheritedMembers(symbols, baseSymbols) {
35474             for (var _i = 0, baseSymbols_1 = baseSymbols; _i < baseSymbols_1.length; _i++) {
35475                 var s = baseSymbols_1[_i];
35476                 if (!symbols.has(s.escapedName) && !isStaticPrivateIdentifierProperty(s)) {
35477                     symbols.set(s.escapedName, s);
35478                 }
35479             }
35480         }
35481         function isStaticPrivateIdentifierProperty(s) {
35482             return !!s.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(s.valueDeclaration) && ts.hasModifier(s.valueDeclaration, 32);
35483         }
35484         function resolveDeclaredMembers(type) {
35485             if (!type.declaredProperties) {
35486                 var symbol = type.symbol;
35487                 var members = getMembersOfSymbol(symbol);
35488                 type.declaredProperties = getNamedMembers(members);
35489                 type.declaredCallSignatures = ts.emptyArray;
35490                 type.declaredConstructSignatures = ts.emptyArray;
35491                 type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call"));
35492                 type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new"));
35493                 type.declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, 0);
35494                 type.declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, 1);
35495             }
35496             return type;
35497         }
35498         function isTypeUsableAsPropertyName(type) {
35499             return !!(type.flags & 8576);
35500         }
35501         function isLateBindableName(node) {
35502             if (!ts.isComputedPropertyName(node) && !ts.isElementAccessExpression(node)) {
35503                 return false;
35504             }
35505             var expr = ts.isComputedPropertyName(node) ? node.expression : node.argumentExpression;
35506             return ts.isEntityNameExpression(expr)
35507                 && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr));
35508         }
35509         function isLateBoundName(name) {
35510             return name.charCodeAt(0) === 95 &&
35511                 name.charCodeAt(1) === 95 &&
35512                 name.charCodeAt(2) === 64;
35513         }
35514         function hasLateBindableName(node) {
35515             var name = ts.getNameOfDeclaration(node);
35516             return !!name && isLateBindableName(name);
35517         }
35518         function hasNonBindableDynamicName(node) {
35519             return ts.hasDynamicName(node) && !hasLateBindableName(node);
35520         }
35521         function isNonBindableDynamicName(node) {
35522             return ts.isDynamicName(node) && !isLateBindableName(node);
35523         }
35524         function getPropertyNameFromType(type) {
35525             if (type.flags & 8192) {
35526                 return type.escapedName;
35527             }
35528             if (type.flags & (128 | 256)) {
35529                 return ts.escapeLeadingUnderscores("" + type.value);
35530             }
35531             return ts.Debug.fail();
35532         }
35533         function addDeclarationToLateBoundSymbol(symbol, member, symbolFlags) {
35534             ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096), "Expected a late-bound symbol.");
35535             symbol.flags |= symbolFlags;
35536             getSymbolLinks(member.symbol).lateSymbol = symbol;
35537             if (!symbol.declarations) {
35538                 symbol.declarations = [member];
35539             }
35540             else {
35541                 symbol.declarations.push(member);
35542             }
35543             if (symbolFlags & 111551) {
35544                 if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) {
35545                     symbol.valueDeclaration = member;
35546                 }
35547             }
35548         }
35549         function lateBindMember(parent, earlySymbols, lateSymbols, decl) {
35550             ts.Debug.assert(!!decl.symbol, "The member is expected to have a symbol.");
35551             var links = getNodeLinks(decl);
35552             if (!links.resolvedSymbol) {
35553                 links.resolvedSymbol = decl.symbol;
35554                 var declName = ts.isBinaryExpression(decl) ? decl.left : decl.name;
35555                 var type = ts.isElementAccessExpression(declName) ? checkExpressionCached(declName.argumentExpression) : checkComputedPropertyName(declName);
35556                 if (isTypeUsableAsPropertyName(type)) {
35557                     var memberName = getPropertyNameFromType(type);
35558                     var symbolFlags = decl.symbol.flags;
35559                     var lateSymbol = lateSymbols.get(memberName);
35560                     if (!lateSymbol)
35561                         lateSymbols.set(memberName, lateSymbol = createSymbol(0, memberName, 4096));
35562                     var earlySymbol = earlySymbols && earlySymbols.get(memberName);
35563                     if (lateSymbol.flags & getExcludedSymbolFlags(symbolFlags) || earlySymbol) {
35564                         var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
35565                         var name_3 = !(type.flags & 8192) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName);
35566                         ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_3); });
35567                         error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_3);
35568                         lateSymbol = createSymbol(0, memberName, 4096);
35569                     }
35570                     lateSymbol.nameType = type;
35571                     addDeclarationToLateBoundSymbol(lateSymbol, decl, symbolFlags);
35572                     if (lateSymbol.parent) {
35573                         ts.Debug.assert(lateSymbol.parent === parent, "Existing symbol parent should match new one");
35574                     }
35575                     else {
35576                         lateSymbol.parent = parent;
35577                     }
35578                     return links.resolvedSymbol = lateSymbol;
35579                 }
35580             }
35581             return links.resolvedSymbol;
35582         }
35583         function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) {
35584             var links = getSymbolLinks(symbol);
35585             if (!links[resolutionKind]) {
35586                 var isStatic = resolutionKind === "resolvedExports";
35587                 var earlySymbols = !isStatic ? symbol.members :
35588                     symbol.flags & 1536 ? getExportsOfModuleWorker(symbol) :
35589                         symbol.exports;
35590                 links[resolutionKind] = earlySymbols || emptySymbols;
35591                 var lateSymbols = ts.createSymbolTable();
35592                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
35593                     var decl = _a[_i];
35594                     var members = ts.getMembersOfDeclaration(decl);
35595                     if (members) {
35596                         for (var _b = 0, members_5 = members; _b < members_5.length; _b++) {
35597                             var member = members_5[_b];
35598                             if (isStatic === ts.hasStaticModifier(member) && hasLateBindableName(member)) {
35599                                 lateBindMember(symbol, earlySymbols, lateSymbols, member);
35600                             }
35601                         }
35602                     }
35603                 }
35604                 var assignments = symbol.assignmentDeclarationMembers;
35605                 if (assignments) {
35606                     var decls = ts.arrayFrom(assignments.values());
35607                     for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) {
35608                         var member = decls_1[_c];
35609                         var assignmentKind = ts.getAssignmentDeclarationKind(member);
35610                         var isInstanceMember = assignmentKind === 3
35611                             || assignmentKind === 4
35612                             || assignmentKind === 9
35613                             || assignmentKind === 6;
35614                         if (isStatic === !isInstanceMember && hasLateBindableName(member)) {
35615                             lateBindMember(symbol, earlySymbols, lateSymbols, member);
35616                         }
35617                     }
35618                 }
35619                 links[resolutionKind] = combineSymbolTables(earlySymbols, lateSymbols) || emptySymbols;
35620             }
35621             return links[resolutionKind];
35622         }
35623         function getMembersOfSymbol(symbol) {
35624             return symbol.flags & 6256
35625                 ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers")
35626                 : symbol.members || emptySymbols;
35627         }
35628         function getLateBoundSymbol(symbol) {
35629             if (symbol.flags & 106500 && symbol.escapedName === "__computed") {
35630                 var links = getSymbolLinks(symbol);
35631                 if (!links.lateSymbol && ts.some(symbol.declarations, hasLateBindableName)) {
35632                     var parent = getMergedSymbol(symbol.parent);
35633                     if (ts.some(symbol.declarations, ts.hasStaticModifier)) {
35634                         getExportsOfSymbol(parent);
35635                     }
35636                     else {
35637                         getMembersOfSymbol(parent);
35638                     }
35639                 }
35640                 return links.lateSymbol || (links.lateSymbol = symbol);
35641             }
35642             return symbol;
35643         }
35644         function getTypeWithThisArgument(type, thisArgument, needApparentType) {
35645             if (ts.getObjectFlags(type) & 4) {
35646                 var target = type.target;
35647                 var typeArguments = getTypeArguments(type);
35648                 if (ts.length(target.typeParameters) === ts.length(typeArguments)) {
35649                     var ref = createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType]));
35650                     return needApparentType ? getApparentType(ref) : ref;
35651                 }
35652             }
35653             else if (type.flags & 2097152) {
35654                 return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); }));
35655             }
35656             return needApparentType ? getApparentType(type) : type;
35657         }
35658         function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) {
35659             var mapper;
35660             var members;
35661             var callSignatures;
35662             var constructSignatures;
35663             var stringIndexInfo;
35664             var numberIndexInfo;
35665             if (ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) {
35666                 members = source.symbol ? getMembersOfSymbol(source.symbol) : ts.createSymbolTable(source.declaredProperties);
35667                 callSignatures = source.declaredCallSignatures;
35668                 constructSignatures = source.declaredConstructSignatures;
35669                 stringIndexInfo = source.declaredStringIndexInfo;
35670                 numberIndexInfo = source.declaredNumberIndexInfo;
35671             }
35672             else {
35673                 mapper = createTypeMapper(typeParameters, typeArguments);
35674                 members = createInstantiatedSymbolTable(source.declaredProperties, mapper, typeParameters.length === 1);
35675                 callSignatures = instantiateSignatures(source.declaredCallSignatures, mapper);
35676                 constructSignatures = instantiateSignatures(source.declaredConstructSignatures, mapper);
35677                 stringIndexInfo = instantiateIndexInfo(source.declaredStringIndexInfo, mapper);
35678                 numberIndexInfo = instantiateIndexInfo(source.declaredNumberIndexInfo, mapper);
35679             }
35680             var baseTypes = getBaseTypes(source);
35681             if (baseTypes.length) {
35682                 if (source.symbol && members === getMembersOfSymbol(source.symbol)) {
35683                     members = ts.createSymbolTable(source.declaredProperties);
35684                 }
35685                 setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
35686                 var thisArgument = ts.lastOrUndefined(typeArguments);
35687                 for (var _i = 0, baseTypes_1 = baseTypes; _i < baseTypes_1.length; _i++) {
35688                     var baseType = baseTypes_1[_i];
35689                     var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType;
35690                     addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType));
35691                     callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0));
35692                     constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1));
35693                     if (!stringIndexInfo) {
35694                         stringIndexInfo = instantiatedBaseType === anyType ?
35695                             createIndexInfo(anyType, false) :
35696                             getIndexInfoOfType(instantiatedBaseType, 0);
35697                     }
35698                     numberIndexInfo = numberIndexInfo || getIndexInfoOfType(instantiatedBaseType, 1);
35699                 }
35700             }
35701             setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
35702         }
35703         function resolveClassOrInterfaceMembers(type) {
35704             resolveObjectTypeMembers(type, resolveDeclaredMembers(type), ts.emptyArray, ts.emptyArray);
35705         }
35706         function resolveTypeReferenceMembers(type) {
35707             var source = resolveDeclaredMembers(type.target);
35708             var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]);
35709             var typeArguments = getTypeArguments(type);
35710             var paddedTypeArguments = typeArguments.length === typeParameters.length ? typeArguments : ts.concatenate(typeArguments, [type]);
35711             resolveObjectTypeMembers(type, source, typeParameters, paddedTypeArguments);
35712         }
35713         function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, resolvedTypePredicate, minArgumentCount, flags) {
35714             var sig = new Signature(checker, flags);
35715             sig.declaration = declaration;
35716             sig.typeParameters = typeParameters;
35717             sig.parameters = parameters;
35718             sig.thisParameter = thisParameter;
35719             sig.resolvedReturnType = resolvedReturnType;
35720             sig.resolvedTypePredicate = resolvedTypePredicate;
35721             sig.minArgumentCount = minArgumentCount;
35722             sig.target = undefined;
35723             sig.mapper = undefined;
35724             sig.unionSignatures = undefined;
35725             return sig;
35726         }
35727         function cloneSignature(sig) {
35728             var result = createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, undefined, undefined, sig.minArgumentCount, sig.flags & 3);
35729             result.target = sig.target;
35730             result.mapper = sig.mapper;
35731             result.unionSignatures = sig.unionSignatures;
35732             return result;
35733         }
35734         function createUnionSignature(signature, unionSignatures) {
35735             var result = cloneSignature(signature);
35736             result.unionSignatures = unionSignatures;
35737             result.target = undefined;
35738             result.mapper = undefined;
35739             return result;
35740         }
35741         function getOptionalCallSignature(signature, callChainFlags) {
35742             if ((signature.flags & 12) === callChainFlags) {
35743                 return signature;
35744             }
35745             if (!signature.optionalCallSignatureCache) {
35746                 signature.optionalCallSignatureCache = {};
35747             }
35748             var key = callChainFlags === 4 ? "inner" : "outer";
35749             return signature.optionalCallSignatureCache[key]
35750                 || (signature.optionalCallSignatureCache[key] = createOptionalCallSignature(signature, callChainFlags));
35751         }
35752         function createOptionalCallSignature(signature, callChainFlags) {
35753             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.");
35754             var result = cloneSignature(signature);
35755             result.flags |= callChainFlags;
35756             return result;
35757         }
35758         function getExpandedParameters(sig) {
35759             if (signatureHasRestParameter(sig)) {
35760                 var restIndex_1 = sig.parameters.length - 1;
35761                 var restParameter = sig.parameters[restIndex_1];
35762                 var restType = getTypeOfSymbol(restParameter);
35763                 if (isTupleType(restType)) {
35764                     var elementTypes = getTypeArguments(restType);
35765                     var minLength_1 = restType.target.minLength;
35766                     var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1;
35767                     var restParams = ts.map(elementTypes, function (t, i) {
35768                         var name = getParameterNameAtPosition(sig, restIndex_1 + i);
35769                         var checkFlags = i === tupleRestIndex_1 ? 32768 :
35770                             i >= minLength_1 ? 16384 : 0;
35771                         var symbol = createSymbol(1, name, checkFlags);
35772                         symbol.type = i === tupleRestIndex_1 ? createArrayType(t) : t;
35773                         return symbol;
35774                     });
35775                     return ts.concatenate(sig.parameters.slice(0, restIndex_1), restParams);
35776                 }
35777             }
35778             return sig.parameters;
35779         }
35780         function getDefaultConstructSignatures(classType) {
35781             var baseConstructorType = getBaseConstructorTypeOfClass(classType);
35782             var baseSignatures = getSignaturesOfType(baseConstructorType, 1);
35783             if (baseSignatures.length === 0) {
35784                 return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, undefined, 0, 0)];
35785             }
35786             var baseTypeNode = getBaseTypeNodeOfClass(classType);
35787             var isJavaScript = ts.isInJSFile(baseTypeNode);
35788             var typeArguments = typeArgumentsFromTypeReferenceNode(baseTypeNode);
35789             var typeArgCount = ts.length(typeArguments);
35790             var result = [];
35791             for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) {
35792                 var baseSig = baseSignatures_1[_i];
35793                 var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters);
35794                 var typeParamCount = ts.length(baseSig.typeParameters);
35795                 if (isJavaScript || typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) {
35796                     var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript)) : cloneSignature(baseSig);
35797                     sig.typeParameters = classType.localTypeParameters;
35798                     sig.resolvedReturnType = classType;
35799                     result.push(sig);
35800                 }
35801             }
35802             return result;
35803         }
35804         function findMatchingSignature(signatureList, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes) {
35805             for (var _i = 0, signatureList_1 = signatureList; _i < signatureList_1.length; _i++) {
35806                 var s = signatureList_1[_i];
35807                 if (compareSignaturesIdentical(s, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes, partialMatch ? compareTypesSubtypeOf : compareTypesIdentical)) {
35808                     return s;
35809                 }
35810             }
35811         }
35812         function findMatchingSignatures(signatureLists, signature, listIndex) {
35813             if (signature.typeParameters) {
35814                 if (listIndex > 0) {
35815                     return undefined;
35816                 }
35817                 for (var i = 1; i < signatureLists.length; i++) {
35818                     if (!findMatchingSignature(signatureLists[i], signature, false, false, false)) {
35819                         return undefined;
35820                     }
35821                 }
35822                 return [signature];
35823             }
35824             var result;
35825             for (var i = 0; i < signatureLists.length; i++) {
35826                 var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, true, false, true);
35827                 if (!match) {
35828                     return undefined;
35829                 }
35830                 result = ts.appendIfUnique(result, match);
35831             }
35832             return result;
35833         }
35834         function getUnionSignatures(signatureLists) {
35835             var result;
35836             var indexWithLengthOverOne;
35837             for (var i = 0; i < signatureLists.length; i++) {
35838                 if (signatureLists[i].length === 0)
35839                     return ts.emptyArray;
35840                 if (signatureLists[i].length > 1) {
35841                     indexWithLengthOverOne = indexWithLengthOverOne === undefined ? i : -1;
35842                 }
35843                 for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) {
35844                     var signature = _a[_i];
35845                     if (!result || !findMatchingSignature(result, signature, false, false, true)) {
35846                         var unionSignatures = findMatchingSignatures(signatureLists, signature, i);
35847                         if (unionSignatures) {
35848                             var s = signature;
35849                             if (unionSignatures.length > 1) {
35850                                 var thisParameter = signature.thisParameter;
35851                                 var firstThisParameterOfUnionSignatures = ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; });
35852                                 if (firstThisParameterOfUnionSignatures) {
35853                                     var thisType = getIntersectionType(ts.mapDefined(unionSignatures, function (sig) { return sig.thisParameter && getTypeOfSymbol(sig.thisParameter); }));
35854                                     thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType);
35855                                 }
35856                                 s = createUnionSignature(signature, unionSignatures);
35857                                 s.thisParameter = thisParameter;
35858                             }
35859                             (result || (result = [])).push(s);
35860                         }
35861                     }
35862                 }
35863             }
35864             if (!ts.length(result) && indexWithLengthOverOne !== -1) {
35865                 var masterList = signatureLists[indexWithLengthOverOne !== undefined ? indexWithLengthOverOne : 0];
35866                 var results = masterList.slice();
35867                 var _loop_9 = function (signatures) {
35868                     if (signatures !== masterList) {
35869                         var signature_1 = signatures[0];
35870                         ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass");
35871                         results = signature_1.typeParameters && ts.some(results, function (s) { return !!s.typeParameters; }) ? undefined : ts.map(results, function (sig) { return combineSignaturesOfUnionMembers(sig, signature_1); });
35872                         if (!results) {
35873                             return "break";
35874                         }
35875                     }
35876                 };
35877                 for (var _b = 0, signatureLists_1 = signatureLists; _b < signatureLists_1.length; _b++) {
35878                     var signatures = signatureLists_1[_b];
35879                     var state_3 = _loop_9(signatures);
35880                     if (state_3 === "break")
35881                         break;
35882                 }
35883                 result = results;
35884             }
35885             return result || ts.emptyArray;
35886         }
35887         function combineUnionThisParam(left, right) {
35888             if (!left || !right) {
35889                 return left || right;
35890             }
35891             var thisType = getIntersectionType([getTypeOfSymbol(left), getTypeOfSymbol(right)]);
35892             return createSymbolWithType(left, thisType);
35893         }
35894         function combineUnionParameters(left, right) {
35895             var leftCount = getParameterCount(left);
35896             var rightCount = getParameterCount(right);
35897             var longest = leftCount >= rightCount ? left : right;
35898             var shorter = longest === left ? right : left;
35899             var longestCount = longest === left ? leftCount : rightCount;
35900             var eitherHasEffectiveRest = (hasEffectiveRestParameter(left) || hasEffectiveRestParameter(right));
35901             var needsExtraRestElement = eitherHasEffectiveRest && !hasEffectiveRestParameter(longest);
35902             var params = new Array(longestCount + (needsExtraRestElement ? 1 : 0));
35903             for (var i = 0; i < longestCount; i++) {
35904                 var longestParamType = tryGetTypeAtPosition(longest, i);
35905                 var shorterParamType = tryGetTypeAtPosition(shorter, i) || unknownType;
35906                 var unionParamType = getIntersectionType([longestParamType, shorterParamType]);
35907                 var isRestParam = eitherHasEffectiveRest && !needsExtraRestElement && i === (longestCount - 1);
35908                 var isOptional = i >= getMinArgumentCount(longest) && i >= getMinArgumentCount(shorter);
35909                 var leftName = i >= leftCount ? undefined : getParameterNameAtPosition(left, i);
35910                 var rightName = i >= rightCount ? undefined : getParameterNameAtPosition(right, i);
35911                 var paramName = leftName === rightName ? leftName :
35912                     !leftName ? rightName :
35913                         !rightName ? leftName :
35914                             undefined;
35915                 var paramSymbol = createSymbol(1 | (isOptional && !isRestParam ? 16777216 : 0), paramName || "arg" + i);
35916                 paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType;
35917                 params[i] = paramSymbol;
35918             }
35919             if (needsExtraRestElement) {
35920                 var restParamSymbol = createSymbol(1, "args");
35921                 restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount));
35922                 params[longestCount] = restParamSymbol;
35923             }
35924             return params;
35925         }
35926         function combineSignaturesOfUnionMembers(left, right) {
35927             var declaration = left.declaration;
35928             var params = combineUnionParameters(left, right);
35929             var thisParam = combineUnionThisParam(left.thisParameter, right.thisParameter);
35930             var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount);
35931             var result = createSignature(declaration, left.typeParameters || right.typeParameters, thisParam, params, undefined, undefined, minArgCount, (left.flags | right.flags) & 3);
35932             result.unionSignatures = ts.concatenate(left.unionSignatures || [left], [right]);
35933             return result;
35934         }
35935         function getUnionIndexInfo(types, kind) {
35936             var indexTypes = [];
35937             var isAnyReadonly = false;
35938             for (var _i = 0, types_3 = types; _i < types_3.length; _i++) {
35939                 var type = types_3[_i];
35940                 var indexInfo = getIndexInfoOfType(getApparentType(type), kind);
35941                 if (!indexInfo) {
35942                     return undefined;
35943                 }
35944                 indexTypes.push(indexInfo.type);
35945                 isAnyReadonly = isAnyReadonly || indexInfo.isReadonly;
35946             }
35947             return createIndexInfo(getUnionType(indexTypes, 2), isAnyReadonly);
35948         }
35949         function resolveUnionTypeMembers(type) {
35950             var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0); }));
35951             var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1); }));
35952             var stringIndexInfo = getUnionIndexInfo(type.types, 0);
35953             var numberIndexInfo = getUnionIndexInfo(type.types, 1);
35954             setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
35955         }
35956         function intersectTypes(type1, type2) {
35957             return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]);
35958         }
35959         function intersectIndexInfos(info1, info2) {
35960             return !info1 ? info2 : !info2 ? info1 : createIndexInfo(getIntersectionType([info1.type, info2.type]), info1.isReadonly && info2.isReadonly);
35961         }
35962         function unionSpreadIndexInfos(info1, info2) {
35963             return info1 && info2 && createIndexInfo(getUnionType([info1.type, info2.type]), info1.isReadonly || info2.isReadonly);
35964         }
35965         function findMixins(types) {
35966             var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1).length > 0; });
35967             var mixinFlags = ts.map(types, isMixinConstructorType);
35968             if (constructorTypeCount > 0 && constructorTypeCount === ts.countWhere(mixinFlags, function (b) { return b; })) {
35969                 var firstMixinIndex = mixinFlags.indexOf(true);
35970                 mixinFlags[firstMixinIndex] = false;
35971             }
35972             return mixinFlags;
35973         }
35974         function includeMixinType(type, types, mixinFlags, index) {
35975             var mixedTypes = [];
35976             for (var i = 0; i < types.length; i++) {
35977                 if (i === index) {
35978                     mixedTypes.push(type);
35979                 }
35980                 else if (mixinFlags[i]) {
35981                     mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1)[0]));
35982                 }
35983             }
35984             return getIntersectionType(mixedTypes);
35985         }
35986         function resolveIntersectionTypeMembers(type) {
35987             var callSignatures;
35988             var constructSignatures;
35989             var stringIndexInfo;
35990             var numberIndexInfo;
35991             var types = type.types;
35992             var mixinFlags = findMixins(types);
35993             var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; });
35994             var _loop_10 = function (i) {
35995                 var t = type.types[i];
35996                 if (!mixinFlags[i]) {
35997                     var signatures = getSignaturesOfType(t, 1);
35998                     if (signatures.length && mixinCount > 0) {
35999                         signatures = ts.map(signatures, function (s) {
36000                             var clone = cloneSignature(s);
36001                             clone.resolvedReturnType = includeMixinType(getReturnTypeOfSignature(s), types, mixinFlags, i);
36002                             return clone;
36003                         });
36004                     }
36005                     constructSignatures = appendSignatures(constructSignatures, signatures);
36006                 }
36007                 callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0));
36008                 stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0));
36009                 numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1));
36010             };
36011             for (var i = 0; i < types.length; i++) {
36012                 _loop_10(i);
36013             }
36014             setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo);
36015         }
36016         function appendSignatures(signatures, newSignatures) {
36017             var _loop_11 = function (sig) {
36018                 if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, false, false, false, compareTypesIdentical); })) {
36019                     signatures = ts.append(signatures, sig);
36020                 }
36021             };
36022             for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) {
36023                 var sig = newSignatures_1[_i];
36024                 _loop_11(sig);
36025             }
36026             return signatures;
36027         }
36028         function resolveAnonymousTypeMembers(type) {
36029             var symbol = getMergedSymbol(type.symbol);
36030             if (type.target) {
36031                 setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
36032                 var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false);
36033                 var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0), type.mapper);
36034                 var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1), type.mapper);
36035                 var stringIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 0), type.mapper);
36036                 var numberIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 1), type.mapper);
36037                 setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
36038             }
36039             else if (symbol.flags & 2048) {
36040                 setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
36041                 var members = getMembersOfSymbol(symbol);
36042                 var callSignatures = getSignaturesOfSymbol(members.get("__call"));
36043                 var constructSignatures = getSignaturesOfSymbol(members.get("__new"));
36044                 var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0);
36045                 var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1);
36046                 setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
36047             }
36048             else {
36049                 var members = emptySymbols;
36050                 var stringIndexInfo = void 0;
36051                 if (symbol.exports) {
36052                     members = getExportsOfSymbol(symbol);
36053                     if (symbol === globalThisSymbol) {
36054                         var varsOnly_1 = ts.createMap();
36055                         members.forEach(function (p) {
36056                             if (!(p.flags & 418)) {
36057                                 varsOnly_1.set(p.escapedName, p);
36058                             }
36059                         });
36060                         members = varsOnly_1;
36061                     }
36062                 }
36063                 setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, undefined, undefined);
36064                 if (symbol.flags & 32) {
36065                     var classType = getDeclaredTypeOfClassOrInterface(symbol);
36066                     var baseConstructorType = getBaseConstructorTypeOfClass(classType);
36067                     if (baseConstructorType.flags & (524288 | 2097152 | 8650752)) {
36068                         members = ts.createSymbolTable(getNamedMembers(members));
36069                         addInheritedMembers(members, getPropertiesOfType(baseConstructorType));
36070                     }
36071                     else if (baseConstructorType === anyType) {
36072                         stringIndexInfo = createIndexInfo(anyType, false);
36073                     }
36074                 }
36075                 var numberIndexInfo = symbol.flags & 384 && (getDeclaredTypeOfSymbol(symbol).flags & 32 ||
36076                     ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296); })) ? enumNumberIndexInfo : undefined;
36077                 setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo);
36078                 if (symbol.flags & (16 | 8192)) {
36079                     type.callSignatures = getSignaturesOfSymbol(symbol);
36080                 }
36081                 if (symbol.flags & 32) {
36082                     var classType_1 = getDeclaredTypeOfClassOrInterface(symbol);
36083                     var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor")) : ts.emptyArray;
36084                     if (symbol.flags & 16) {
36085                         constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ?
36086                             createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, undefined, sig.minArgumentCount, sig.flags & 3) :
36087                             undefined; }));
36088                     }
36089                     if (!constructSignatures.length) {
36090                         constructSignatures = getDefaultConstructSignatures(classType_1);
36091                     }
36092                     type.constructSignatures = constructSignatures;
36093                 }
36094             }
36095         }
36096         function resolveReverseMappedTypeMembers(type) {
36097             var indexInfo = getIndexInfoOfType(type.source, 0);
36098             var modifiers = getMappedTypeModifiers(type.mappedType);
36099             var readonlyMask = modifiers & 1 ? false : true;
36100             var optionalMask = modifiers & 4 ? 0 : 16777216;
36101             var stringIndexInfo = indexInfo && createIndexInfo(inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly);
36102             var members = ts.createSymbolTable();
36103             for (var _i = 0, _a = getPropertiesOfType(type.source); _i < _a.length; _i++) {
36104                 var prop = _a[_i];
36105                 var checkFlags = 8192 | (readonlyMask && isReadonlySymbol(prop) ? 8 : 0);
36106                 var inferredProp = createSymbol(4 | prop.flags & optionalMask, prop.escapedName, checkFlags);
36107                 inferredProp.declarations = prop.declarations;
36108                 inferredProp.nameType = getSymbolLinks(prop).nameType;
36109                 inferredProp.propertyType = getTypeOfSymbol(prop);
36110                 inferredProp.mappedType = type.mappedType;
36111                 inferredProp.constraintType = type.constraintType;
36112                 members.set(prop.escapedName, inferredProp);
36113             }
36114             setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined);
36115         }
36116         function getLowerBoundOfKeyType(type) {
36117             if (type.flags & (1 | 131068)) {
36118                 return type;
36119             }
36120             if (type.flags & 4194304) {
36121                 return getIndexType(getApparentType(type.type));
36122             }
36123             if (type.flags & 16777216) {
36124                 if (type.root.isDistributive) {
36125                     var checkType = type.checkType;
36126                     var constraint = getLowerBoundOfKeyType(checkType);
36127                     if (constraint !== checkType) {
36128                         return getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
36129                     }
36130                 }
36131                 return type;
36132             }
36133             if (type.flags & 1048576) {
36134                 return getUnionType(ts.sameMap(type.types, getLowerBoundOfKeyType));
36135             }
36136             if (type.flags & 2097152) {
36137                 return getIntersectionType(ts.sameMap(type.types, getLowerBoundOfKeyType));
36138             }
36139             return neverType;
36140         }
36141         function resolveMappedTypeMembers(type) {
36142             var members = ts.createSymbolTable();
36143             var stringIndexInfo;
36144             var numberIndexInfo;
36145             setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
36146             var typeParameter = getTypeParameterFromMappedType(type);
36147             var constraintType = getConstraintTypeFromMappedType(type);
36148             var templateType = getTemplateTypeFromMappedType(type.target || type);
36149             var modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
36150             var templateModifiers = getMappedTypeModifiers(type);
36151             var include = keyofStringsOnly ? 128 : 8576;
36152             if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
36153                 for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) {
36154                     var prop = _a[_i];
36155                     addMemberForKeyType(getLiteralTypeFromProperty(prop, include));
36156                 }
36157                 if (modifiersType.flags & 1 || getIndexInfoOfType(modifiersType, 0)) {
36158                     addMemberForKeyType(stringType);
36159                 }
36160                 if (!keyofStringsOnly && getIndexInfoOfType(modifiersType, 1)) {
36161                     addMemberForKeyType(numberType);
36162                 }
36163             }
36164             else {
36165                 forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
36166             }
36167             setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo);
36168             function addMemberForKeyType(t) {
36169                 var templateMapper = appendTypeMapping(type.mapper, typeParameter, t);
36170                 if (isTypeUsableAsPropertyName(t)) {
36171                     var propName = getPropertyNameFromType(t);
36172                     var modifiersProp = getPropertyOfType(modifiersType, propName);
36173                     var isOptional = !!(templateModifiers & 4 ||
36174                         !(templateModifiers & 8) && modifiersProp && modifiersProp.flags & 16777216);
36175                     var isReadonly = !!(templateModifiers & 1 ||
36176                         !(templateModifiers & 2) && modifiersProp && isReadonlySymbol(modifiersProp));
36177                     var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216;
36178                     var prop = createSymbol(4 | (isOptional ? 16777216 : 0), propName, 262144 | (isReadonly ? 8 : 0) | (stripOptional ? 524288 : 0));
36179                     prop.mappedType = type;
36180                     prop.mapper = templateMapper;
36181                     if (modifiersProp) {
36182                         prop.syntheticOrigin = modifiersProp;
36183                         prop.declarations = modifiersProp.declarations;
36184                     }
36185                     prop.nameType = t;
36186                     members.set(propName, prop);
36187                 }
36188                 else if (t.flags & (1 | 4 | 8 | 32)) {
36189                     var propType = instantiateType(templateType, templateMapper);
36190                     if (t.flags & (1 | 4)) {
36191                         stringIndexInfo = createIndexInfo(propType, !!(templateModifiers & 1));
36192                     }
36193                     else {
36194                         numberIndexInfo = createIndexInfo(numberIndexInfo ? getUnionType([numberIndexInfo.type, propType]) : propType, !!(templateModifiers & 1));
36195                     }
36196                 }
36197             }
36198         }
36199         function getTypeOfMappedSymbol(symbol) {
36200             if (!symbol.type) {
36201                 if (!pushTypeResolution(symbol, 0)) {
36202                     return errorType;
36203                 }
36204                 var templateType = getTemplateTypeFromMappedType(symbol.mappedType.target || symbol.mappedType);
36205                 var propType = instantiateType(templateType, symbol.mapper);
36206                 var type = strictNullChecks && symbol.flags & 16777216 && !maybeTypeOfKind(propType, 32768 | 16384) ? getOptionalType(propType) :
36207                     symbol.checkFlags & 524288 ? getTypeWithFacts(propType, 524288) :
36208                         propType;
36209                 if (!popTypeResolution()) {
36210                     error(currentNode, ts.Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(symbol.mappedType));
36211                     type = errorType;
36212                 }
36213                 symbol.type = type;
36214                 symbol.mapper = undefined;
36215             }
36216             return symbol.type;
36217         }
36218         function getTypeParameterFromMappedType(type) {
36219             return type.typeParameter ||
36220                 (type.typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(type.declaration.typeParameter)));
36221         }
36222         function getConstraintTypeFromMappedType(type) {
36223             return type.constraintType ||
36224                 (type.constraintType = getConstraintOfTypeParameter(getTypeParameterFromMappedType(type)) || errorType);
36225         }
36226         function getTemplateTypeFromMappedType(type) {
36227             return type.templateType ||
36228                 (type.templateType = type.declaration.type ?
36229                     instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!(getMappedTypeModifiers(type) & 4)), type.mapper) :
36230                     errorType);
36231         }
36232         function getConstraintDeclarationForMappedType(type) {
36233             return ts.getEffectiveConstraintOfTypeParameter(type.declaration.typeParameter);
36234         }
36235         function isMappedTypeWithKeyofConstraintDeclaration(type) {
36236             var constraintDeclaration = getConstraintDeclarationForMappedType(type);
36237             return constraintDeclaration.kind === 184 &&
36238                 constraintDeclaration.operator === 134;
36239         }
36240         function getModifiersTypeFromMappedType(type) {
36241             if (!type.modifiersType) {
36242                 if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
36243                     type.modifiersType = instantiateType(getTypeFromTypeNode(getConstraintDeclarationForMappedType(type).type), type.mapper);
36244                 }
36245                 else {
36246                     var declaredType = getTypeFromMappedTypeNode(type.declaration);
36247                     var constraint = getConstraintTypeFromMappedType(declaredType);
36248                     var extendedConstraint = constraint && constraint.flags & 262144 ? getConstraintOfTypeParameter(constraint) : constraint;
36249                     type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 ? instantiateType(extendedConstraint.type, type.mapper) : unknownType;
36250                 }
36251             }
36252             return type.modifiersType;
36253         }
36254         function getMappedTypeModifiers(type) {
36255             var declaration = type.declaration;
36256             return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 ? 2 : 1 : 0) |
36257                 (declaration.questionToken ? declaration.questionToken.kind === 40 ? 8 : 4 : 0);
36258         }
36259         function getMappedTypeOptionality(type) {
36260             var modifiers = getMappedTypeModifiers(type);
36261             return modifiers & 8 ? -1 : modifiers & 4 ? 1 : 0;
36262         }
36263         function getCombinedMappedTypeOptionality(type) {
36264             var optionality = getMappedTypeOptionality(type);
36265             var modifiersType = getModifiersTypeFromMappedType(type);
36266             return optionality || (isGenericMappedType(modifiersType) ? getMappedTypeOptionality(modifiersType) : 0);
36267         }
36268         function isPartialMappedType(type) {
36269             return !!(ts.getObjectFlags(type) & 32 && getMappedTypeModifiers(type) & 4);
36270         }
36271         function isGenericMappedType(type) {
36272             return !!(ts.getObjectFlags(type) & 32) && isGenericIndexType(getConstraintTypeFromMappedType(type));
36273         }
36274         function resolveStructuredTypeMembers(type) {
36275             if (!type.members) {
36276                 if (type.flags & 524288) {
36277                     if (type.objectFlags & 4) {
36278                         resolveTypeReferenceMembers(type);
36279                     }
36280                     else if (type.objectFlags & 3) {
36281                         resolveClassOrInterfaceMembers(type);
36282                     }
36283                     else if (type.objectFlags & 2048) {
36284                         resolveReverseMappedTypeMembers(type);
36285                     }
36286                     else if (type.objectFlags & 16) {
36287                         resolveAnonymousTypeMembers(type);
36288                     }
36289                     else if (type.objectFlags & 32) {
36290                         resolveMappedTypeMembers(type);
36291                     }
36292                 }
36293                 else if (type.flags & 1048576) {
36294                     resolveUnionTypeMembers(type);
36295                 }
36296                 else if (type.flags & 2097152) {
36297                     resolveIntersectionTypeMembers(type);
36298                 }
36299             }
36300             return type;
36301         }
36302         function getPropertiesOfObjectType(type) {
36303             if (type.flags & 524288) {
36304                 return resolveStructuredTypeMembers(type).properties;
36305             }
36306             return ts.emptyArray;
36307         }
36308         function getPropertyOfObjectType(type, name) {
36309             if (type.flags & 524288) {
36310                 var resolved = resolveStructuredTypeMembers(type);
36311                 var symbol = resolved.members.get(name);
36312                 if (symbol && symbolIsValue(symbol)) {
36313                     return symbol;
36314                 }
36315             }
36316         }
36317         function getPropertiesOfUnionOrIntersectionType(type) {
36318             if (!type.resolvedProperties) {
36319                 var members = ts.createSymbolTable();
36320                 for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
36321                     var current = _a[_i];
36322                     for (var _b = 0, _c = getPropertiesOfType(current); _b < _c.length; _b++) {
36323                         var prop = _c[_b];
36324                         if (!members.has(prop.escapedName)) {
36325                             var combinedProp = getPropertyOfUnionOrIntersectionType(type, prop.escapedName);
36326                             if (combinedProp) {
36327                                 members.set(prop.escapedName, combinedProp);
36328                             }
36329                         }
36330                     }
36331                     if (type.flags & 1048576 && !getIndexInfoOfType(current, 0) && !getIndexInfoOfType(current, 1)) {
36332                         break;
36333                     }
36334                 }
36335                 type.resolvedProperties = getNamedMembers(members);
36336             }
36337             return type.resolvedProperties;
36338         }
36339         function getPropertiesOfType(type) {
36340             type = getReducedApparentType(type);
36341             return type.flags & 3145728 ?
36342                 getPropertiesOfUnionOrIntersectionType(type) :
36343                 getPropertiesOfObjectType(type);
36344         }
36345         function isTypeInvalidDueToUnionDiscriminant(contextualType, obj) {
36346             var list = obj.properties;
36347             return list.some(function (property) {
36348                 var nameType = property.name && getLiteralTypeFromPropertyName(property.name);
36349                 var name = nameType && isTypeUsableAsPropertyName(nameType) ? getPropertyNameFromType(nameType) : undefined;
36350                 var expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name);
36351                 return !!expected && isLiteralType(expected) && !isTypeAssignableTo(getTypeOfNode(property), expected);
36352             });
36353         }
36354         function getAllPossiblePropertiesOfTypes(types) {
36355             var unionType = getUnionType(types);
36356             if (!(unionType.flags & 1048576)) {
36357                 return getAugmentedPropertiesOfType(unionType);
36358             }
36359             var props = ts.createSymbolTable();
36360             for (var _i = 0, types_4 = types; _i < types_4.length; _i++) {
36361                 var memberType = types_4[_i];
36362                 for (var _a = 0, _b = getAugmentedPropertiesOfType(memberType); _a < _b.length; _a++) {
36363                     var escapedName = _b[_a].escapedName;
36364                     if (!props.has(escapedName)) {
36365                         var prop = createUnionOrIntersectionProperty(unionType, escapedName);
36366                         if (prop)
36367                             props.set(escapedName, prop);
36368                     }
36369                 }
36370             }
36371             return ts.arrayFrom(props.values());
36372         }
36373         function getConstraintOfType(type) {
36374             return type.flags & 262144 ? getConstraintOfTypeParameter(type) :
36375                 type.flags & 8388608 ? getConstraintOfIndexedAccess(type) :
36376                     type.flags & 16777216 ? getConstraintOfConditionalType(type) :
36377                         getBaseConstraintOfType(type);
36378         }
36379         function getConstraintOfTypeParameter(typeParameter) {
36380             return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined;
36381         }
36382         function getConstraintOfIndexedAccess(type) {
36383             return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : undefined;
36384         }
36385         function getSimplifiedTypeOrConstraint(type) {
36386             var simplified = getSimplifiedType(type, false);
36387             return simplified !== type ? simplified : getConstraintOfType(type);
36388         }
36389         function getConstraintFromIndexedAccess(type) {
36390             var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType);
36391             if (indexConstraint && indexConstraint !== type.indexType) {
36392                 var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint);
36393                 if (indexedAccess) {
36394                     return indexedAccess;
36395                 }
36396             }
36397             var objectConstraint = getSimplifiedTypeOrConstraint(type.objectType);
36398             if (objectConstraint && objectConstraint !== type.objectType) {
36399                 return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType);
36400             }
36401             return undefined;
36402         }
36403         function getDefaultConstraintOfConditionalType(type) {
36404             if (!type.resolvedDefaultConstraint) {
36405                 var trueConstraint = getInferredTrueTypeFromConditionalType(type);
36406                 var falseConstraint = getFalseTypeFromConditionalType(type);
36407                 type.resolvedDefaultConstraint = isTypeAny(trueConstraint) ? falseConstraint : isTypeAny(falseConstraint) ? trueConstraint : getUnionType([trueConstraint, falseConstraint]);
36408             }
36409             return type.resolvedDefaultConstraint;
36410         }
36411         function getConstraintOfDistributiveConditionalType(type) {
36412             if (type.root.isDistributive && type.restrictiveInstantiation !== type) {
36413                 var simplified = getSimplifiedType(type.checkType, false);
36414                 var constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified;
36415                 if (constraint && constraint !== type.checkType) {
36416                     var instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
36417                     if (!(instantiated.flags & 131072)) {
36418                         return instantiated;
36419                     }
36420                 }
36421             }
36422             return undefined;
36423         }
36424         function getConstraintFromConditionalType(type) {
36425             return getConstraintOfDistributiveConditionalType(type) || getDefaultConstraintOfConditionalType(type);
36426         }
36427         function getConstraintOfConditionalType(type) {
36428             return hasNonCircularBaseConstraint(type) ? getConstraintFromConditionalType(type) : undefined;
36429         }
36430         function getEffectiveConstraintOfIntersection(types, targetIsUnion) {
36431             var constraints;
36432             var hasDisjointDomainType = false;
36433             for (var _i = 0, types_5 = types; _i < types_5.length; _i++) {
36434                 var t = types_5[_i];
36435                 if (t.flags & 63176704) {
36436                     var constraint = getConstraintOfType(t);
36437                     while (constraint && constraint.flags & (262144 | 4194304 | 16777216)) {
36438                         constraint = getConstraintOfType(constraint);
36439                     }
36440                     if (constraint) {
36441                         constraints = ts.append(constraints, constraint);
36442                         if (targetIsUnion) {
36443                             constraints = ts.append(constraints, t);
36444                         }
36445                     }
36446                 }
36447                 else if (t.flags & 67238908) {
36448                     hasDisjointDomainType = true;
36449                 }
36450             }
36451             if (constraints && (targetIsUnion || hasDisjointDomainType)) {
36452                 if (hasDisjointDomainType) {
36453                     for (var _a = 0, types_6 = types; _a < types_6.length; _a++) {
36454                         var t = types_6[_a];
36455                         if (t.flags & 67238908) {
36456                             constraints = ts.append(constraints, t);
36457                         }
36458                     }
36459                 }
36460                 return getIntersectionType(constraints);
36461             }
36462             return undefined;
36463         }
36464         function getBaseConstraintOfType(type) {
36465             if (type.flags & (58982400 | 3145728)) {
36466                 var constraint = getResolvedBaseConstraint(type);
36467                 return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined;
36468             }
36469             return type.flags & 4194304 ? keyofConstraintType : undefined;
36470         }
36471         function getBaseConstraintOrType(type) {
36472             return getBaseConstraintOfType(type) || type;
36473         }
36474         function hasNonCircularBaseConstraint(type) {
36475             return getResolvedBaseConstraint(type) !== circularConstraintType;
36476         }
36477         function getResolvedBaseConstraint(type) {
36478             var nonTerminating = false;
36479             return type.resolvedBaseConstraint ||
36480                 (type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type));
36481             function getImmediateBaseConstraint(t) {
36482                 if (!t.immediateBaseConstraint) {
36483                     if (!pushTypeResolution(t, 4)) {
36484                         return circularConstraintType;
36485                     }
36486                     if (constraintDepth >= 50) {
36487                         error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
36488                         nonTerminating = true;
36489                         return t.immediateBaseConstraint = noConstraintType;
36490                     }
36491                     constraintDepth++;
36492                     var result = computeBaseConstraint(getSimplifiedType(t, false));
36493                     constraintDepth--;
36494                     if (!popTypeResolution()) {
36495                         if (t.flags & 262144) {
36496                             var errorNode = getConstraintDeclaration(t);
36497                             if (errorNode) {
36498                                 var diagnostic = error(errorNode, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(t));
36499                                 if (currentNode && !ts.isNodeDescendantOf(errorNode, currentNode) && !ts.isNodeDescendantOf(currentNode, errorNode)) {
36500                                     ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(currentNode, ts.Diagnostics.Circularity_originates_in_type_at_this_location));
36501                                 }
36502                             }
36503                         }
36504                         result = circularConstraintType;
36505                     }
36506                     if (nonTerminating) {
36507                         result = circularConstraintType;
36508                     }
36509                     t.immediateBaseConstraint = result || noConstraintType;
36510                 }
36511                 return t.immediateBaseConstraint;
36512             }
36513             function getBaseConstraint(t) {
36514                 var c = getImmediateBaseConstraint(t);
36515                 return c !== noConstraintType && c !== circularConstraintType ? c : undefined;
36516             }
36517             function computeBaseConstraint(t) {
36518                 if (t.flags & 262144) {
36519                     var constraint = getConstraintFromTypeParameter(t);
36520                     return t.isThisType || !constraint ?
36521                         constraint :
36522                         getBaseConstraint(constraint);
36523                 }
36524                 if (t.flags & 3145728) {
36525                     var types = t.types;
36526                     var baseTypes = [];
36527                     for (var _i = 0, types_7 = types; _i < types_7.length; _i++) {
36528                         var type_2 = types_7[_i];
36529                         var baseType = getBaseConstraint(type_2);
36530                         if (baseType) {
36531                             baseTypes.push(baseType);
36532                         }
36533                     }
36534                     return t.flags & 1048576 && baseTypes.length === types.length ? getUnionType(baseTypes) :
36535                         t.flags & 2097152 && baseTypes.length ? getIntersectionType(baseTypes) :
36536                             undefined;
36537                 }
36538                 if (t.flags & 4194304) {
36539                     return keyofConstraintType;
36540                 }
36541                 if (t.flags & 8388608) {
36542                     var baseObjectType = getBaseConstraint(t.objectType);
36543                     var baseIndexType = getBaseConstraint(t.indexType);
36544                     var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType);
36545                     return baseIndexedAccess && getBaseConstraint(baseIndexedAccess);
36546                 }
36547                 if (t.flags & 16777216) {
36548                     var constraint = getConstraintFromConditionalType(t);
36549                     constraintDepth++;
36550                     var result = constraint && getBaseConstraint(constraint);
36551                     constraintDepth--;
36552                     return result;
36553                 }
36554                 if (t.flags & 33554432) {
36555                     return getBaseConstraint(t.substitute);
36556                 }
36557                 return t;
36558             }
36559         }
36560         function getApparentTypeOfIntersectionType(type) {
36561             return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(type, type, true));
36562         }
36563         function getResolvedTypeParameterDefault(typeParameter) {
36564             if (!typeParameter.default) {
36565                 if (typeParameter.target) {
36566                     var targetDefault = getResolvedTypeParameterDefault(typeParameter.target);
36567                     typeParameter.default = targetDefault ? instantiateType(targetDefault, typeParameter.mapper) : noConstraintType;
36568                 }
36569                 else {
36570                     typeParameter.default = resolvingDefaultType;
36571                     var defaultDeclaration = typeParameter.symbol && ts.forEach(typeParameter.symbol.declarations, function (decl) { return ts.isTypeParameterDeclaration(decl) && decl.default; });
36572                     var defaultType = defaultDeclaration ? getTypeFromTypeNode(defaultDeclaration) : noConstraintType;
36573                     if (typeParameter.default === resolvingDefaultType) {
36574                         typeParameter.default = defaultType;
36575                     }
36576                 }
36577             }
36578             else if (typeParameter.default === resolvingDefaultType) {
36579                 typeParameter.default = circularConstraintType;
36580             }
36581             return typeParameter.default;
36582         }
36583         function getDefaultFromTypeParameter(typeParameter) {
36584             var defaultType = getResolvedTypeParameterDefault(typeParameter);
36585             return defaultType !== noConstraintType && defaultType !== circularConstraintType ? defaultType : undefined;
36586         }
36587         function hasNonCircularTypeParameterDefault(typeParameter) {
36588             return getResolvedTypeParameterDefault(typeParameter) !== circularConstraintType;
36589         }
36590         function hasTypeParameterDefault(typeParameter) {
36591             return !!(typeParameter.symbol && ts.forEach(typeParameter.symbol.declarations, function (decl) { return ts.isTypeParameterDeclaration(decl) && decl.default; }));
36592         }
36593         function getApparentTypeOfMappedType(type) {
36594             return type.resolvedApparentType || (type.resolvedApparentType = getResolvedApparentTypeOfMappedType(type));
36595         }
36596         function getResolvedApparentTypeOfMappedType(type) {
36597             var typeVariable = getHomomorphicTypeVariable(type);
36598             if (typeVariable) {
36599                 var constraint = getConstraintOfTypeParameter(typeVariable);
36600                 if (constraint && (isArrayType(constraint) || isTupleType(constraint))) {
36601                     return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper));
36602                 }
36603             }
36604             return type;
36605         }
36606         function getApparentType(type) {
36607             var t = type.flags & 63176704 ? getBaseConstraintOfType(type) || unknownType : type;
36608             return ts.getObjectFlags(t) & 32 ? getApparentTypeOfMappedType(t) :
36609                 t.flags & 2097152 ? getApparentTypeOfIntersectionType(t) :
36610                     t.flags & 132 ? globalStringType :
36611                         t.flags & 296 ? globalNumberType :
36612                             t.flags & 2112 ? getGlobalBigIntType(languageVersion >= 7) :
36613                                 t.flags & 528 ? globalBooleanType :
36614                                     t.flags & 12288 ? getGlobalESSymbolType(languageVersion >= 2) :
36615                                         t.flags & 67108864 ? emptyObjectType :
36616                                             t.flags & 4194304 ? keyofConstraintType :
36617                                                 t.flags & 2 && !strictNullChecks ? emptyObjectType :
36618                                                     t;
36619         }
36620         function getReducedApparentType(type) {
36621             return getReducedType(getApparentType(getReducedType(type)));
36622         }
36623         function createUnionOrIntersectionProperty(containingType, name) {
36624             var singleProp;
36625             var propSet;
36626             var indexTypes;
36627             var isUnion = containingType.flags & 1048576;
36628             var optionalFlag = isUnion ? 0 : 16777216;
36629             var syntheticFlag = 4;
36630             var checkFlags = 0;
36631             for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) {
36632                 var current = _a[_i];
36633                 var type = getApparentType(current);
36634                 if (!(type === errorType || type.flags & 131072)) {
36635                     var prop = getPropertyOfType(type, name);
36636                     var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
36637                     if (prop) {
36638                         if (isUnion) {
36639                             optionalFlag |= (prop.flags & 16777216);
36640                         }
36641                         else {
36642                             optionalFlag &= prop.flags;
36643                         }
36644                         if (!singleProp) {
36645                             singleProp = prop;
36646                         }
36647                         else if (prop !== singleProp) {
36648                             if (!propSet) {
36649                                 propSet = ts.createMap();
36650                                 propSet.set("" + getSymbolId(singleProp), singleProp);
36651                             }
36652                             var id = "" + getSymbolId(prop);
36653                             if (!propSet.has(id)) {
36654                                 propSet.set(id, prop);
36655                             }
36656                         }
36657                         checkFlags |= (isReadonlySymbol(prop) ? 8 : 0) |
36658                             (!(modifiers & 24) ? 256 : 0) |
36659                             (modifiers & 16 ? 512 : 0) |
36660                             (modifiers & 8 ? 1024 : 0) |
36661                             (modifiers & 32 ? 2048 : 0);
36662                         if (!isPrototypeProperty(prop)) {
36663                             syntheticFlag = 2;
36664                         }
36665                     }
36666                     else if (isUnion) {
36667                         var indexInfo = !isLateBoundName(name) && (isNumericLiteralName(name) && getIndexInfoOfType(type, 1) || getIndexInfoOfType(type, 0));
36668                         if (indexInfo) {
36669                             checkFlags |= 32 | (indexInfo.isReadonly ? 8 : 0);
36670                             indexTypes = ts.append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type);
36671                         }
36672                         else if (isObjectLiteralType(type)) {
36673                             checkFlags |= 32;
36674                             indexTypes = ts.append(indexTypes, undefinedType);
36675                         }
36676                         else {
36677                             checkFlags |= 16;
36678                         }
36679                     }
36680                 }
36681             }
36682             if (!singleProp || isUnion && (propSet || checkFlags & 48) && checkFlags & (1024 | 512)) {
36683                 return undefined;
36684             }
36685             if (!propSet && !(checkFlags & 16) && !indexTypes) {
36686                 return singleProp;
36687             }
36688             var props = propSet ? ts.arrayFrom(propSet.values()) : [singleProp];
36689             var declarations;
36690             var firstType;
36691             var nameType;
36692             var propTypes = [];
36693             var firstValueDeclaration;
36694             var hasNonUniformValueDeclaration = false;
36695             for (var _b = 0, props_1 = props; _b < props_1.length; _b++) {
36696                 var prop = props_1[_b];
36697                 if (!firstValueDeclaration) {
36698                     firstValueDeclaration = prop.valueDeclaration;
36699                 }
36700                 else if (prop.valueDeclaration && prop.valueDeclaration !== firstValueDeclaration) {
36701                     hasNonUniformValueDeclaration = true;
36702                 }
36703                 declarations = ts.addRange(declarations, prop.declarations);
36704                 var type = getTypeOfSymbol(prop);
36705                 if (!firstType) {
36706                     firstType = type;
36707                     nameType = getSymbolLinks(prop).nameType;
36708                 }
36709                 else if (type !== firstType) {
36710                     checkFlags |= 64;
36711                 }
36712                 if (isLiteralType(type)) {
36713                     checkFlags |= 128;
36714                 }
36715                 if (type.flags & 131072) {
36716                     checkFlags |= 131072;
36717                 }
36718                 propTypes.push(type);
36719             }
36720             ts.addRange(propTypes, indexTypes);
36721             var result = createSymbol(4 | optionalFlag, name, syntheticFlag | checkFlags);
36722             result.containingType = containingType;
36723             if (!hasNonUniformValueDeclaration && firstValueDeclaration) {
36724                 result.valueDeclaration = firstValueDeclaration;
36725                 if (firstValueDeclaration.symbol.parent) {
36726                     result.parent = firstValueDeclaration.symbol.parent;
36727                 }
36728             }
36729             result.declarations = declarations;
36730             result.nameType = nameType;
36731             if (propTypes.length > 2) {
36732                 result.checkFlags |= 65536;
36733                 result.deferralParent = containingType;
36734                 result.deferralConstituents = propTypes;
36735             }
36736             else {
36737                 result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes);
36738             }
36739             return result;
36740         }
36741         function getUnionOrIntersectionProperty(type, name) {
36742             var properties = type.propertyCache || (type.propertyCache = ts.createSymbolTable());
36743             var property = properties.get(name);
36744             if (!property) {
36745                 property = createUnionOrIntersectionProperty(type, name);
36746                 if (property) {
36747                     properties.set(name, property);
36748                 }
36749             }
36750             return property;
36751         }
36752         function getPropertyOfUnionOrIntersectionType(type, name) {
36753             var property = getUnionOrIntersectionProperty(type, name);
36754             return property && !(ts.getCheckFlags(property) & 16) ? property : undefined;
36755         }
36756         function getReducedType(type) {
36757             if (type.flags & 1048576 && type.objectFlags & 268435456) {
36758                 return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type));
36759             }
36760             else if (type.flags & 2097152) {
36761                 if (!(type.objectFlags & 268435456)) {
36762                     type.objectFlags |= 268435456 |
36763                         (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 536870912 : 0);
36764                 }
36765                 return type.objectFlags & 536870912 ? neverType : type;
36766             }
36767             return type;
36768         }
36769         function getReducedUnionType(unionType) {
36770             var reducedTypes = ts.sameMap(unionType.types, getReducedType);
36771             if (reducedTypes === unionType.types) {
36772                 return unionType;
36773             }
36774             var reduced = getUnionType(reducedTypes);
36775             if (reduced.flags & 1048576) {
36776                 reduced.resolvedReducedType = reduced;
36777             }
36778             return reduced;
36779         }
36780         function isNeverReducedProperty(prop) {
36781             return isDiscriminantWithNeverType(prop) || isConflictingPrivateProperty(prop);
36782         }
36783         function isDiscriminantWithNeverType(prop) {
36784             return !(prop.flags & 16777216) &&
36785                 (ts.getCheckFlags(prop) & (192 | 131072)) === 192 &&
36786                 !!(getTypeOfSymbol(prop).flags & 131072);
36787         }
36788         function isConflictingPrivateProperty(prop) {
36789             return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024);
36790         }
36791         function elaborateNeverIntersection(errorInfo, type) {
36792             if (ts.getObjectFlags(type) & 536870912) {
36793                 var neverProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isDiscriminantWithNeverType);
36794                 if (neverProp) {
36795                     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));
36796                 }
36797                 var privateProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isConflictingPrivateProperty);
36798                 if (privateProp) {
36799                     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));
36800                 }
36801             }
36802             return errorInfo;
36803         }
36804         function getPropertyOfType(type, name) {
36805             type = getReducedApparentType(type);
36806             if (type.flags & 524288) {
36807                 var resolved = resolveStructuredTypeMembers(type);
36808                 var symbol = resolved.members.get(name);
36809                 if (symbol && symbolIsValue(symbol)) {
36810                     return symbol;
36811                 }
36812                 var functionType = resolved === anyFunctionType ? globalFunctionType :
36813                     resolved.callSignatures.length ? globalCallableFunctionType :
36814                         resolved.constructSignatures.length ? globalNewableFunctionType :
36815                             undefined;
36816                 if (functionType) {
36817                     var symbol_1 = getPropertyOfObjectType(functionType, name);
36818                     if (symbol_1) {
36819                         return symbol_1;
36820                     }
36821                 }
36822                 return getPropertyOfObjectType(globalObjectType, name);
36823             }
36824             if (type.flags & 3145728) {
36825                 return getPropertyOfUnionOrIntersectionType(type, name);
36826             }
36827             return undefined;
36828         }
36829         function getSignaturesOfStructuredType(type, kind) {
36830             if (type.flags & 3670016) {
36831                 var resolved = resolveStructuredTypeMembers(type);
36832                 return kind === 0 ? resolved.callSignatures : resolved.constructSignatures;
36833             }
36834             return ts.emptyArray;
36835         }
36836         function getSignaturesOfType(type, kind) {
36837             return getSignaturesOfStructuredType(getReducedApparentType(type), kind);
36838         }
36839         function getIndexInfoOfStructuredType(type, kind) {
36840             if (type.flags & 3670016) {
36841                 var resolved = resolveStructuredTypeMembers(type);
36842                 return kind === 0 ? resolved.stringIndexInfo : resolved.numberIndexInfo;
36843             }
36844         }
36845         function getIndexTypeOfStructuredType(type, kind) {
36846             var info = getIndexInfoOfStructuredType(type, kind);
36847             return info && info.type;
36848         }
36849         function getIndexInfoOfType(type, kind) {
36850             return getIndexInfoOfStructuredType(getReducedApparentType(type), kind);
36851         }
36852         function getIndexTypeOfType(type, kind) {
36853             return getIndexTypeOfStructuredType(getReducedApparentType(type), kind);
36854         }
36855         function getImplicitIndexTypeOfType(type, kind) {
36856             if (isObjectTypeWithInferableIndex(type)) {
36857                 var propTypes = [];
36858                 for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) {
36859                     var prop = _a[_i];
36860                     if (kind === 0 || isNumericLiteralName(prop.escapedName)) {
36861                         propTypes.push(getTypeOfSymbol(prop));
36862                     }
36863                 }
36864                 if (kind === 0) {
36865                     ts.append(propTypes, getIndexTypeOfType(type, 1));
36866                 }
36867                 if (propTypes.length) {
36868                     return getUnionType(propTypes);
36869                 }
36870             }
36871             return undefined;
36872         }
36873         function getTypeParametersFromDeclaration(declaration) {
36874             var result;
36875             for (var _i = 0, _a = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _a.length; _i++) {
36876                 var node = _a[_i];
36877                 result = ts.appendIfUnique(result, getDeclaredTypeOfTypeParameter(node.symbol));
36878             }
36879             return result;
36880         }
36881         function symbolsToArray(symbols) {
36882             var result = [];
36883             symbols.forEach(function (symbol, id) {
36884                 if (!isReservedMemberName(id)) {
36885                     result.push(symbol);
36886                 }
36887             });
36888             return result;
36889         }
36890         function isJSDocOptionalParameter(node) {
36891             return ts.isInJSFile(node) && (node.type && node.type.kind === 299
36892                 || ts.getJSDocParameterTags(node).some(function (_a) {
36893                     var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression;
36894                     return isBracketed || !!typeExpression && typeExpression.type.kind === 299;
36895                 }));
36896         }
36897         function tryFindAmbientModule(moduleName, withAugmentations) {
36898             if (ts.isExternalModuleNameRelative(moduleName)) {
36899                 return undefined;
36900             }
36901             var symbol = getSymbol(globals, '"' + moduleName + '"', 512);
36902             return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol;
36903         }
36904         function isOptionalParameter(node) {
36905             if (ts.hasQuestionToken(node) || isOptionalJSDocParameterTag(node) || isJSDocOptionalParameter(node)) {
36906                 return true;
36907             }
36908             if (node.initializer) {
36909                 var signature = getSignatureFromDeclaration(node.parent);
36910                 var parameterIndex = node.parent.parameters.indexOf(node);
36911                 ts.Debug.assert(parameterIndex >= 0);
36912                 return parameterIndex >= getMinArgumentCount(signature, true);
36913             }
36914             var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent);
36915             if (iife) {
36916                 return !node.type &&
36917                     !node.dotDotDotToken &&
36918                     node.parent.parameters.indexOf(node) >= iife.arguments.length;
36919             }
36920             return false;
36921         }
36922         function isOptionalJSDocParameterTag(node) {
36923             if (!ts.isJSDocParameterTag(node)) {
36924                 return false;
36925             }
36926             var isBracketed = node.isBracketed, typeExpression = node.typeExpression;
36927             return isBracketed || !!typeExpression && typeExpression.type.kind === 299;
36928         }
36929         function createTypePredicate(kind, parameterName, parameterIndex, type) {
36930             return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type };
36931         }
36932         function getMinTypeArgumentCount(typeParameters) {
36933             var minTypeArgumentCount = 0;
36934             if (typeParameters) {
36935                 for (var i = 0; i < typeParameters.length; i++) {
36936                     if (!hasTypeParameterDefault(typeParameters[i])) {
36937                         minTypeArgumentCount = i + 1;
36938                     }
36939                 }
36940             }
36941             return minTypeArgumentCount;
36942         }
36943         function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, isJavaScriptImplicitAny) {
36944             var numTypeParameters = ts.length(typeParameters);
36945             if (!numTypeParameters) {
36946                 return [];
36947             }
36948             var numTypeArguments = ts.length(typeArguments);
36949             if (isJavaScriptImplicitAny || (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters)) {
36950                 var result = typeArguments ? typeArguments.slice() : [];
36951                 for (var i = numTypeArguments; i < numTypeParameters; i++) {
36952                     result[i] = errorType;
36953                 }
36954                 var baseDefaultType = getDefaultTypeArgumentType(isJavaScriptImplicitAny);
36955                 for (var i = numTypeArguments; i < numTypeParameters; i++) {
36956                     var defaultType = getDefaultFromTypeParameter(typeParameters[i]);
36957                     if (isJavaScriptImplicitAny && defaultType && (isTypeIdenticalTo(defaultType, unknownType) || isTypeIdenticalTo(defaultType, emptyObjectType))) {
36958                         defaultType = anyType;
36959                     }
36960                     result[i] = defaultType ? instantiateType(defaultType, createTypeMapper(typeParameters, result)) : baseDefaultType;
36961                 }
36962                 result.length = typeParameters.length;
36963                 return result;
36964             }
36965             return typeArguments && typeArguments.slice();
36966         }
36967         function getSignatureFromDeclaration(declaration) {
36968             var links = getNodeLinks(declaration);
36969             if (!links.resolvedSignature) {
36970                 var parameters = [];
36971                 var flags = 0;
36972                 var minArgumentCount = 0;
36973                 var thisParameter = void 0;
36974                 var hasThisParameter = false;
36975                 var iife = ts.getImmediatelyInvokedFunctionExpression(declaration);
36976                 var isJSConstructSignature = ts.isJSDocConstructSignature(declaration);
36977                 var isUntypedSignatureInJSFile = !iife &&
36978                     ts.isInJSFile(declaration) &&
36979                     ts.isValueSignatureDeclaration(declaration) &&
36980                     !ts.hasJSDocParameterTags(declaration) &&
36981                     !ts.getJSDocType(declaration);
36982                 if (isUntypedSignatureInJSFile) {
36983                     flags |= 16;
36984                 }
36985                 for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) {
36986                     var param = declaration.parameters[i];
36987                     var paramSymbol = param.symbol;
36988                     var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type;
36989                     if (paramSymbol && !!(paramSymbol.flags & 4) && !ts.isBindingPattern(param.name)) {
36990                         var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551, undefined, undefined, false);
36991                         paramSymbol = resolvedSymbol;
36992                     }
36993                     if (i === 0 && paramSymbol.escapedName === "this") {
36994                         hasThisParameter = true;
36995                         thisParameter = param.symbol;
36996                     }
36997                     else {
36998                         parameters.push(paramSymbol);
36999                     }
37000                     if (type && type.kind === 187) {
37001                         flags |= 2;
37002                     }
37003                     var isOptionalParameter_1 = isOptionalJSDocParameterTag(param) ||
37004                         param.initializer || param.questionToken || param.dotDotDotToken ||
37005                         iife && parameters.length > iife.arguments.length && !type ||
37006                         isJSDocOptionalParameter(param);
37007                     if (!isOptionalParameter_1) {
37008                         minArgumentCount = parameters.length;
37009                     }
37010                 }
37011                 if ((declaration.kind === 163 || declaration.kind === 164) &&
37012                     !hasNonBindableDynamicName(declaration) &&
37013                     (!hasThisParameter || !thisParameter)) {
37014                     var otherKind = declaration.kind === 163 ? 164 : 163;
37015                     var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind);
37016                     if (other) {
37017                         thisParameter = getAnnotatedAccessorThisParameter(other);
37018                     }
37019                 }
37020                 var classType = declaration.kind === 162 ?
37021                     getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol))
37022                     : undefined;
37023                 var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration);
37024                 if (ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) {
37025                     flags |= 1;
37026                 }
37027                 links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, undefined, undefined, minArgumentCount, flags);
37028             }
37029             return links.resolvedSignature;
37030         }
37031         function maybeAddJsSyntheticRestParameter(declaration, parameters) {
37032             if (ts.isJSDocSignature(declaration) || !containsArgumentsReference(declaration)) {
37033                 return false;
37034             }
37035             var lastParam = ts.lastOrUndefined(declaration.parameters);
37036             var lastParamTags = lastParam ? ts.getJSDocParameterTags(lastParam) : ts.getJSDocTags(declaration).filter(ts.isJSDocParameterTag);
37037             var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) {
37038                 return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined;
37039             });
37040             var syntheticArgsSymbol = createSymbol(3, "args", 32768);
37041             syntheticArgsSymbol.type = lastParamVariadicType ? createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)) : anyArrayType;
37042             if (lastParamVariadicType) {
37043                 parameters.pop();
37044             }
37045             parameters.push(syntheticArgsSymbol);
37046             return true;
37047         }
37048         function getSignatureOfTypeTag(node) {
37049             if (!(ts.isInJSFile(node) && ts.isFunctionLikeDeclaration(node)))
37050                 return undefined;
37051             var typeTag = ts.getJSDocTypeTag(node);
37052             var signature = typeTag && typeTag.typeExpression && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression));
37053             return signature && getErasedSignature(signature);
37054         }
37055         function getReturnTypeOfTypeTag(node) {
37056             var signature = getSignatureOfTypeTag(node);
37057             return signature && getReturnTypeOfSignature(signature);
37058         }
37059         function containsArgumentsReference(declaration) {
37060             var links = getNodeLinks(declaration);
37061             if (links.containsArgumentsReference === undefined) {
37062                 if (links.flags & 8192) {
37063                     links.containsArgumentsReference = true;
37064                 }
37065                 else {
37066                     links.containsArgumentsReference = traverse(declaration.body);
37067                 }
37068             }
37069             return links.containsArgumentsReference;
37070             function traverse(node) {
37071                 if (!node)
37072                     return false;
37073                 switch (node.kind) {
37074                     case 75:
37075                         return node.escapedText === "arguments" && ts.isExpressionNode(node);
37076                     case 159:
37077                     case 161:
37078                     case 163:
37079                     case 164:
37080                         return node.name.kind === 154
37081                             && traverse(node.name);
37082                     default:
37083                         return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse);
37084                 }
37085             }
37086         }
37087         function getSignaturesOfSymbol(symbol) {
37088             if (!symbol)
37089                 return ts.emptyArray;
37090             var result = [];
37091             for (var i = 0; i < symbol.declarations.length; i++) {
37092                 var decl = symbol.declarations[i];
37093                 if (!ts.isFunctionLike(decl))
37094                     continue;
37095                 if (i > 0 && decl.body) {
37096                     var previous = symbol.declarations[i - 1];
37097                     if (decl.parent === previous.parent && decl.kind === previous.kind && decl.pos === previous.end) {
37098                         continue;
37099                     }
37100                 }
37101                 result.push(getSignatureFromDeclaration(decl));
37102             }
37103             return result;
37104         }
37105         function resolveExternalModuleTypeByLiteral(name) {
37106             var moduleSym = resolveExternalModuleName(name, name);
37107             if (moduleSym) {
37108                 var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym);
37109                 if (resolvedModuleSymbol) {
37110                     return getTypeOfSymbol(resolvedModuleSymbol);
37111                 }
37112             }
37113             return anyType;
37114         }
37115         function getThisTypeOfSignature(signature) {
37116             if (signature.thisParameter) {
37117                 return getTypeOfSymbol(signature.thisParameter);
37118             }
37119         }
37120         function getTypePredicateOfSignature(signature) {
37121             if (!signature.resolvedTypePredicate) {
37122                 if (signature.target) {
37123                     var targetTypePredicate = getTypePredicateOfSignature(signature.target);
37124                     signature.resolvedTypePredicate = targetTypePredicate ? instantiateTypePredicate(targetTypePredicate, signature.mapper) : noTypePredicate;
37125                 }
37126                 else if (signature.unionSignatures) {
37127                     signature.resolvedTypePredicate = getUnionTypePredicate(signature.unionSignatures) || noTypePredicate;
37128                 }
37129                 else {
37130                     var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
37131                     var jsdocPredicate = void 0;
37132                     if (!type && ts.isInJSFile(signature.declaration)) {
37133                         var jsdocSignature = getSignatureOfTypeTag(signature.declaration);
37134                         if (jsdocSignature && signature !== jsdocSignature) {
37135                             jsdocPredicate = getTypePredicateOfSignature(jsdocSignature);
37136                         }
37137                     }
37138                     signature.resolvedTypePredicate = type && ts.isTypePredicateNode(type) ?
37139                         createTypePredicateFromTypePredicateNode(type, signature) :
37140                         jsdocPredicate || noTypePredicate;
37141                 }
37142                 ts.Debug.assert(!!signature.resolvedTypePredicate);
37143             }
37144             return signature.resolvedTypePredicate === noTypePredicate ? undefined : signature.resolvedTypePredicate;
37145         }
37146         function createTypePredicateFromTypePredicateNode(node, signature) {
37147             var parameterName = node.parameterName;
37148             var type = node.type && getTypeFromTypeNode(node.type);
37149             return parameterName.kind === 183 ?
37150                 createTypePredicate(node.assertsModifier ? 2 : 0, undefined, undefined, type) :
37151                 createTypePredicate(node.assertsModifier ? 3 : 1, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type);
37152         }
37153         function getReturnTypeOfSignature(signature) {
37154             if (!signature.resolvedReturnType) {
37155                 if (!pushTypeResolution(signature, 3)) {
37156                     return errorType;
37157                 }
37158                 var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) :
37159                     signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2) :
37160                         getReturnTypeFromAnnotation(signature.declaration) ||
37161                             (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration));
37162                 if (signature.flags & 4) {
37163                     type = addOptionalTypeMarker(type);
37164                 }
37165                 else if (signature.flags & 8) {
37166                     type = getOptionalType(type);
37167                 }
37168                 if (!popTypeResolution()) {
37169                     if (signature.declaration) {
37170                         var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration);
37171                         if (typeNode) {
37172                             error(typeNode, ts.Diagnostics.Return_type_annotation_circularly_references_itself);
37173                         }
37174                         else if (noImplicitAny) {
37175                             var declaration = signature.declaration;
37176                             var name = ts.getNameOfDeclaration(declaration);
37177                             if (name) {
37178                                 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));
37179                             }
37180                             else {
37181                                 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);
37182                             }
37183                         }
37184                     }
37185                     type = anyType;
37186                 }
37187                 signature.resolvedReturnType = type;
37188             }
37189             return signature.resolvedReturnType;
37190         }
37191         function getReturnTypeFromAnnotation(declaration) {
37192             if (declaration.kind === 162) {
37193                 return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol));
37194             }
37195             if (ts.isJSDocConstructSignature(declaration)) {
37196                 return getTypeFromTypeNode(declaration.parameters[0].type);
37197             }
37198             var typeNode = ts.getEffectiveReturnTypeNode(declaration);
37199             if (typeNode) {
37200                 return getTypeFromTypeNode(typeNode);
37201             }
37202             if (declaration.kind === 163 && !hasNonBindableDynamicName(declaration)) {
37203                 var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration);
37204                 if (jsDocType) {
37205                     return jsDocType;
37206                 }
37207                 var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 164);
37208                 var setterType = getAnnotatedAccessorType(setter);
37209                 if (setterType) {
37210                     return setterType;
37211                 }
37212             }
37213             return getReturnTypeOfTypeTag(declaration);
37214         }
37215         function isResolvingReturnTypeOfSignature(signature) {
37216             return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3) >= 0;
37217         }
37218         function getRestTypeOfSignature(signature) {
37219             return tryGetRestTypeOfSignature(signature) || anyType;
37220         }
37221         function tryGetRestTypeOfSignature(signature) {
37222             if (signatureHasRestParameter(signature)) {
37223                 var sigRestType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
37224                 var restType = isTupleType(sigRestType) ? getRestTypeOfTupleType(sigRestType) : sigRestType;
37225                 return restType && getIndexTypeOfType(restType, 1);
37226             }
37227             return undefined;
37228         }
37229         function getSignatureInstantiation(signature, typeArguments, isJavascript, inferredTypeParameters) {
37230             var instantiatedSignature = getSignatureInstantiationWithoutFillingInTypeArguments(signature, fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript));
37231             if (inferredTypeParameters) {
37232                 var returnSignature = getSingleCallOrConstructSignature(getReturnTypeOfSignature(instantiatedSignature));
37233                 if (returnSignature) {
37234                     var newReturnSignature = cloneSignature(returnSignature);
37235                     newReturnSignature.typeParameters = inferredTypeParameters;
37236                     var newInstantiatedSignature = cloneSignature(instantiatedSignature);
37237                     newInstantiatedSignature.resolvedReturnType = getOrCreateTypeFromSignature(newReturnSignature);
37238                     return newInstantiatedSignature;
37239                 }
37240             }
37241             return instantiatedSignature;
37242         }
37243         function getSignatureInstantiationWithoutFillingInTypeArguments(signature, typeArguments) {
37244             var instantiations = signature.instantiations || (signature.instantiations = ts.createMap());
37245             var id = getTypeListId(typeArguments);
37246             var instantiation = instantiations.get(id);
37247             if (!instantiation) {
37248                 instantiations.set(id, instantiation = createSignatureInstantiation(signature, typeArguments));
37249             }
37250             return instantiation;
37251         }
37252         function createSignatureInstantiation(signature, typeArguments) {
37253             return instantiateSignature(signature, createSignatureTypeMapper(signature, typeArguments), true);
37254         }
37255         function createSignatureTypeMapper(signature, typeArguments) {
37256             return createTypeMapper(signature.typeParameters, typeArguments);
37257         }
37258         function getErasedSignature(signature) {
37259             return signature.typeParameters ?
37260                 signature.erasedSignatureCache || (signature.erasedSignatureCache = createErasedSignature(signature)) :
37261                 signature;
37262         }
37263         function createErasedSignature(signature) {
37264             return instantiateSignature(signature, createTypeEraser(signature.typeParameters), true);
37265         }
37266         function getCanonicalSignature(signature) {
37267             return signature.typeParameters ?
37268                 signature.canonicalSignatureCache || (signature.canonicalSignatureCache = createCanonicalSignature(signature)) :
37269                 signature;
37270         }
37271         function createCanonicalSignature(signature) {
37272             return getSignatureInstantiation(signature, ts.map(signature.typeParameters, function (tp) { return tp.target && !getConstraintOfTypeParameter(tp.target) ? tp.target : tp; }), ts.isInJSFile(signature.declaration));
37273         }
37274         function getBaseSignature(signature) {
37275             var typeParameters = signature.typeParameters;
37276             if (typeParameters) {
37277                 var typeEraser_1 = createTypeEraser(typeParameters);
37278                 var baseConstraints = ts.map(typeParameters, function (tp) { return instantiateType(getBaseConstraintOfType(tp), typeEraser_1) || unknownType; });
37279                 return instantiateSignature(signature, createTypeMapper(typeParameters, baseConstraints), true);
37280             }
37281             return signature;
37282         }
37283         function getOrCreateTypeFromSignature(signature) {
37284             if (!signature.isolatedSignatureType) {
37285                 var kind = signature.declaration ? signature.declaration.kind : 0;
37286                 var isConstructor = kind === 162 || kind === 166 || kind === 171;
37287                 var type = createObjectType(16);
37288                 type.members = emptySymbols;
37289                 type.properties = ts.emptyArray;
37290                 type.callSignatures = !isConstructor ? [signature] : ts.emptyArray;
37291                 type.constructSignatures = isConstructor ? [signature] : ts.emptyArray;
37292                 signature.isolatedSignatureType = type;
37293             }
37294             return signature.isolatedSignatureType;
37295         }
37296         function getIndexSymbol(symbol) {
37297             return symbol.members.get("__index");
37298         }
37299         function getIndexDeclarationOfSymbol(symbol, kind) {
37300             var syntaxKind = kind === 1 ? 140 : 143;
37301             var indexSymbol = getIndexSymbol(symbol);
37302             if (indexSymbol) {
37303                 for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
37304                     var decl = _a[_i];
37305                     var node = ts.cast(decl, ts.isIndexSignatureDeclaration);
37306                     if (node.parameters.length === 1) {
37307                         var parameter = node.parameters[0];
37308                         if (parameter.type && parameter.type.kind === syntaxKind) {
37309                             return node;
37310                         }
37311                     }
37312                 }
37313             }
37314             return undefined;
37315         }
37316         function createIndexInfo(type, isReadonly, declaration) {
37317             return { type: type, isReadonly: isReadonly, declaration: declaration };
37318         }
37319         function getIndexInfoOfSymbol(symbol, kind) {
37320             var declaration = getIndexDeclarationOfSymbol(symbol, kind);
37321             if (declaration) {
37322                 return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasModifier(declaration, 64), declaration);
37323             }
37324             return undefined;
37325         }
37326         function getConstraintDeclaration(type) {
37327             return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0];
37328         }
37329         function getInferredTypeParameterConstraint(typeParameter) {
37330             var inferences;
37331             if (typeParameter.symbol) {
37332                 for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) {
37333                     var declaration = _a[_i];
37334                     if (declaration.parent.kind === 181) {
37335                         var grandParent = declaration.parent.parent;
37336                         if (grandParent.kind === 169) {
37337                             var typeReference = grandParent;
37338                             var typeParameters = getTypeParametersForTypeReference(typeReference);
37339                             if (typeParameters) {
37340                                 var index = typeReference.typeArguments.indexOf(declaration.parent);
37341                                 if (index < typeParameters.length) {
37342                                     var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]);
37343                                     if (declaredConstraint) {
37344                                         var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters));
37345                                         var constraint = instantiateType(declaredConstraint, mapper);
37346                                         if (constraint !== typeParameter) {
37347                                             inferences = ts.append(inferences, constraint);
37348                                         }
37349                                     }
37350                                 }
37351                             }
37352                         }
37353                         else if (grandParent.kind === 156 && grandParent.dotDotDotToken) {
37354                             inferences = ts.append(inferences, createArrayType(unknownType));
37355                         }
37356                     }
37357                 }
37358             }
37359             return inferences && getIntersectionType(inferences);
37360         }
37361         function getConstraintFromTypeParameter(typeParameter) {
37362             if (!typeParameter.constraint) {
37363                 if (typeParameter.target) {
37364                     var targetConstraint = getConstraintOfTypeParameter(typeParameter.target);
37365                     typeParameter.constraint = targetConstraint ? instantiateType(targetConstraint, typeParameter.mapper) : noConstraintType;
37366                 }
37367                 else {
37368                     var constraintDeclaration = getConstraintDeclaration(typeParameter);
37369                     if (!constraintDeclaration) {
37370                         typeParameter.constraint = getInferredTypeParameterConstraint(typeParameter) || noConstraintType;
37371                     }
37372                     else {
37373                         var type = getTypeFromTypeNode(constraintDeclaration);
37374                         if (type.flags & 1 && type !== errorType) {
37375                             type = constraintDeclaration.parent.parent.kind === 186 ? keyofConstraintType : unknownType;
37376                         }
37377                         typeParameter.constraint = type;
37378                     }
37379                 }
37380             }
37381             return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint;
37382         }
37383         function getParentSymbolOfTypeParameter(typeParameter) {
37384             var tp = ts.getDeclarationOfKind(typeParameter.symbol, 155);
37385             var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent;
37386             return host && getSymbolOfNode(host);
37387         }
37388         function getTypeListId(types) {
37389             var result = "";
37390             if (types) {
37391                 var length_4 = types.length;
37392                 var i = 0;
37393                 while (i < length_4) {
37394                     var startId = types[i].id;
37395                     var count = 1;
37396                     while (i + count < length_4 && types[i + count].id === startId + count) {
37397                         count++;
37398                     }
37399                     if (result.length) {
37400                         result += ",";
37401                     }
37402                     result += startId;
37403                     if (count > 1) {
37404                         result += ":" + count;
37405                     }
37406                     i += count;
37407                 }
37408             }
37409             return result;
37410         }
37411         function getPropagatingFlagsOfTypes(types, excludeKinds) {
37412             var result = 0;
37413             for (var _i = 0, types_8 = types; _i < types_8.length; _i++) {
37414                 var type = types_8[_i];
37415                 if (!(type.flags & excludeKinds)) {
37416                     result |= ts.getObjectFlags(type);
37417                 }
37418             }
37419             return result & 3670016;
37420         }
37421         function createTypeReference(target, typeArguments) {
37422             var id = getTypeListId(typeArguments);
37423             var type = target.instantiations.get(id);
37424             if (!type) {
37425                 type = createObjectType(4, target.symbol);
37426                 target.instantiations.set(id, type);
37427                 type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, 0) : 0;
37428                 type.target = target;
37429                 type.resolvedTypeArguments = typeArguments;
37430             }
37431             return type;
37432         }
37433         function cloneTypeReference(source) {
37434             var type = createType(source.flags);
37435             type.symbol = source.symbol;
37436             type.objectFlags = source.objectFlags;
37437             type.target = source.target;
37438             type.resolvedTypeArguments = source.resolvedTypeArguments;
37439             return type;
37440         }
37441         function createDeferredTypeReference(target, node, mapper) {
37442             var aliasSymbol = getAliasSymbolForTypeNode(node);
37443             var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
37444             var type = createObjectType(4, target.symbol);
37445             type.target = target;
37446             type.node = node;
37447             type.mapper = mapper;
37448             type.aliasSymbol = aliasSymbol;
37449             type.aliasTypeArguments = mapper ? instantiateTypes(aliasTypeArguments, mapper) : aliasTypeArguments;
37450             return type;
37451         }
37452         function getTypeArguments(type) {
37453             var _a, _b;
37454             if (!type.resolvedTypeArguments) {
37455                 if (!pushTypeResolution(type, 6)) {
37456                     return ((_a = type.target.localTypeParameters) === null || _a === void 0 ? void 0 : _a.map(function () { return errorType; })) || ts.emptyArray;
37457                 }
37458                 var node = type.node;
37459                 var typeArguments = !node ? ts.emptyArray :
37460                     node.kind === 169 ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) :
37461                         node.kind === 174 ? [getTypeFromTypeNode(node.elementType)] :
37462                             ts.map(node.elementTypes, getTypeFromTypeNode);
37463                 if (popTypeResolution()) {
37464                     type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments;
37465                 }
37466                 else {
37467                     type.resolvedTypeArguments = ((_b = type.target.localTypeParameters) === null || _b === void 0 ? void 0 : _b.map(function () { return errorType; })) || ts.emptyArray;
37468                     error(type.node || currentNode, type.target.symbol
37469                         ? ts.Diagnostics.Type_arguments_for_0_circularly_reference_themselves
37470                         : ts.Diagnostics.Tuple_type_arguments_circularly_reference_themselves, type.target.symbol && symbolToString(type.target.symbol));
37471                 }
37472             }
37473             return type.resolvedTypeArguments;
37474         }
37475         function getTypeReferenceArity(type) {
37476             return ts.length(type.target.typeParameters);
37477         }
37478         function getTypeFromClassOrInterfaceReference(node, symbol) {
37479             var type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol));
37480             var typeParameters = type.localTypeParameters;
37481             if (typeParameters) {
37482                 var numTypeArguments = ts.length(node.typeArguments);
37483                 var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters);
37484                 var isJs = ts.isInJSFile(node);
37485                 var isJsImplicitAny = !noImplicitAny && isJs;
37486                 if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) {
37487                     var missingAugmentsTag = isJs && ts.isExpressionWithTypeArguments(node) && !ts.isJSDocAugmentsTag(node.parent);
37488                     var diag = minTypeArgumentCount === typeParameters.length ?
37489                         missingAugmentsTag ?
37490                             ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag :
37491                             ts.Diagnostics.Generic_type_0_requires_1_type_argument_s :
37492                         missingAugmentsTag ?
37493                             ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag :
37494                             ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments;
37495                     var typeStr = typeToString(type, undefined, 2);
37496                     error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length);
37497                     if (!isJs) {
37498                         return errorType;
37499                     }
37500                 }
37501                 if (node.kind === 169 && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) {
37502                     return createDeferredTypeReference(type, node, undefined);
37503                 }
37504                 var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgumentsFromTypeReferenceNode(node), typeParameters, minTypeArgumentCount, isJs));
37505                 return createTypeReference(type, typeArguments);
37506             }
37507             return checkNoTypeArguments(node, symbol) ? type : errorType;
37508         }
37509         function getTypeAliasInstantiation(symbol, typeArguments) {
37510             var type = getDeclaredTypeOfSymbol(symbol);
37511             var links = getSymbolLinks(symbol);
37512             var typeParameters = links.typeParameters;
37513             var id = getTypeListId(typeArguments);
37514             var instantiation = links.instantiations.get(id);
37515             if (!instantiation) {
37516                 links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(symbol.valueDeclaration)))));
37517             }
37518             return instantiation;
37519         }
37520         function getTypeFromTypeAliasReference(node, symbol) {
37521             var type = getDeclaredTypeOfSymbol(symbol);
37522             var typeParameters = getSymbolLinks(symbol).typeParameters;
37523             if (typeParameters) {
37524                 var numTypeArguments = ts.length(node.typeArguments);
37525                 var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters);
37526                 if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) {
37527                     error(node, minTypeArgumentCount === typeParameters.length ?
37528                         ts.Diagnostics.Generic_type_0_requires_1_type_argument_s :
37529                         ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length);
37530                     return errorType;
37531                 }
37532                 return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node));
37533             }
37534             return checkNoTypeArguments(node, symbol) ? type : errorType;
37535         }
37536         function getTypeReferenceName(node) {
37537             switch (node.kind) {
37538                 case 169:
37539                     return node.typeName;
37540                 case 216:
37541                     var expr = node.expression;
37542                     if (ts.isEntityNameExpression(expr)) {
37543                         return expr;
37544                     }
37545             }
37546             return undefined;
37547         }
37548         function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) {
37549             if (!typeReferenceName) {
37550                 return unknownSymbol;
37551             }
37552             return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol;
37553         }
37554         function getTypeReferenceType(node, symbol) {
37555             if (symbol === unknownSymbol) {
37556                 return errorType;
37557             }
37558             symbol = getExpandoSymbol(symbol) || symbol;
37559             if (symbol.flags & (32 | 64)) {
37560                 return getTypeFromClassOrInterfaceReference(node, symbol);
37561             }
37562             if (symbol.flags & 524288) {
37563                 return getTypeFromTypeAliasReference(node, symbol);
37564             }
37565             var res = tryGetDeclaredTypeOfSymbol(symbol);
37566             if (res) {
37567                 return checkNoTypeArguments(node, symbol) ? getRegularTypeOfLiteralType(res) : errorType;
37568             }
37569             if (symbol.flags & 111551 && isJSDocTypeReference(node)) {
37570                 var jsdocType = getTypeFromJSDocValueReference(node, symbol);
37571                 if (jsdocType) {
37572                     return jsdocType;
37573                 }
37574                 else {
37575                     resolveTypeReferenceName(getTypeReferenceName(node), 788968);
37576                     return getTypeOfSymbol(symbol);
37577                 }
37578             }
37579             return errorType;
37580         }
37581         function getTypeFromJSDocValueReference(node, symbol) {
37582             var links = getNodeLinks(node);
37583             if (!links.resolvedJSDocType) {
37584                 var valueType = getTypeOfSymbol(symbol);
37585                 var typeType = valueType;
37586                 if (symbol.valueDeclaration) {
37587                     var decl = ts.getRootDeclaration(symbol.valueDeclaration);
37588                     var isRequireAlias = false;
37589                     if (ts.isVariableDeclaration(decl) && decl.initializer) {
37590                         var expr = decl.initializer;
37591                         while (ts.isPropertyAccessExpression(expr)) {
37592                             expr = expr.expression;
37593                         }
37594                         isRequireAlias = ts.isCallExpression(expr) && ts.isRequireCall(expr, true) && !!valueType.symbol;
37595                     }
37596                     var isImportTypeWithQualifier = node.kind === 188 && node.qualifier;
37597                     if (valueType.symbol && (isRequireAlias || isImportTypeWithQualifier)) {
37598                         typeType = getTypeReferenceType(node, valueType.symbol);
37599                     }
37600                 }
37601                 links.resolvedJSDocType = typeType;
37602             }
37603             return links.resolvedJSDocType;
37604         }
37605         function getSubstitutionType(baseType, substitute) {
37606             if (substitute.flags & 3 || substitute === baseType) {
37607                 return baseType;
37608             }
37609             var id = getTypeId(baseType) + ">" + getTypeId(substitute);
37610             var cached = substitutionTypes.get(id);
37611             if (cached) {
37612                 return cached;
37613             }
37614             var result = createType(33554432);
37615             result.baseType = baseType;
37616             result.substitute = substitute;
37617             substitutionTypes.set(id, result);
37618             return result;
37619         }
37620         function isUnaryTupleTypeNode(node) {
37621             return node.kind === 175 && node.elementTypes.length === 1;
37622         }
37623         function getImpliedConstraint(type, checkNode, extendsNode) {
37624             return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elementTypes[0], extendsNode.elementTypes[0]) :
37625                 getActualTypeVariable(getTypeFromTypeNode(checkNode)) === type ? getTypeFromTypeNode(extendsNode) :
37626                     undefined;
37627         }
37628         function getConditionalFlowTypeOfType(type, node) {
37629             var constraints;
37630             while (node && !ts.isStatement(node) && node.kind !== 303) {
37631                 var parent = node.parent;
37632                 if (parent.kind === 180 && node === parent.trueType) {
37633                     var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType);
37634                     if (constraint) {
37635                         constraints = ts.append(constraints, constraint);
37636                     }
37637                 }
37638                 node = parent;
37639             }
37640             return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
37641         }
37642         function isJSDocTypeReference(node) {
37643             return !!(node.flags & 4194304) && (node.kind === 169 || node.kind === 188);
37644         }
37645         function checkNoTypeArguments(node, symbol) {
37646             if (node.typeArguments) {
37647                 error(node, ts.Diagnostics.Type_0_is_not_generic, symbol ? symbolToString(symbol) : node.typeName ? ts.declarationNameToString(node.typeName) : anon);
37648                 return false;
37649             }
37650             return true;
37651         }
37652         function getIntendedTypeFromJSDocTypeReference(node) {
37653             if (ts.isIdentifier(node.typeName)) {
37654                 var typeArgs = node.typeArguments;
37655                 switch (node.typeName.escapedText) {
37656                     case "String":
37657                         checkNoTypeArguments(node);
37658                         return stringType;
37659                     case "Number":
37660                         checkNoTypeArguments(node);
37661                         return numberType;
37662                     case "Boolean":
37663                         checkNoTypeArguments(node);
37664                         return booleanType;
37665                     case "Void":
37666                         checkNoTypeArguments(node);
37667                         return voidType;
37668                     case "Undefined":
37669                         checkNoTypeArguments(node);
37670                         return undefinedType;
37671                     case "Null":
37672                         checkNoTypeArguments(node);
37673                         return nullType;
37674                     case "Function":
37675                     case "function":
37676                         checkNoTypeArguments(node);
37677                         return globalFunctionType;
37678                     case "array":
37679                         return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined;
37680                     case "promise":
37681                         return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined;
37682                     case "Object":
37683                         if (typeArgs && typeArgs.length === 2) {
37684                             if (ts.isJSDocIndexSignature(node)) {
37685                                 var indexed = getTypeFromTypeNode(typeArgs[0]);
37686                                 var target = getTypeFromTypeNode(typeArgs[1]);
37687                                 var index = createIndexInfo(target, false);
37688                                 return createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, indexed === stringType ? index : undefined, indexed === numberType ? index : undefined);
37689                             }
37690                             return anyType;
37691                         }
37692                         checkNoTypeArguments(node);
37693                         return !noImplicitAny ? anyType : undefined;
37694                 }
37695             }
37696         }
37697         function getTypeFromJSDocNullableTypeNode(node) {
37698             var type = getTypeFromTypeNode(node.type);
37699             return strictNullChecks ? getNullableType(type, 65536) : type;
37700         }
37701         function getTypeFromTypeReference(node) {
37702             var links = getNodeLinks(node);
37703             if (!links.resolvedType) {
37704                 if (ts.isConstTypeReference(node) && ts.isAssertionExpression(node.parent)) {
37705                     links.resolvedSymbol = unknownSymbol;
37706                     return links.resolvedType = checkExpressionCached(node.parent.expression);
37707                 }
37708                 var symbol = void 0;
37709                 var type = void 0;
37710                 var meaning = 788968;
37711                 if (isJSDocTypeReference(node)) {
37712                     type = getIntendedTypeFromJSDocTypeReference(node);
37713                     if (!type) {
37714                         symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, true);
37715                         if (symbol === unknownSymbol) {
37716                             symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551);
37717                         }
37718                         else {
37719                             resolveTypeReferenceName(getTypeReferenceName(node), meaning);
37720                         }
37721                         type = getTypeReferenceType(node, symbol);
37722                     }
37723                 }
37724                 if (!type) {
37725                     symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning);
37726                     type = getTypeReferenceType(node, symbol);
37727                 }
37728                 links.resolvedSymbol = symbol;
37729                 links.resolvedType = type;
37730             }
37731             return links.resolvedType;
37732         }
37733         function typeArgumentsFromTypeReferenceNode(node) {
37734             return ts.map(node.typeArguments, getTypeFromTypeNode);
37735         }
37736         function getTypeFromTypeQueryNode(node) {
37737             var links = getNodeLinks(node);
37738             if (!links.resolvedType) {
37739                 links.resolvedType = getRegularTypeOfLiteralType(getWidenedType(checkExpression(node.exprName)));
37740             }
37741             return links.resolvedType;
37742         }
37743         function getTypeOfGlobalSymbol(symbol, arity) {
37744             function getTypeDeclaration(symbol) {
37745                 var declarations = symbol.declarations;
37746                 for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) {
37747                     var declaration = declarations_3[_i];
37748                     switch (declaration.kind) {
37749                         case 245:
37750                         case 246:
37751                         case 248:
37752                             return declaration;
37753                     }
37754                 }
37755             }
37756             if (!symbol) {
37757                 return arity ? emptyGenericType : emptyObjectType;
37758             }
37759             var type = getDeclaredTypeOfSymbol(symbol);
37760             if (!(type.flags & 524288)) {
37761                 error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol));
37762                 return arity ? emptyGenericType : emptyObjectType;
37763             }
37764             if (ts.length(type.typeParameters) !== arity) {
37765                 error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, ts.symbolName(symbol), arity);
37766                 return arity ? emptyGenericType : emptyObjectType;
37767             }
37768             return type;
37769         }
37770         function getGlobalValueSymbol(name, reportErrors) {
37771             return getGlobalSymbol(name, 111551, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined);
37772         }
37773         function getGlobalTypeSymbol(name, reportErrors) {
37774             return getGlobalSymbol(name, 788968, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined);
37775         }
37776         function getGlobalSymbol(name, meaning, diagnostic) {
37777             return resolveName(undefined, name, meaning, diagnostic, name, false);
37778         }
37779         function getGlobalType(name, arity, reportErrors) {
37780             var symbol = getGlobalTypeSymbol(name, reportErrors);
37781             return symbol || reportErrors ? getTypeOfGlobalSymbol(symbol, arity) : undefined;
37782         }
37783         function getGlobalTypedPropertyDescriptorType() {
37784             return deferredGlobalTypedPropertyDescriptorType || (deferredGlobalTypedPropertyDescriptorType = getGlobalType("TypedPropertyDescriptor", 1, true)) || emptyGenericType;
37785         }
37786         function getGlobalTemplateStringsArrayType() {
37787             return deferredGlobalTemplateStringsArrayType || (deferredGlobalTemplateStringsArrayType = getGlobalType("TemplateStringsArray", 0, true)) || emptyObjectType;
37788         }
37789         function getGlobalImportMetaType() {
37790             return deferredGlobalImportMetaType || (deferredGlobalImportMetaType = getGlobalType("ImportMeta", 0, true)) || emptyObjectType;
37791         }
37792         function getGlobalESSymbolConstructorSymbol(reportErrors) {
37793             return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors));
37794         }
37795         function getGlobalESSymbolType(reportErrors) {
37796             return deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", 0, reportErrors)) || emptyObjectType;
37797         }
37798         function getGlobalPromiseType(reportErrors) {
37799             return deferredGlobalPromiseType || (deferredGlobalPromiseType = getGlobalType("Promise", 1, reportErrors)) || emptyGenericType;
37800         }
37801         function getGlobalPromiseLikeType(reportErrors) {
37802             return deferredGlobalPromiseLikeType || (deferredGlobalPromiseLikeType = getGlobalType("PromiseLike", 1, reportErrors)) || emptyGenericType;
37803         }
37804         function getGlobalPromiseConstructorSymbol(reportErrors) {
37805             return deferredGlobalPromiseConstructorSymbol || (deferredGlobalPromiseConstructorSymbol = getGlobalValueSymbol("Promise", reportErrors));
37806         }
37807         function getGlobalPromiseConstructorLikeType(reportErrors) {
37808             return deferredGlobalPromiseConstructorLikeType || (deferredGlobalPromiseConstructorLikeType = getGlobalType("PromiseConstructorLike", 0, reportErrors)) || emptyObjectType;
37809         }
37810         function getGlobalAsyncIterableType(reportErrors) {
37811             return deferredGlobalAsyncIterableType || (deferredGlobalAsyncIterableType = getGlobalType("AsyncIterable", 1, reportErrors)) || emptyGenericType;
37812         }
37813         function getGlobalAsyncIteratorType(reportErrors) {
37814             return deferredGlobalAsyncIteratorType || (deferredGlobalAsyncIteratorType = getGlobalType("AsyncIterator", 3, reportErrors)) || emptyGenericType;
37815         }
37816         function getGlobalAsyncIterableIteratorType(reportErrors) {
37817             return deferredGlobalAsyncIterableIteratorType || (deferredGlobalAsyncIterableIteratorType = getGlobalType("AsyncIterableIterator", 1, reportErrors)) || emptyGenericType;
37818         }
37819         function getGlobalAsyncGeneratorType(reportErrors) {
37820             return deferredGlobalAsyncGeneratorType || (deferredGlobalAsyncGeneratorType = getGlobalType("AsyncGenerator", 3, reportErrors)) || emptyGenericType;
37821         }
37822         function getGlobalIterableType(reportErrors) {
37823             return deferredGlobalIterableType || (deferredGlobalIterableType = getGlobalType("Iterable", 1, reportErrors)) || emptyGenericType;
37824         }
37825         function getGlobalIteratorType(reportErrors) {
37826             return deferredGlobalIteratorType || (deferredGlobalIteratorType = getGlobalType("Iterator", 3, reportErrors)) || emptyGenericType;
37827         }
37828         function getGlobalIterableIteratorType(reportErrors) {
37829             return deferredGlobalIterableIteratorType || (deferredGlobalIterableIteratorType = getGlobalType("IterableIterator", 1, reportErrors)) || emptyGenericType;
37830         }
37831         function getGlobalGeneratorType(reportErrors) {
37832             return deferredGlobalGeneratorType || (deferredGlobalGeneratorType = getGlobalType("Generator", 3, reportErrors)) || emptyGenericType;
37833         }
37834         function getGlobalIteratorYieldResultType(reportErrors) {
37835             return deferredGlobalIteratorYieldResultType || (deferredGlobalIteratorYieldResultType = getGlobalType("IteratorYieldResult", 1, reportErrors)) || emptyGenericType;
37836         }
37837         function getGlobalIteratorReturnResultType(reportErrors) {
37838             return deferredGlobalIteratorReturnResultType || (deferredGlobalIteratorReturnResultType = getGlobalType("IteratorReturnResult", 1, reportErrors)) || emptyGenericType;
37839         }
37840         function getGlobalTypeOrUndefined(name, arity) {
37841             if (arity === void 0) { arity = 0; }
37842             var symbol = getGlobalSymbol(name, 788968, undefined);
37843             return symbol && getTypeOfGlobalSymbol(symbol, arity);
37844         }
37845         function getGlobalExtractSymbol() {
37846             return deferredGlobalExtractSymbol || (deferredGlobalExtractSymbol = getGlobalSymbol("Extract", 524288, ts.Diagnostics.Cannot_find_global_type_0));
37847         }
37848         function getGlobalOmitSymbol() {
37849             return deferredGlobalOmitSymbol || (deferredGlobalOmitSymbol = getGlobalSymbol("Omit", 524288, ts.Diagnostics.Cannot_find_global_type_0));
37850         }
37851         function getGlobalBigIntType(reportErrors) {
37852             return deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", 0, reportErrors)) || emptyObjectType;
37853         }
37854         function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) {
37855             return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType;
37856         }
37857         function createTypedPropertyDescriptorType(propertyType) {
37858             return createTypeFromGenericGlobalType(getGlobalTypedPropertyDescriptorType(), [propertyType]);
37859         }
37860         function createIterableType(iteratedType) {
37861             return createTypeFromGenericGlobalType(getGlobalIterableType(true), [iteratedType]);
37862         }
37863         function createArrayType(elementType, readonly) {
37864             return createTypeFromGenericGlobalType(readonly ? globalReadonlyArrayType : globalArrayType, [elementType]);
37865         }
37866         function getArrayOrTupleTargetType(node) {
37867             var readonly = isReadonlyTypeOperator(node.parent);
37868             if (node.kind === 174 || node.elementTypes.length === 1 && node.elementTypes[0].kind === 177) {
37869                 return readonly ? globalReadonlyArrayType : globalArrayType;
37870             }
37871             var lastElement = ts.lastOrUndefined(node.elementTypes);
37872             var restElement = lastElement && lastElement.kind === 177 ? lastElement : undefined;
37873             var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 176 && n !== restElement; }) + 1;
37874             return getTupleTypeOfArity(node.elementTypes.length, minLength, !!restElement, readonly, undefined);
37875         }
37876         function isDeferredTypeReferenceNode(node, hasDefaultTypeArguments) {
37877             return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 174 ? mayResolveTypeAlias(node.elementType) :
37878                 node.kind === 175 ? ts.some(node.elementTypes, mayResolveTypeAlias) :
37879                     hasDefaultTypeArguments || ts.some(node.typeArguments, mayResolveTypeAlias));
37880         }
37881         function isResolvedByTypeAlias(node) {
37882             var parent = node.parent;
37883             switch (parent.kind) {
37884                 case 182:
37885                 case 169:
37886                 case 178:
37887                 case 179:
37888                 case 185:
37889                 case 180:
37890                 case 184:
37891                 case 174:
37892                 case 175:
37893                     return isResolvedByTypeAlias(parent);
37894                 case 247:
37895                     return true;
37896             }
37897             return false;
37898         }
37899         function mayResolveTypeAlias(node) {
37900             switch (node.kind) {
37901                 case 169:
37902                     return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node.typeName, 788968).flags & 524288);
37903                 case 172:
37904                     return true;
37905                 case 184:
37906                     return node.operator !== 147 && mayResolveTypeAlias(node.type);
37907                 case 182:
37908                 case 176:
37909                 case 299:
37910                 case 297:
37911                 case 298:
37912                 case 294:
37913                     return mayResolveTypeAlias(node.type);
37914                 case 177:
37915                     return node.type.kind !== 174 || mayResolveTypeAlias(node.type.elementType);
37916                 case 178:
37917                 case 179:
37918                     return ts.some(node.types, mayResolveTypeAlias);
37919                 case 185:
37920                     return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType);
37921                 case 180:
37922                     return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) ||
37923                         mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType);
37924             }
37925             return false;
37926         }
37927         function getTypeFromArrayOrTupleTypeNode(node) {
37928             var links = getNodeLinks(node);
37929             if (!links.resolvedType) {
37930                 var target = getArrayOrTupleTargetType(node);
37931                 if (target === emptyGenericType) {
37932                     links.resolvedType = emptyObjectType;
37933                 }
37934                 else if (isDeferredTypeReferenceNode(node)) {
37935                     links.resolvedType = node.kind === 175 && node.elementTypes.length === 0 ? target :
37936                         createDeferredTypeReference(target, node, undefined);
37937                 }
37938                 else {
37939                     var elementTypes = node.kind === 174 ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elementTypes, getTypeFromTypeNode);
37940                     links.resolvedType = createTypeReference(target, elementTypes);
37941                 }
37942             }
37943             return links.resolvedType;
37944         }
37945         function isReadonlyTypeOperator(node) {
37946             return ts.isTypeOperatorNode(node) && node.operator === 138;
37947         }
37948         function createTupleTypeOfArity(arity, minLength, hasRestElement, readonly, associatedNames) {
37949             var typeParameters;
37950             var properties = [];
37951             var maxLength = hasRestElement ? arity - 1 : arity;
37952             if (arity) {
37953                 typeParameters = new Array(arity);
37954                 for (var i = 0; i < arity; i++) {
37955                     var typeParameter = typeParameters[i] = createTypeParameter();
37956                     if (i < maxLength) {
37957                         var property = createSymbol(4 | (i >= minLength ? 16777216 : 0), "" + i, readonly ? 8 : 0);
37958                         property.type = typeParameter;
37959                         properties.push(property);
37960                     }
37961                 }
37962             }
37963             var literalTypes = [];
37964             for (var i = minLength; i <= maxLength; i++)
37965                 literalTypes.push(getLiteralType(i));
37966             var lengthSymbol = createSymbol(4, "length");
37967             lengthSymbol.type = hasRestElement ? numberType : getUnionType(literalTypes);
37968             properties.push(lengthSymbol);
37969             var type = createObjectType(8 | 4);
37970             type.typeParameters = typeParameters;
37971             type.outerTypeParameters = undefined;
37972             type.localTypeParameters = typeParameters;
37973             type.instantiations = ts.createMap();
37974             type.instantiations.set(getTypeListId(type.typeParameters), type);
37975             type.target = type;
37976             type.resolvedTypeArguments = type.typeParameters;
37977             type.thisType = createTypeParameter();
37978             type.thisType.isThisType = true;
37979             type.thisType.constraint = type;
37980             type.declaredProperties = properties;
37981             type.declaredCallSignatures = ts.emptyArray;
37982             type.declaredConstructSignatures = ts.emptyArray;
37983             type.declaredStringIndexInfo = undefined;
37984             type.declaredNumberIndexInfo = undefined;
37985             type.minLength = minLength;
37986             type.hasRestElement = hasRestElement;
37987             type.readonly = readonly;
37988             type.associatedNames = associatedNames;
37989             return type;
37990         }
37991         function getTupleTypeOfArity(arity, minLength, hasRestElement, readonly, associatedNames) {
37992             var key = arity + (hasRestElement ? "+" : ",") + minLength + (readonly ? "R" : "") + (associatedNames && associatedNames.length ? "," + associatedNames.join(",") : "");
37993             var type = tupleTypes.get(key);
37994             if (!type) {
37995                 tupleTypes.set(key, type = createTupleTypeOfArity(arity, minLength, hasRestElement, readonly, associatedNames));
37996             }
37997             return type;
37998         }
37999         function createTupleType(elementTypes, minLength, hasRestElement, readonly, associatedNames) {
38000             if (minLength === void 0) { minLength = elementTypes.length; }
38001             if (hasRestElement === void 0) { hasRestElement = false; }
38002             if (readonly === void 0) { readonly = false; }
38003             var arity = elementTypes.length;
38004             if (arity === 1 && hasRestElement) {
38005                 return createArrayType(elementTypes[0], readonly);
38006             }
38007             var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, readonly, associatedNames);
38008             return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType;
38009         }
38010         function sliceTupleType(type, index) {
38011             var tuple = type.target;
38012             if (tuple.hasRestElement) {
38013                 index = Math.min(index, getTypeReferenceArity(type) - 1);
38014             }
38015             return createTupleType(getTypeArguments(type).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index));
38016         }
38017         function getTypeFromOptionalTypeNode(node) {
38018             var type = getTypeFromTypeNode(node.type);
38019             return strictNullChecks ? getOptionalType(type) : type;
38020         }
38021         function getTypeId(type) {
38022             return type.id;
38023         }
38024         function containsType(types, type) {
38025             return ts.binarySearch(types, type, getTypeId, ts.compareValues) >= 0;
38026         }
38027         function insertType(types, type) {
38028             var index = ts.binarySearch(types, type, getTypeId, ts.compareValues);
38029             if (index < 0) {
38030                 types.splice(~index, 0, type);
38031                 return true;
38032             }
38033             return false;
38034         }
38035         function addTypeToUnion(typeSet, includes, type) {
38036             var flags = type.flags;
38037             if (flags & 1048576) {
38038                 return addTypesToUnion(typeSet, includes, type.types);
38039             }
38040             if (!(flags & 131072)) {
38041                 includes |= flags & 71041023;
38042                 if (flags & 66846720)
38043                     includes |= 262144;
38044                 if (type === wildcardType)
38045                     includes |= 8388608;
38046                 if (!strictNullChecks && flags & 98304) {
38047                     if (!(ts.getObjectFlags(type) & 524288))
38048                         includes |= 4194304;
38049                 }
38050                 else {
38051                     var len = typeSet.length;
38052                     var index = len && type.id > typeSet[len - 1].id ? ~len : ts.binarySearch(typeSet, type, getTypeId, ts.compareValues);
38053                     if (index < 0) {
38054                         typeSet.splice(~index, 0, type);
38055                     }
38056                 }
38057             }
38058             return includes;
38059         }
38060         function addTypesToUnion(typeSet, includes, types) {
38061             for (var _i = 0, types_9 = types; _i < types_9.length; _i++) {
38062                 var type = types_9[_i];
38063                 includes = addTypeToUnion(typeSet, includes, type);
38064             }
38065             return includes;
38066         }
38067         function isSetOfLiteralsFromSameEnum(types) {
38068             var first = types[0];
38069             if (first.flags & 1024) {
38070                 var firstEnum = getParentOfSymbol(first.symbol);
38071                 for (var i = 1; i < types.length; i++) {
38072                     var other = types[i];
38073                     if (!(other.flags & 1024) || (firstEnum !== getParentOfSymbol(other.symbol))) {
38074                         return false;
38075                     }
38076                 }
38077                 return true;
38078             }
38079             return false;
38080         }
38081         function removeSubtypes(types, primitivesOnly) {
38082             var len = types.length;
38083             if (len === 0 || isSetOfLiteralsFromSameEnum(types)) {
38084                 return true;
38085             }
38086             var i = len;
38087             var count = 0;
38088             while (i > 0) {
38089                 i--;
38090                 var source = types[i];
38091                 for (var _i = 0, types_10 = types; _i < types_10.length; _i++) {
38092                     var target = types_10[_i];
38093                     if (source !== target) {
38094                         if (count === 100000) {
38095                             var estimatedCount = (count / (len - i)) * len;
38096                             if (estimatedCount > (primitivesOnly ? 25000000 : 1000000)) {
38097                                 error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
38098                                 return false;
38099                             }
38100                         }
38101                         count++;
38102                         if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1) ||
38103                             !(ts.getObjectFlags(getTargetType(target)) & 1) ||
38104                             isTypeDerivedFrom(source, target))) {
38105                             ts.orderedRemoveItemAt(types, i);
38106                             break;
38107                         }
38108                     }
38109                 }
38110             }
38111             return true;
38112         }
38113         function removeRedundantLiteralTypes(types, includes) {
38114             var i = types.length;
38115             while (i > 0) {
38116                 i--;
38117                 var t = types[i];
38118                 var remove = t.flags & 128 && includes & 4 ||
38119                     t.flags & 256 && includes & 8 ||
38120                     t.flags & 2048 && includes & 64 ||
38121                     t.flags & 8192 && includes & 4096 ||
38122                     isFreshLiteralType(t) && containsType(types, t.regularType);
38123                 if (remove) {
38124                     ts.orderedRemoveItemAt(types, i);
38125                 }
38126             }
38127         }
38128         function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments) {
38129             if (unionReduction === void 0) { unionReduction = 1; }
38130             if (types.length === 0) {
38131                 return neverType;
38132             }
38133             if (types.length === 1) {
38134                 return types[0];
38135             }
38136             var typeSet = [];
38137             var includes = addTypesToUnion(typeSet, 0, types);
38138             if (unionReduction !== 0) {
38139                 if (includes & 3) {
38140                     return includes & 1 ? includes & 8388608 ? wildcardType : anyType : unknownType;
38141                 }
38142                 switch (unionReduction) {
38143                     case 1:
38144                         if (includes & (2944 | 8192)) {
38145                             removeRedundantLiteralTypes(typeSet, includes);
38146                         }
38147                         break;
38148                     case 2:
38149                         if (!removeSubtypes(typeSet, !(includes & 262144))) {
38150                             return errorType;
38151                         }
38152                         break;
38153                 }
38154                 if (typeSet.length === 0) {
38155                     return includes & 65536 ? includes & 4194304 ? nullType : nullWideningType :
38156                         includes & 32768 ? includes & 4194304 ? undefinedType : undefinedWideningType :
38157                             neverType;
38158                 }
38159             }
38160             var objectFlags = (includes & 66994211 ? 0 : 262144) |
38161                 (includes & 2097152 ? 268435456 : 0);
38162             return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments);
38163         }
38164         function getUnionTypePredicate(signatures) {
38165             var first;
38166             var types = [];
38167             for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) {
38168                 var sig = signatures_6[_i];
38169                 var pred = getTypePredicateOfSignature(sig);
38170                 if (!pred || pred.kind === 2 || pred.kind === 3) {
38171                     continue;
38172                 }
38173                 if (first) {
38174                     if (!typePredicateKindsMatch(first, pred)) {
38175                         return undefined;
38176                     }
38177                 }
38178                 else {
38179                     first = pred;
38180                 }
38181                 types.push(pred.type);
38182             }
38183             if (!first) {
38184                 return undefined;
38185             }
38186             var unionType = getUnionType(types);
38187             return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType);
38188         }
38189         function typePredicateKindsMatch(a, b) {
38190             return a.kind === b.kind && a.parameterIndex === b.parameterIndex;
38191         }
38192         function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments) {
38193             if (types.length === 0) {
38194                 return neverType;
38195             }
38196             if (types.length === 1) {
38197                 return types[0];
38198             }
38199             var id = getTypeListId(types);
38200             var type = unionTypes.get(id);
38201             if (!type) {
38202                 type = createType(1048576);
38203                 unionTypes.set(id, type);
38204                 type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, 98304);
38205                 type.types = types;
38206                 type.aliasSymbol = aliasSymbol;
38207                 type.aliasTypeArguments = aliasTypeArguments;
38208             }
38209             return type;
38210         }
38211         function getTypeFromUnionTypeNode(node) {
38212             var links = getNodeLinks(node);
38213             if (!links.resolvedType) {
38214                 var aliasSymbol = getAliasSymbolForTypeNode(node);
38215                 links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
38216             }
38217             return links.resolvedType;
38218         }
38219         function addTypeToIntersection(typeSet, includes, type) {
38220             var flags = type.flags;
38221             if (flags & 2097152) {
38222                 return addTypesToIntersection(typeSet, includes, type.types);
38223             }
38224             if (isEmptyAnonymousObjectType(type)) {
38225                 if (!(includes & 16777216)) {
38226                     includes |= 16777216;
38227                     typeSet.set(type.id.toString(), type);
38228                 }
38229             }
38230             else {
38231                 if (flags & 3) {
38232                     if (type === wildcardType)
38233                         includes |= 8388608;
38234                 }
38235                 else if ((strictNullChecks || !(flags & 98304)) && !typeSet.has(type.id.toString())) {
38236                     if (type.flags & 109440 && includes & 109440) {
38237                         includes |= 67108864;
38238                     }
38239                     typeSet.set(type.id.toString(), type);
38240                 }
38241                 includes |= flags & 71041023;
38242             }
38243             return includes;
38244         }
38245         function addTypesToIntersection(typeSet, includes, types) {
38246             for (var _i = 0, types_11 = types; _i < types_11.length; _i++) {
38247                 var type = types_11[_i];
38248                 includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type));
38249             }
38250             return includes;
38251         }
38252         function removeRedundantPrimitiveTypes(types, includes) {
38253             var i = types.length;
38254             while (i > 0) {
38255                 i--;
38256                 var t = types[i];
38257                 var remove = t.flags & 4 && includes & 128 ||
38258                     t.flags & 8 && includes & 256 ||
38259                     t.flags & 64 && includes & 2048 ||
38260                     t.flags & 4096 && includes & 8192;
38261                 if (remove) {
38262                     ts.orderedRemoveItemAt(types, i);
38263                 }
38264             }
38265         }
38266         function eachUnionContains(unionTypes, type) {
38267             for (var _i = 0, unionTypes_1 = unionTypes; _i < unionTypes_1.length; _i++) {
38268                 var u = unionTypes_1[_i];
38269                 if (!containsType(u.types, type)) {
38270                     var primitive = type.flags & 128 ? stringType :
38271                         type.flags & 256 ? numberType :
38272                             type.flags & 2048 ? bigintType :
38273                                 type.flags & 8192 ? esSymbolType :
38274                                     undefined;
38275                     if (!primitive || !containsType(u.types, primitive)) {
38276                         return false;
38277                     }
38278                 }
38279             }
38280             return true;
38281         }
38282         function extractIrreducible(types, flag) {
38283             if (ts.every(types, function (t) { return !!(t.flags & 1048576) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); })) {
38284                 for (var i = 0; i < types.length; i++) {
38285                     types[i] = filterType(types[i], function (t) { return !(t.flags & flag); });
38286                 }
38287                 return true;
38288             }
38289             return false;
38290         }
38291         function intersectUnionsOfPrimitiveTypes(types) {
38292             var unionTypes;
38293             var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 262144); });
38294             if (index < 0) {
38295                 return false;
38296             }
38297             var i = index + 1;
38298             while (i < types.length) {
38299                 var t = types[i];
38300                 if (ts.getObjectFlags(t) & 262144) {
38301                     (unionTypes || (unionTypes = [types[index]])).push(t);
38302                     ts.orderedRemoveItemAt(types, i);
38303                 }
38304                 else {
38305                     i++;
38306                 }
38307             }
38308             if (!unionTypes) {
38309                 return false;
38310             }
38311             var checked = [];
38312             var result = [];
38313             for (var _i = 0, unionTypes_2 = unionTypes; _i < unionTypes_2.length; _i++) {
38314                 var u = unionTypes_2[_i];
38315                 for (var _a = 0, _b = u.types; _a < _b.length; _a++) {
38316                     var t = _b[_a];
38317                     if (insertType(checked, t)) {
38318                         if (eachUnionContains(unionTypes, t)) {
38319                             insertType(result, t);
38320                         }
38321                     }
38322                 }
38323             }
38324             types[index] = getUnionTypeFromSortedList(result, 262144);
38325             return true;
38326         }
38327         function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
38328             var result = createType(2097152);
38329             result.objectFlags = getPropagatingFlagsOfTypes(types, 98304);
38330             result.types = types;
38331             result.aliasSymbol = aliasSymbol;
38332             result.aliasTypeArguments = aliasTypeArguments;
38333             return result;
38334         }
38335         function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
38336             var typeMembershipMap = ts.createMap();
38337             var includes = addTypesToIntersection(typeMembershipMap, 0, types);
38338             var typeSet = ts.arrayFrom(typeMembershipMap.values());
38339             if (includes & 131072 ||
38340                 strictNullChecks && includes & 98304 && includes & (524288 | 67108864 | 16777216) ||
38341                 includes & 67108864 && includes & (67238908 & ~67108864) ||
38342                 includes & 132 && includes & (67238908 & ~132) ||
38343                 includes & 296 && includes & (67238908 & ~296) ||
38344                 includes & 2112 && includes & (67238908 & ~2112) ||
38345                 includes & 12288 && includes & (67238908 & ~12288) ||
38346                 includes & 49152 && includes & (67238908 & ~49152)) {
38347                 return neverType;
38348             }
38349             if (includes & 1) {
38350                 return includes & 8388608 ? wildcardType : anyType;
38351             }
38352             if (!strictNullChecks && includes & 98304) {
38353                 return includes & 32768 ? undefinedType : nullType;
38354             }
38355             if (includes & 4 && includes & 128 ||
38356                 includes & 8 && includes & 256 ||
38357                 includes & 64 && includes & 2048 ||
38358                 includes & 4096 && includes & 8192) {
38359                 removeRedundantPrimitiveTypes(typeSet, includes);
38360             }
38361             if (includes & 16777216 && includes & 524288) {
38362                 ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType));
38363             }
38364             if (typeSet.length === 0) {
38365                 return unknownType;
38366             }
38367             if (typeSet.length === 1) {
38368                 return typeSet[0];
38369             }
38370             var id = getTypeListId(typeSet);
38371             var result = intersectionTypes.get(id);
38372             if (!result) {
38373                 if (includes & 1048576) {
38374                     if (intersectUnionsOfPrimitiveTypes(typeSet)) {
38375                         result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
38376                     }
38377                     else if (extractIrreducible(typeSet, 32768)) {
38378                         result = getUnionType([getIntersectionType(typeSet), undefinedType], 1, aliasSymbol, aliasTypeArguments);
38379                     }
38380                     else if (extractIrreducible(typeSet, 65536)) {
38381                         result = getUnionType([getIntersectionType(typeSet), nullType], 1, aliasSymbol, aliasTypeArguments);
38382                     }
38383                     else {
38384                         var size = ts.reduceLeft(typeSet, function (n, t) { return n * (t.flags & 1048576 ? t.types.length : 1); }, 1);
38385                         if (size >= 100000) {
38386                             error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
38387                             return errorType;
38388                         }
38389                         var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 1048576) !== 0; });
38390                         var unionType = typeSet[unionIndex_1];
38391                         result = getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1, aliasSymbol, aliasTypeArguments);
38392                     }
38393                 }
38394                 else {
38395                     result = createIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
38396                 }
38397                 intersectionTypes.set(id, result);
38398             }
38399             return result;
38400         }
38401         function getTypeFromIntersectionTypeNode(node) {
38402             var links = getNodeLinks(node);
38403             if (!links.resolvedType) {
38404                 var aliasSymbol = getAliasSymbolForTypeNode(node);
38405                 links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
38406             }
38407             return links.resolvedType;
38408         }
38409         function createIndexType(type, stringsOnly) {
38410             var result = createType(4194304);
38411             result.type = type;
38412             result.stringsOnly = stringsOnly;
38413             return result;
38414         }
38415         function getIndexTypeForGenericType(type, stringsOnly) {
38416             return stringsOnly ?
38417                 type.resolvedStringIndexType || (type.resolvedStringIndexType = createIndexType(type, true)) :
38418                 type.resolvedIndexType || (type.resolvedIndexType = createIndexType(type, false));
38419         }
38420         function getLiteralTypeFromPropertyName(name) {
38421             if (ts.isPrivateIdentifier(name)) {
38422                 return neverType;
38423             }
38424             return ts.isIdentifier(name) ? getLiteralType(ts.unescapeLeadingUnderscores(name.escapedText)) :
38425                 getRegularTypeOfLiteralType(ts.isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name));
38426         }
38427         function getBigIntLiteralType(node) {
38428             return getLiteralType({
38429                 negative: false,
38430                 base10Value: ts.parsePseudoBigInt(node.text)
38431             });
38432         }
38433         function getLiteralTypeFromProperty(prop, include) {
38434             if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24)) {
38435                 var type = getSymbolLinks(getLateBoundSymbol(prop)).nameType;
38436                 if (!type && !ts.isKnownSymbol(prop)) {
38437                     if (prop.escapedName === "default") {
38438                         type = getLiteralType("default");
38439                     }
38440                     else {
38441                         var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration);
38442                         type = name && getLiteralTypeFromPropertyName(name) || getLiteralType(ts.symbolName(prop));
38443                     }
38444                 }
38445                 if (type && type.flags & include) {
38446                     return type;
38447                 }
38448             }
38449             return neverType;
38450         }
38451         function getLiteralTypeFromProperties(type, include) {
38452             return getUnionType(ts.map(getPropertiesOfType(type), function (p) { return getLiteralTypeFromProperty(p, include); }));
38453         }
38454         function getNonEnumNumberIndexInfo(type) {
38455             var numberIndexInfo = getIndexInfoOfType(type, 1);
38456             return numberIndexInfo !== enumNumberIndexInfo ? numberIndexInfo : undefined;
38457         }
38458         function getIndexType(type, stringsOnly, noIndexSignatures) {
38459             if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; }
38460             type = getReducedType(type);
38461             return type.flags & 1048576 ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
38462                 type.flags & 2097152 ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
38463                     maybeTypeOfKind(type, 58982400) ? getIndexTypeForGenericType(type, stringsOnly) :
38464                         ts.getObjectFlags(type) & 32 ? filterType(getConstraintTypeFromMappedType(type), function (t) { return !(noIndexSignatures && t.flags & (1 | 4)); }) :
38465                             type === wildcardType ? wildcardType :
38466                                 type.flags & 2 ? neverType :
38467                                     type.flags & (1 | 131072) ? keyofConstraintType :
38468                                         stringsOnly ? !noIndexSignatures && getIndexInfoOfType(type, 0) ? stringType : getLiteralTypeFromProperties(type, 128) :
38469                                             !noIndexSignatures && getIndexInfoOfType(type, 0) ? getUnionType([stringType, numberType, getLiteralTypeFromProperties(type, 8192)]) :
38470                                                 getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromProperties(type, 128 | 8192)]) :
38471                                                     getLiteralTypeFromProperties(type, 8576);
38472         }
38473         function getExtractStringType(type) {
38474             if (keyofStringsOnly) {
38475                 return type;
38476             }
38477             var extractTypeAlias = getGlobalExtractSymbol();
38478             return extractTypeAlias ? getTypeAliasInstantiation(extractTypeAlias, [type, stringType]) : stringType;
38479         }
38480         function getIndexTypeOrString(type) {
38481             var indexType = getExtractStringType(getIndexType(type));
38482             return indexType.flags & 131072 ? stringType : indexType;
38483         }
38484         function getTypeFromTypeOperatorNode(node) {
38485             var links = getNodeLinks(node);
38486             if (!links.resolvedType) {
38487                 switch (node.operator) {
38488                     case 134:
38489                         links.resolvedType = getIndexType(getTypeFromTypeNode(node.type));
38490                         break;
38491                     case 147:
38492                         links.resolvedType = node.type.kind === 144
38493                             ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent))
38494                             : errorType;
38495                         break;
38496                     case 138:
38497                         links.resolvedType = getTypeFromTypeNode(node.type);
38498                         break;
38499                     default:
38500                         throw ts.Debug.assertNever(node.operator);
38501                 }
38502             }
38503             return links.resolvedType;
38504         }
38505         function createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments) {
38506             var type = createType(8388608);
38507             type.objectType = objectType;
38508             type.indexType = indexType;
38509             type.aliasSymbol = aliasSymbol;
38510             type.aliasTypeArguments = aliasTypeArguments;
38511             return type;
38512         }
38513         function isJSLiteralType(type) {
38514             if (noImplicitAny) {
38515                 return false;
38516             }
38517             if (ts.getObjectFlags(type) & 16384) {
38518                 return true;
38519             }
38520             if (type.flags & 1048576) {
38521                 return ts.every(type.types, isJSLiteralType);
38522             }
38523             if (type.flags & 2097152) {
38524                 return ts.some(type.types, isJSLiteralType);
38525             }
38526             if (type.flags & 63176704) {
38527                 return isJSLiteralType(getResolvedBaseConstraint(type));
38528             }
38529             return false;
38530         }
38531         function getPropertyNameFromIndex(indexType, accessNode) {
38532             var accessExpression = accessNode && accessNode.kind === 195 ? accessNode : undefined;
38533             return isTypeUsableAsPropertyName(indexType) ?
38534                 getPropertyNameFromType(indexType) :
38535                 accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ?
38536                     ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) :
38537                     accessNode && ts.isPropertyName(accessNode) ?
38538                         ts.getPropertyNameForPropertyNameNode(accessNode) :
38539                         undefined;
38540         }
38541         function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) {
38542             var accessExpression = accessNode && accessNode.kind === 195 ? accessNode : undefined;
38543             var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode);
38544             if (propName !== undefined) {
38545                 var prop = getPropertyOfType(objectType, propName);
38546                 if (prop) {
38547                     if (accessExpression) {
38548                         markPropertyAsReferenced(prop, accessExpression, accessExpression.expression.kind === 104);
38549                         if (isAssignmentToReadonlyEntity(accessExpression, prop, ts.getAssignmentTargetKind(accessExpression))) {
38550                             error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop));
38551                             return undefined;
38552                         }
38553                         if (accessFlags & 4) {
38554                             getNodeLinks(accessNode).resolvedSymbol = prop;
38555                         }
38556                     }
38557                     var propType = getTypeOfSymbol(prop);
38558                     return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 ?
38559                         getFlowTypeOfReference(accessExpression, propType) :
38560                         propType;
38561                 }
38562                 if (everyType(objectType, isTupleType) && isNumericLiteralName(propName) && +propName >= 0) {
38563                     if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 8)) {
38564                         var indexNode = getIndexNodeForAccessExpression(accessNode);
38565                         if (isTupleType(objectType)) {
38566                             error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName));
38567                         }
38568                         else {
38569                             error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
38570                         }
38571                     }
38572                     errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, 1));
38573                     return mapType(objectType, function (t) { return getRestTypeOfTupleType(t) || undefinedType; });
38574                 }
38575             }
38576             if (!(indexType.flags & 98304) && isTypeAssignableToKind(indexType, 132 | 296 | 12288)) {
38577                 if (objectType.flags & (1 | 131072)) {
38578                     return objectType;
38579                 }
38580                 var stringIndexInfo = getIndexInfoOfType(objectType, 0);
38581                 var indexInfo = isTypeAssignableToKind(indexType, 296) && getIndexInfoOfType(objectType, 1) || stringIndexInfo;
38582                 if (indexInfo) {
38583                     if (accessFlags & 1 && indexInfo === stringIndexInfo) {
38584                         if (accessExpression) {
38585                             error(accessExpression, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType));
38586                         }
38587                         return undefined;
38588                     }
38589                     if (accessNode && !isTypeAssignableToKind(indexType, 4 | 8)) {
38590                         var indexNode = getIndexNodeForAccessExpression(accessNode);
38591                         error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
38592                         return indexInfo.type;
38593                     }
38594                     errorIfWritingToReadonlyIndex(indexInfo);
38595                     return indexInfo.type;
38596                 }
38597                 if (indexType.flags & 131072) {
38598                     return neverType;
38599                 }
38600                 if (isJSLiteralType(objectType)) {
38601                     return anyType;
38602                 }
38603                 if (accessExpression && !isConstEnumObjectType(objectType)) {
38604                     if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418)) {
38605                         error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
38606                     }
38607                     else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !suppressNoImplicitAnyError) {
38608                         if (propName !== undefined && typeHasStaticProperty(propName, objectType)) {
38609                             error(accessExpression, ts.Diagnostics.Property_0_is_a_static_member_of_type_1, propName, typeToString(objectType));
38610                         }
38611                         else if (getIndexTypeOfType(objectType, 1)) {
38612                             error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number);
38613                         }
38614                         else {
38615                             var suggestion = void 0;
38616                             if (propName !== undefined && (suggestion = getSuggestionForNonexistentProperty(propName, objectType))) {
38617                                 if (suggestion !== undefined) {
38618                                     error(accessExpression.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, propName, typeToString(objectType), suggestion);
38619                                 }
38620                             }
38621                             else {
38622                                 var suggestion_1 = getSuggestionForNonexistentIndexSignature(objectType, accessExpression, indexType);
38623                                 if (suggestion_1 !== undefined) {
38624                                     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);
38625                                 }
38626                                 else {
38627                                     var errorInfo = void 0;
38628                                     if (indexType.flags & 1024) {
38629                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + typeToString(indexType) + "]", typeToString(objectType));
38630                                     }
38631                                     else if (indexType.flags & 8192) {
38632                                         var symbolName_2 = getFullyQualifiedName(indexType.symbol, accessExpression);
38633                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + symbolName_2 + "]", typeToString(objectType));
38634                                     }
38635                                     else if (indexType.flags & 128) {
38636                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
38637                                     }
38638                                     else if (indexType.flags & 256) {
38639                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
38640                                     }
38641                                     else if (indexType.flags & (8 | 4)) {
38642                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1, typeToString(indexType), typeToString(objectType));
38643                                     }
38644                                     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));
38645                                     diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(accessExpression, errorInfo));
38646                                 }
38647                             }
38648                         }
38649                     }
38650                     return undefined;
38651                 }
38652             }
38653             if (isJSLiteralType(objectType)) {
38654                 return anyType;
38655             }
38656             if (accessNode) {
38657                 var indexNode = getIndexNodeForAccessExpression(accessNode);
38658                 if (indexType.flags & (128 | 256)) {
38659                     error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType));
38660                 }
38661                 else if (indexType.flags & (4 | 8)) {
38662                     error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType));
38663                 }
38664                 else {
38665                     error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
38666                 }
38667             }
38668             if (isTypeAny(indexType)) {
38669                 return indexType;
38670             }
38671             return undefined;
38672             function errorIfWritingToReadonlyIndex(indexInfo) {
38673                 if (indexInfo && indexInfo.isReadonly && accessExpression && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) {
38674                     error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
38675                 }
38676             }
38677         }
38678         function getIndexNodeForAccessExpression(accessNode) {
38679             return accessNode.kind === 195 ? accessNode.argumentExpression :
38680                 accessNode.kind === 185 ? accessNode.indexType :
38681                     accessNode.kind === 154 ? accessNode.expression :
38682                         accessNode;
38683         }
38684         function isGenericObjectType(type) {
38685             if (type.flags & 3145728) {
38686                 if (!(type.objectFlags & 4194304)) {
38687                     type.objectFlags |= 4194304 |
38688                         (ts.some(type.types, isGenericObjectType) ? 8388608 : 0);
38689                 }
38690                 return !!(type.objectFlags & 8388608);
38691             }
38692             return !!(type.flags & 58982400) || isGenericMappedType(type);
38693         }
38694         function isGenericIndexType(type) {
38695             if (type.flags & 3145728) {
38696                 if (!(type.objectFlags & 16777216)) {
38697                     type.objectFlags |= 16777216 |
38698                         (ts.some(type.types, isGenericIndexType) ? 33554432 : 0);
38699                 }
38700                 return !!(type.objectFlags & 33554432);
38701             }
38702             return !!(type.flags & (58982400 | 4194304));
38703         }
38704         function isThisTypeParameter(type) {
38705             return !!(type.flags & 262144 && type.isThisType);
38706         }
38707         function getSimplifiedType(type, writing) {
38708             return type.flags & 8388608 ? getSimplifiedIndexedAccessType(type, writing) :
38709                 type.flags & 16777216 ? getSimplifiedConditionalType(type, writing) :
38710                     type;
38711         }
38712         function distributeIndexOverObjectType(objectType, indexType, writing) {
38713             if (objectType.flags & 3145728) {
38714                 var types = ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType), writing); });
38715                 return objectType.flags & 2097152 || writing ? getIntersectionType(types) : getUnionType(types);
38716             }
38717         }
38718         function distributeObjectOverIndexType(objectType, indexType, writing) {
38719             if (indexType.flags & 1048576) {
38720                 var types = ts.map(indexType.types, function (t) { return getSimplifiedType(getIndexedAccessType(objectType, t), writing); });
38721                 return writing ? getIntersectionType(types) : getUnionType(types);
38722             }
38723         }
38724         function unwrapSubstitution(type) {
38725             if (type.flags & 33554432) {
38726                 return type.substitute;
38727             }
38728             return type;
38729         }
38730         function getSimplifiedIndexedAccessType(type, writing) {
38731             var cache = writing ? "simplifiedForWriting" : "simplifiedForReading";
38732             if (type[cache]) {
38733                 return type[cache] === circularConstraintType ? type : type[cache];
38734             }
38735             type[cache] = circularConstraintType;
38736             var objectType = unwrapSubstitution(getSimplifiedType(type.objectType, writing));
38737             var indexType = getSimplifiedType(type.indexType, writing);
38738             var distributedOverIndex = distributeObjectOverIndexType(objectType, indexType, writing);
38739             if (distributedOverIndex) {
38740                 return type[cache] = distributedOverIndex;
38741             }
38742             if (!(indexType.flags & 63176704)) {
38743                 var distributedOverObject = distributeIndexOverObjectType(objectType, indexType, writing);
38744                 if (distributedOverObject) {
38745                     return type[cache] = distributedOverObject;
38746                 }
38747             }
38748             if (isGenericMappedType(objectType)) {
38749                 return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); });
38750             }
38751             return type[cache] = type;
38752         }
38753         function getSimplifiedConditionalType(type, writing) {
38754             var checkType = type.checkType;
38755             var extendsType = type.extendsType;
38756             var trueType = getTrueTypeFromConditionalType(type);
38757             var falseType = getFalseTypeFromConditionalType(type);
38758             if (falseType.flags & 131072 && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) {
38759                 if (checkType.flags & 1 || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) {
38760                     return getSimplifiedType(trueType, writing);
38761                 }
38762                 else if (isIntersectionEmpty(checkType, extendsType)) {
38763                     return neverType;
38764                 }
38765             }
38766             else if (trueType.flags & 131072 && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) {
38767                 if (!(checkType.flags & 1) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) {
38768                     return neverType;
38769                 }
38770                 else if (checkType.flags & 1 || isIntersectionEmpty(checkType, extendsType)) {
38771                     return getSimplifiedType(falseType, writing);
38772                 }
38773             }
38774             return type;
38775         }
38776         function isIntersectionEmpty(type1, type2) {
38777             return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072);
38778         }
38779         function substituteIndexedMappedType(objectType, index) {
38780             var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [index]);
38781             var templateMapper = combineTypeMappers(objectType.mapper, mapper);
38782             return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper);
38783         }
38784         function getIndexedAccessType(objectType, indexType, accessNode, aliasSymbol, aliasTypeArguments) {
38785             return getIndexedAccessTypeOrUndefined(objectType, indexType, accessNode, 0, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType);
38786         }
38787         function getIndexedAccessTypeOrUndefined(objectType, indexType, accessNode, accessFlags, aliasSymbol, aliasTypeArguments) {
38788             if (accessFlags === void 0) { accessFlags = 0; }
38789             if (objectType === wildcardType || indexType === wildcardType) {
38790                 return wildcardType;
38791             }
38792             if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304) && isTypeAssignableToKind(indexType, 4 | 8)) {
38793                 indexType = stringType;
38794             }
38795             if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 185) && isGenericObjectType(objectType)) {
38796                 if (objectType.flags & 3) {
38797                     return objectType;
38798                 }
38799                 var id = objectType.id + "," + indexType.id;
38800                 var type = indexedAccessTypes.get(id);
38801                 if (!type) {
38802                     indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments));
38803                 }
38804                 return type;
38805             }
38806             var apparentObjectType = getReducedApparentType(objectType);
38807             if (indexType.flags & 1048576 && !(indexType.flags & 16)) {
38808                 var propTypes = [];
38809                 var wasMissingProp = false;
38810                 for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) {
38811                     var t = _a[_i];
38812                     var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, wasMissingProp, accessNode, accessFlags);
38813                     if (propType) {
38814                         propTypes.push(propType);
38815                     }
38816                     else if (!accessNode) {
38817                         return undefined;
38818                     }
38819                     else {
38820                         wasMissingProp = true;
38821                     }
38822                 }
38823                 if (wasMissingProp) {
38824                     return undefined;
38825                 }
38826                 return accessFlags & 2 ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments) : getUnionType(propTypes, 1, aliasSymbol, aliasTypeArguments);
38827             }
38828             return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, false, accessNode, accessFlags | 4);
38829         }
38830         function getTypeFromIndexedAccessTypeNode(node) {
38831             var links = getNodeLinks(node);
38832             if (!links.resolvedType) {
38833                 var objectType = getTypeFromTypeNode(node.objectType);
38834                 var indexType = getTypeFromTypeNode(node.indexType);
38835                 var potentialAlias = getAliasSymbolForTypeNode(node);
38836                 var resolved = getIndexedAccessType(objectType, indexType, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias));
38837                 links.resolvedType = resolved.flags & 8388608 &&
38838                     resolved.objectType === objectType &&
38839                     resolved.indexType === indexType ?
38840                     getConditionalFlowTypeOfType(resolved, node) : resolved;
38841             }
38842             return links.resolvedType;
38843         }
38844         function getTypeFromMappedTypeNode(node) {
38845             var links = getNodeLinks(node);
38846             if (!links.resolvedType) {
38847                 var type = createObjectType(32, node.symbol);
38848                 type.declaration = node;
38849                 type.aliasSymbol = getAliasSymbolForTypeNode(node);
38850                 type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(type.aliasSymbol);
38851                 links.resolvedType = type;
38852                 getConstraintTypeFromMappedType(type);
38853             }
38854             return links.resolvedType;
38855         }
38856         function getActualTypeVariable(type) {
38857             if (type.flags & 33554432) {
38858                 return type.baseType;
38859             }
38860             if (type.flags & 8388608 && (type.objectType.flags & 33554432 ||
38861                 type.indexType.flags & 33554432)) {
38862                 return getIndexedAccessType(getActualTypeVariable(type.objectType), getActualTypeVariable(type.indexType));
38863             }
38864             return type;
38865         }
38866         function getConditionalType(root, mapper) {
38867             var result;
38868             var extraTypes;
38869             var _loop_12 = function () {
38870                 var checkType = instantiateType(root.checkType, mapper);
38871                 var checkTypeInstantiable = isGenericObjectType(checkType) || isGenericIndexType(checkType);
38872                 var extendsType = instantiateType(root.extendsType, mapper);
38873                 if (checkType === wildcardType || extendsType === wildcardType) {
38874                     return { value: wildcardType };
38875                 }
38876                 var combinedMapper = void 0;
38877                 if (root.inferTypeParameters) {
38878                     var context = createInferenceContext(root.inferTypeParameters, undefined, 0);
38879                     if (!checkTypeInstantiable || !ts.some(root.inferTypeParameters, function (t) { return t === extendsType; })) {
38880                         inferTypes(context.inferences, checkType, extendsType, 128 | 256);
38881                     }
38882                     combinedMapper = mergeTypeMappers(mapper, context.mapper);
38883                 }
38884                 var inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
38885                 if (!checkTypeInstantiable && !isGenericObjectType(inferredExtendsType) && !isGenericIndexType(inferredExtendsType)) {
38886                     if (!(inferredExtendsType.flags & 3) && (checkType.flags & 1 || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
38887                         if (checkType.flags & 1) {
38888                             (extraTypes || (extraTypes = [])).push(instantiateTypeWithoutDepthIncrease(root.trueType, combinedMapper || mapper));
38889                         }
38890                         var falseType_1 = root.falseType;
38891                         if (falseType_1.flags & 16777216) {
38892                             var newRoot = falseType_1.root;
38893                             if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
38894                                 root = newRoot;
38895                                 return "continue";
38896                             }
38897                         }
38898                         result = instantiateTypeWithoutDepthIncrease(falseType_1, mapper);
38899                         return "break";
38900                     }
38901                     if (inferredExtendsType.flags & 3 || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) {
38902                         result = instantiateTypeWithoutDepthIncrease(root.trueType, combinedMapper || mapper);
38903                         return "break";
38904                     }
38905                 }
38906                 var erasedCheckType = getActualTypeVariable(checkType);
38907                 result = createType(16777216);
38908                 result.root = root;
38909                 result.checkType = erasedCheckType;
38910                 result.extendsType = extendsType;
38911                 result.mapper = mapper;
38912                 result.combinedMapper = combinedMapper;
38913                 result.aliasSymbol = root.aliasSymbol;
38914                 result.aliasTypeArguments = instantiateTypes(root.aliasTypeArguments, mapper);
38915                 return "break";
38916             };
38917             while (true) {
38918                 var state_4 = _loop_12();
38919                 if (typeof state_4 === "object")
38920                     return state_4.value;
38921                 if (state_4 === "break")
38922                     break;
38923             }
38924             return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
38925         }
38926         function getTrueTypeFromConditionalType(type) {
38927             return type.resolvedTrueType || (type.resolvedTrueType = instantiateType(type.root.trueType, type.mapper));
38928         }
38929         function getFalseTypeFromConditionalType(type) {
38930             return type.resolvedFalseType || (type.resolvedFalseType = instantiateType(type.root.falseType, type.mapper));
38931         }
38932         function getInferredTrueTypeFromConditionalType(type) {
38933             return type.resolvedInferredTrueType || (type.resolvedInferredTrueType = type.combinedMapper ? instantiateType(type.root.trueType, type.combinedMapper) : getTrueTypeFromConditionalType(type));
38934         }
38935         function getInferTypeParameters(node) {
38936             var result;
38937             if (node.locals) {
38938                 node.locals.forEach(function (symbol) {
38939                     if (symbol.flags & 262144) {
38940                         result = ts.append(result, getDeclaredTypeOfSymbol(symbol));
38941                     }
38942                 });
38943             }
38944             return result;
38945         }
38946         function getTypeFromConditionalTypeNode(node) {
38947             var links = getNodeLinks(node);
38948             if (!links.resolvedType) {
38949                 var checkType = getTypeFromTypeNode(node.checkType);
38950                 var aliasSymbol = getAliasSymbolForTypeNode(node);
38951                 var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
38952                 var allOuterTypeParameters = getOuterTypeParameters(node, true);
38953                 var outerTypeParameters = aliasTypeArguments ? allOuterTypeParameters : ts.filter(allOuterTypeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, node); });
38954                 var root = {
38955                     node: node,
38956                     checkType: checkType,
38957                     extendsType: getTypeFromTypeNode(node.extendsType),
38958                     trueType: getTypeFromTypeNode(node.trueType),
38959                     falseType: getTypeFromTypeNode(node.falseType),
38960                     isDistributive: !!(checkType.flags & 262144),
38961                     inferTypeParameters: getInferTypeParameters(node),
38962                     outerTypeParameters: outerTypeParameters,
38963                     instantiations: undefined,
38964                     aliasSymbol: aliasSymbol,
38965                     aliasTypeArguments: aliasTypeArguments
38966                 };
38967                 links.resolvedType = getConditionalType(root, undefined);
38968                 if (outerTypeParameters) {
38969                     root.instantiations = ts.createMap();
38970                     root.instantiations.set(getTypeListId(outerTypeParameters), links.resolvedType);
38971                 }
38972             }
38973             return links.resolvedType;
38974         }
38975         function getTypeFromInferTypeNode(node) {
38976             var links = getNodeLinks(node);
38977             if (!links.resolvedType) {
38978                 links.resolvedType = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter));
38979             }
38980             return links.resolvedType;
38981         }
38982         function getIdentifierChain(node) {
38983             if (ts.isIdentifier(node)) {
38984                 return [node];
38985             }
38986             else {
38987                 return ts.append(getIdentifierChain(node.left), node.right);
38988             }
38989         }
38990         function getTypeFromImportTypeNode(node) {
38991             var links = getNodeLinks(node);
38992             if (!links.resolvedType) {
38993                 if (node.isTypeOf && node.typeArguments) {
38994                     error(node, ts.Diagnostics.Type_arguments_cannot_be_used_here);
38995                     links.resolvedSymbol = unknownSymbol;
38996                     return links.resolvedType = errorType;
38997                 }
38998                 if (!ts.isLiteralImportTypeNode(node)) {
38999                     error(node.argument, ts.Diagnostics.String_literal_expected);
39000                     links.resolvedSymbol = unknownSymbol;
39001                     return links.resolvedType = errorType;
39002                 }
39003                 var targetMeaning = node.isTypeOf ? 111551 : node.flags & 4194304 ? 111551 | 788968 : 788968;
39004                 var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal);
39005                 if (!innerModuleSymbol) {
39006                     links.resolvedSymbol = unknownSymbol;
39007                     return links.resolvedType = errorType;
39008                 }
39009                 var moduleSymbol = resolveExternalModuleSymbol(innerModuleSymbol, false);
39010                 if (!ts.nodeIsMissing(node.qualifier)) {
39011                     var nameStack = getIdentifierChain(node.qualifier);
39012                     var currentNamespace = moduleSymbol;
39013                     var current = void 0;
39014                     while (current = nameStack.shift()) {
39015                         var meaning = nameStack.length ? 1920 : targetMeaning;
39016                         var next = getSymbol(getExportsOfSymbol(getMergedSymbol(resolveSymbol(currentNamespace))), current.escapedText, meaning);
39017                         if (!next) {
39018                             error(current, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), ts.declarationNameToString(current));
39019                             return links.resolvedType = errorType;
39020                         }
39021                         getNodeLinks(current).resolvedSymbol = next;
39022                         getNodeLinks(current.parent).resolvedSymbol = next;
39023                         currentNamespace = next;
39024                     }
39025                     links.resolvedType = resolveImportSymbolType(node, links, currentNamespace, targetMeaning);
39026                 }
39027                 else {
39028                     if (moduleSymbol.flags & targetMeaning) {
39029                         links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning);
39030                     }
39031                     else {
39032                         var errorMessage = targetMeaning === 111551
39033                             ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here
39034                             : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0;
39035                         error(node, errorMessage, node.argument.literal.text);
39036                         links.resolvedSymbol = unknownSymbol;
39037                         links.resolvedType = errorType;
39038                     }
39039                 }
39040             }
39041             return links.resolvedType;
39042         }
39043         function resolveImportSymbolType(node, links, symbol, meaning) {
39044             var resolvedSymbol = resolveSymbol(symbol);
39045             links.resolvedSymbol = resolvedSymbol;
39046             if (meaning === 111551) {
39047                 return getTypeOfSymbol(symbol);
39048             }
39049             else {
39050                 return getTypeReferenceType(node, resolvedSymbol);
39051             }
39052         }
39053         function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) {
39054             var links = getNodeLinks(node);
39055             if (!links.resolvedType) {
39056                 var aliasSymbol = getAliasSymbolForTypeNode(node);
39057                 if (getMembersOfSymbol(node.symbol).size === 0 && !aliasSymbol) {
39058                     links.resolvedType = emptyTypeLiteralType;
39059                 }
39060                 else {
39061                     var type = createObjectType(16, node.symbol);
39062                     type.aliasSymbol = aliasSymbol;
39063                     type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
39064                     if (ts.isJSDocTypeLiteral(node) && node.isArrayType) {
39065                         type = createArrayType(type);
39066                     }
39067                     links.resolvedType = type;
39068                 }
39069             }
39070             return links.resolvedType;
39071         }
39072         function getAliasSymbolForTypeNode(node) {
39073             var host = node.parent;
39074             while (ts.isParenthesizedTypeNode(host) || ts.isTypeOperatorNode(host) && host.operator === 138) {
39075                 host = host.parent;
39076             }
39077             return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined;
39078         }
39079         function getTypeArgumentsForAliasSymbol(symbol) {
39080             return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined;
39081         }
39082         function isNonGenericObjectType(type) {
39083             return !!(type.flags & 524288) && !isGenericMappedType(type);
39084         }
39085         function isEmptyObjectTypeOrSpreadsIntoEmptyObject(type) {
39086             return isEmptyObjectType(type) || !!(type.flags & (65536 | 32768 | 528 | 296 | 2112 | 132 | 1056 | 67108864 | 4194304));
39087         }
39088         function isSinglePropertyAnonymousObjectType(type) {
39089             return !!(type.flags & 524288) &&
39090                 !!(ts.getObjectFlags(type) & 16) &&
39091                 (ts.length(getPropertiesOfType(type)) === 1 || ts.every(getPropertiesOfType(type), function (p) { return !!(p.flags & 16777216); }));
39092         }
39093         function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) {
39094             if (type.types.length === 2) {
39095                 var firstType = type.types[0];
39096                 var secondType = type.types[1];
39097                 if (ts.every(type.types, isEmptyObjectTypeOrSpreadsIntoEmptyObject)) {
39098                     return isEmptyObjectType(firstType) ? firstType : isEmptyObjectType(secondType) ? secondType : emptyObjectType;
39099                 }
39100                 if (isEmptyObjectTypeOrSpreadsIntoEmptyObject(firstType) && isSinglePropertyAnonymousObjectType(secondType)) {
39101                     return getAnonymousPartialType(secondType);
39102                 }
39103                 if (isEmptyObjectTypeOrSpreadsIntoEmptyObject(secondType) && isSinglePropertyAnonymousObjectType(firstType)) {
39104                     return getAnonymousPartialType(firstType);
39105                 }
39106             }
39107             function getAnonymousPartialType(type) {
39108                 var members = ts.createSymbolTable();
39109                 for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) {
39110                     var prop = _a[_i];
39111                     if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16)) {
39112                     }
39113                     else if (isSpreadableProperty(prop)) {
39114                         var isSetonlyAccessor = prop.flags & 65536 && !(prop.flags & 32768);
39115                         var flags = 4 | 16777216;
39116                         var result = createSymbol(flags, prop.escapedName, readonly ? 8 : 0);
39117                         result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop);
39118                         result.declarations = prop.declarations;
39119                         result.nameType = getSymbolLinks(prop).nameType;
39120                         result.syntheticOrigin = prop;
39121                         members.set(prop.escapedName, result);
39122                     }
39123                 }
39124                 var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoOfType(type, 0), getIndexInfoOfType(type, 1));
39125                 spread.objectFlags |= 128 | 1048576;
39126                 return spread;
39127             }
39128         }
39129         function getSpreadType(left, right, symbol, objectFlags, readonly) {
39130             if (left.flags & 1 || right.flags & 1) {
39131                 return anyType;
39132             }
39133             if (left.flags & 2 || right.flags & 2) {
39134                 return unknownType;
39135             }
39136             if (left.flags & 131072) {
39137                 return right;
39138             }
39139             if (right.flags & 131072) {
39140                 return left;
39141             }
39142             if (left.flags & 1048576) {
39143                 var merged = tryMergeUnionOfObjectTypeAndEmptyObject(left, readonly);
39144                 if (merged) {
39145                     return getSpreadType(merged, right, symbol, objectFlags, readonly);
39146                 }
39147                 return mapType(left, function (t) { return getSpreadType(t, right, symbol, objectFlags, readonly); });
39148             }
39149             if (right.flags & 1048576) {
39150                 var merged = tryMergeUnionOfObjectTypeAndEmptyObject(right, readonly);
39151                 if (merged) {
39152                     return getSpreadType(left, merged, symbol, objectFlags, readonly);
39153                 }
39154                 return mapType(right, function (t) { return getSpreadType(left, t, symbol, objectFlags, readonly); });
39155             }
39156             if (right.flags & (528 | 296 | 2112 | 132 | 1056 | 67108864 | 4194304)) {
39157                 return left;
39158             }
39159             if (isGenericObjectType(left) || isGenericObjectType(right)) {
39160                 if (isEmptyObjectType(left)) {
39161                     return right;
39162                 }
39163                 if (left.flags & 2097152) {
39164                     var types = left.types;
39165                     var lastLeft = types[types.length - 1];
39166                     if (isNonGenericObjectType(lastLeft) && isNonGenericObjectType(right)) {
39167                         return getIntersectionType(ts.concatenate(types.slice(0, types.length - 1), [getSpreadType(lastLeft, right, symbol, objectFlags, readonly)]));
39168                     }
39169                 }
39170                 return getIntersectionType([left, right]);
39171             }
39172             var members = ts.createSymbolTable();
39173             var skippedPrivateMembers = ts.createUnderscoreEscapedMap();
39174             var stringIndexInfo;
39175             var numberIndexInfo;
39176             if (left === emptyObjectType) {
39177                 stringIndexInfo = getIndexInfoOfType(right, 0);
39178                 numberIndexInfo = getIndexInfoOfType(right, 1);
39179             }
39180             else {
39181                 stringIndexInfo = unionSpreadIndexInfos(getIndexInfoOfType(left, 0), getIndexInfoOfType(right, 0));
39182                 numberIndexInfo = unionSpreadIndexInfos(getIndexInfoOfType(left, 1), getIndexInfoOfType(right, 1));
39183             }
39184             for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) {
39185                 var rightProp = _a[_i];
39186                 if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 | 16)) {
39187                     skippedPrivateMembers.set(rightProp.escapedName, true);
39188                 }
39189                 else if (isSpreadableProperty(rightProp)) {
39190                     members.set(rightProp.escapedName, getSpreadSymbol(rightProp, readonly));
39191                 }
39192             }
39193             for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) {
39194                 var leftProp = _c[_b];
39195                 if (skippedPrivateMembers.has(leftProp.escapedName) || !isSpreadableProperty(leftProp)) {
39196                     continue;
39197                 }
39198                 if (members.has(leftProp.escapedName)) {
39199                     var rightProp = members.get(leftProp.escapedName);
39200                     var rightType = getTypeOfSymbol(rightProp);
39201                     if (rightProp.flags & 16777216) {
39202                         var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations);
39203                         var flags = 4 | (leftProp.flags & 16777216);
39204                         var result = createSymbol(flags, leftProp.escapedName);
39205                         result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 524288)]);
39206                         result.leftSpread = leftProp;
39207                         result.rightSpread = rightProp;
39208                         result.declarations = declarations;
39209                         result.nameType = getSymbolLinks(leftProp).nameType;
39210                         members.set(leftProp.escapedName, result);
39211                     }
39212                 }
39213                 else {
39214                     members.set(leftProp.escapedName, getSpreadSymbol(leftProp, readonly));
39215                 }
39216             }
39217             var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoWithReadonly(stringIndexInfo, readonly), getIndexInfoWithReadonly(numberIndexInfo, readonly));
39218             spread.objectFlags |= 128 | 1048576 | 1024 | objectFlags;
39219             return spread;
39220         }
39221         function isSpreadableProperty(prop) {
39222             return !ts.some(prop.declarations, ts.isPrivateIdentifierPropertyDeclaration) &&
39223                 (!(prop.flags & (8192 | 32768 | 65536)) ||
39224                     !prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); }));
39225         }
39226         function getSpreadSymbol(prop, readonly) {
39227             var isSetonlyAccessor = prop.flags & 65536 && !(prop.flags & 32768);
39228             if (!isSetonlyAccessor && readonly === isReadonlySymbol(prop)) {
39229                 return prop;
39230             }
39231             var flags = 4 | (prop.flags & 16777216);
39232             var result = createSymbol(flags, prop.escapedName, readonly ? 8 : 0);
39233             result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop);
39234             result.declarations = prop.declarations;
39235             result.nameType = getSymbolLinks(prop).nameType;
39236             result.syntheticOrigin = prop;
39237             return result;
39238         }
39239         function getIndexInfoWithReadonly(info, readonly) {
39240             return info && info.isReadonly !== readonly ? createIndexInfo(info.type, readonly, info.declaration) : info;
39241         }
39242         function createLiteralType(flags, value, symbol) {
39243             var type = createType(flags);
39244             type.symbol = symbol;
39245             type.value = value;
39246             return type;
39247         }
39248         function getFreshTypeOfLiteralType(type) {
39249             if (type.flags & 2944) {
39250                 if (!type.freshType) {
39251                     var freshType = createLiteralType(type.flags, type.value, type.symbol);
39252                     freshType.regularType = type;
39253                     freshType.freshType = freshType;
39254                     type.freshType = freshType;
39255                 }
39256                 return type.freshType;
39257             }
39258             return type;
39259         }
39260         function getRegularTypeOfLiteralType(type) {
39261             return type.flags & 2944 ? type.regularType :
39262                 type.flags & 1048576 ? (type.regularType || (type.regularType = getUnionType(ts.sameMap(type.types, getRegularTypeOfLiteralType)))) :
39263                     type;
39264         }
39265         function isFreshLiteralType(type) {
39266             return !!(type.flags & 2944) && type.freshType === type;
39267         }
39268         function getLiteralType(value, enumId, symbol) {
39269             var qualifier = typeof value === "number" ? "#" : typeof value === "string" ? "@" : "n";
39270             var key = (enumId ? enumId : "") + qualifier + (typeof value === "object" ? ts.pseudoBigIntToString(value) : value);
39271             var type = literalTypes.get(key);
39272             if (!type) {
39273                 var flags = (typeof value === "number" ? 256 :
39274                     typeof value === "string" ? 128 : 2048) |
39275                     (enumId ? 1024 : 0);
39276                 literalTypes.set(key, type = createLiteralType(flags, value, symbol));
39277                 type.regularType = type;
39278             }
39279             return type;
39280         }
39281         function getTypeFromLiteralTypeNode(node) {
39282             var links = getNodeLinks(node);
39283             if (!links.resolvedType) {
39284                 links.resolvedType = getRegularTypeOfLiteralType(checkExpression(node.literal));
39285             }
39286             return links.resolvedType;
39287         }
39288         function createUniqueESSymbolType(symbol) {
39289             var type = createType(8192);
39290             type.symbol = symbol;
39291             type.escapedName = "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol);
39292             return type;
39293         }
39294         function getESSymbolLikeTypeForNode(node) {
39295             if (ts.isValidESSymbolDeclaration(node)) {
39296                 var symbol = getSymbolOfNode(node);
39297                 var links = getSymbolLinks(symbol);
39298                 return links.uniqueESSymbolType || (links.uniqueESSymbolType = createUniqueESSymbolType(symbol));
39299             }
39300             return esSymbolType;
39301         }
39302         function getThisType(node) {
39303             var container = ts.getThisContainer(node, false);
39304             var parent = container && container.parent;
39305             if (parent && (ts.isClassLike(parent) || parent.kind === 246)) {
39306                 if (!ts.hasModifier(container, 32) &&
39307                     (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) {
39308                     return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType;
39309                 }
39310             }
39311             if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6) {
39312                 return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType;
39313             }
39314             var host = node.flags & 4194304 ? ts.getHostSignatureFromJSDoc(node) : undefined;
39315             if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3) {
39316                 return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType;
39317             }
39318             if (isJSConstructor(container) && ts.isNodeDescendantOf(node, container.body)) {
39319                 return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(container)).thisType;
39320             }
39321             error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface);
39322             return errorType;
39323         }
39324         function getTypeFromThisTypeNode(node) {
39325             var links = getNodeLinks(node);
39326             if (!links.resolvedType) {
39327                 links.resolvedType = getThisType(node);
39328             }
39329             return links.resolvedType;
39330         }
39331         function getTypeFromTypeNode(node) {
39332             return getConditionalFlowTypeOfType(getTypeFromTypeNodeWorker(node), node);
39333         }
39334         function getTypeFromTypeNodeWorker(node) {
39335             switch (node.kind) {
39336                 case 125:
39337                 case 295:
39338                 case 296:
39339                     return anyType;
39340                 case 148:
39341                     return unknownType;
39342                 case 143:
39343                     return stringType;
39344                 case 140:
39345                     return numberType;
39346                 case 151:
39347                     return bigintType;
39348                 case 128:
39349                     return booleanType;
39350                 case 144:
39351                     return esSymbolType;
39352                 case 110:
39353                     return voidType;
39354                 case 146:
39355                     return undefinedType;
39356                 case 100:
39357                     return nullType;
39358                 case 137:
39359                     return neverType;
39360                 case 141:
39361                     return node.flags & 131072 && !noImplicitAny ? anyType : nonPrimitiveType;
39362                 case 183:
39363                 case 104:
39364                     return getTypeFromThisTypeNode(node);
39365                 case 187:
39366                     return getTypeFromLiteralTypeNode(node);
39367                 case 169:
39368                     return getTypeFromTypeReference(node);
39369                 case 168:
39370                     return node.assertsModifier ? voidType : booleanType;
39371                 case 216:
39372                     return getTypeFromTypeReference(node);
39373                 case 172:
39374                     return getTypeFromTypeQueryNode(node);
39375                 case 174:
39376                 case 175:
39377                     return getTypeFromArrayOrTupleTypeNode(node);
39378                 case 176:
39379                     return getTypeFromOptionalTypeNode(node);
39380                 case 178:
39381                     return getTypeFromUnionTypeNode(node);
39382                 case 179:
39383                     return getTypeFromIntersectionTypeNode(node);
39384                 case 297:
39385                     return getTypeFromJSDocNullableTypeNode(node);
39386                 case 299:
39387                     return addOptionality(getTypeFromTypeNode(node.type));
39388                 case 182:
39389                 case 298:
39390                 case 294:
39391                     return getTypeFromTypeNode(node.type);
39392                 case 177:
39393                     return getElementTypeOfArrayType(getTypeFromTypeNode(node.type)) || errorType;
39394                 case 301:
39395                     return getTypeFromJSDocVariadicType(node);
39396                 case 170:
39397                 case 171:
39398                 case 173:
39399                 case 304:
39400                 case 300:
39401                 case 305:
39402                     return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
39403                 case 184:
39404                     return getTypeFromTypeOperatorNode(node);
39405                 case 185:
39406                     return getTypeFromIndexedAccessTypeNode(node);
39407                 case 186:
39408                     return getTypeFromMappedTypeNode(node);
39409                 case 180:
39410                     return getTypeFromConditionalTypeNode(node);
39411                 case 181:
39412                     return getTypeFromInferTypeNode(node);
39413                 case 188:
39414                     return getTypeFromImportTypeNode(node);
39415                 case 75:
39416                 case 153:
39417                     var symbol = getSymbolAtLocation(node);
39418                     return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType;
39419                 default:
39420                     return errorType;
39421             }
39422         }
39423         function instantiateList(items, mapper, instantiator) {
39424             if (items && items.length) {
39425                 for (var i = 0; i < items.length; i++) {
39426                     var item = items[i];
39427                     var mapped = instantiator(item, mapper);
39428                     if (item !== mapped) {
39429                         var result = i === 0 ? [] : items.slice(0, i);
39430                         result.push(mapped);
39431                         for (i++; i < items.length; i++) {
39432                             result.push(instantiator(items[i], mapper));
39433                         }
39434                         return result;
39435                     }
39436                 }
39437             }
39438             return items;
39439         }
39440         function instantiateTypes(types, mapper) {
39441             return instantiateList(types, mapper, instantiateType);
39442         }
39443         function instantiateSignatures(signatures, mapper) {
39444             return instantiateList(signatures, mapper, instantiateSignature);
39445         }
39446         function createTypeMapper(sources, targets) {
39447             return sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : makeArrayTypeMapper(sources, targets);
39448         }
39449         function getMappedType(type, mapper) {
39450             switch (mapper.kind) {
39451                 case 0:
39452                     return type === mapper.source ? mapper.target : type;
39453                 case 1:
39454                     var sources = mapper.sources;
39455                     var targets = mapper.targets;
39456                     for (var i = 0; i < sources.length; i++) {
39457                         if (type === sources[i]) {
39458                             return targets ? targets[i] : anyType;
39459                         }
39460                     }
39461                     return type;
39462                 case 2:
39463                     return mapper.func(type);
39464                 case 3:
39465                 case 4:
39466                     var t1 = getMappedType(type, mapper.mapper1);
39467                     return t1 !== type && mapper.kind === 3 ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2);
39468             }
39469         }
39470         function makeUnaryTypeMapper(source, target) {
39471             return { kind: 0, source: source, target: target };
39472         }
39473         function makeArrayTypeMapper(sources, targets) {
39474             return { kind: 1, sources: sources, targets: targets };
39475         }
39476         function makeFunctionTypeMapper(func) {
39477             return { kind: 2, func: func };
39478         }
39479         function makeCompositeTypeMapper(kind, mapper1, mapper2) {
39480             return { kind: kind, mapper1: mapper1, mapper2: mapper2 };
39481         }
39482         function createTypeEraser(sources) {
39483             return createTypeMapper(sources, undefined);
39484         }
39485         function createBackreferenceMapper(context, index) {
39486             return makeFunctionTypeMapper(function (t) { return ts.findIndex(context.inferences, function (info) { return info.typeParameter === t; }) >= index ? unknownType : t; });
39487         }
39488         function combineTypeMappers(mapper1, mapper2) {
39489             return mapper1 ? makeCompositeTypeMapper(3, mapper1, mapper2) : mapper2;
39490         }
39491         function mergeTypeMappers(mapper1, mapper2) {
39492             return mapper1 ? makeCompositeTypeMapper(4, mapper1, mapper2) : mapper2;
39493         }
39494         function prependTypeMapping(source, target, mapper) {
39495             return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4, makeUnaryTypeMapper(source, target), mapper);
39496         }
39497         function appendTypeMapping(mapper, source, target) {
39498             return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4, mapper, makeUnaryTypeMapper(source, target));
39499         }
39500         function getRestrictiveTypeParameter(tp) {
39501             return tp.constraint === unknownType ? tp : tp.restrictiveInstantiation || (tp.restrictiveInstantiation = createTypeParameter(tp.symbol),
39502                 tp.restrictiveInstantiation.constraint = unknownType,
39503                 tp.restrictiveInstantiation);
39504         }
39505         function cloneTypeParameter(typeParameter) {
39506             var result = createTypeParameter(typeParameter.symbol);
39507             result.target = typeParameter;
39508             return result;
39509         }
39510         function instantiateTypePredicate(predicate, mapper) {
39511             return createTypePredicate(predicate.kind, predicate.parameterName, predicate.parameterIndex, instantiateType(predicate.type, mapper));
39512         }
39513         function instantiateSignature(signature, mapper, eraseTypeParameters) {
39514             var freshTypeParameters;
39515             if (signature.typeParameters && !eraseTypeParameters) {
39516                 freshTypeParameters = ts.map(signature.typeParameters, cloneTypeParameter);
39517                 mapper = combineTypeMappers(createTypeMapper(signature.typeParameters, freshTypeParameters), mapper);
39518                 for (var _i = 0, freshTypeParameters_1 = freshTypeParameters; _i < freshTypeParameters_1.length; _i++) {
39519                     var tp = freshTypeParameters_1[_i];
39520                     tp.mapper = mapper;
39521                 }
39522             }
39523             var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), undefined, undefined, signature.minArgumentCount, signature.flags & 3);
39524             result.target = signature;
39525             result.mapper = mapper;
39526             return result;
39527         }
39528         function instantiateSymbol(symbol, mapper) {
39529             var links = getSymbolLinks(symbol);
39530             if (links.type && !couldContainTypeVariables(links.type)) {
39531                 return symbol;
39532             }
39533             if (ts.getCheckFlags(symbol) & 1) {
39534                 symbol = links.target;
39535                 mapper = combineTypeMappers(links.mapper, mapper);
39536             }
39537             var result = createSymbol(symbol.flags, symbol.escapedName, 1 | ts.getCheckFlags(symbol) & (8 | 4096 | 16384 | 32768));
39538             result.declarations = symbol.declarations;
39539             result.parent = symbol.parent;
39540             result.target = symbol;
39541             result.mapper = mapper;
39542             if (symbol.valueDeclaration) {
39543                 result.valueDeclaration = symbol.valueDeclaration;
39544             }
39545             if (links.nameType) {
39546                 result.nameType = links.nameType;
39547             }
39548             return result;
39549         }
39550         function getObjectTypeInstantiation(type, mapper) {
39551             var target = type.objectFlags & 64 ? type.target : type;
39552             var node = type.objectFlags & 4 ? type.node : type.symbol.declarations[0];
39553             var links = getNodeLinks(node);
39554             var typeParameters = links.outerTypeParameters;
39555             if (!typeParameters) {
39556                 var declaration_1 = node;
39557                 if (ts.isInJSFile(declaration_1)) {
39558                     var paramTag = ts.findAncestor(declaration_1, ts.isJSDocParameterTag);
39559                     if (paramTag) {
39560                         var paramSymbol = ts.getParameterSymbolFromJSDoc(paramTag);
39561                         if (paramSymbol) {
39562                             declaration_1 = paramSymbol.valueDeclaration;
39563                         }
39564                     }
39565                 }
39566                 var outerTypeParameters = getOuterTypeParameters(declaration_1, true);
39567                 if (isJSConstructor(declaration_1)) {
39568                     var templateTagParameters = getTypeParametersFromDeclaration(declaration_1);
39569                     outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters);
39570                 }
39571                 typeParameters = outerTypeParameters || ts.emptyArray;
39572                 typeParameters = (target.objectFlags & 4 || target.symbol.flags & 2048) && !target.aliasTypeArguments ?
39573                     ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration_1); }) :
39574                     typeParameters;
39575                 links.outerTypeParameters = typeParameters;
39576                 if (typeParameters.length) {
39577                     links.instantiations = ts.createMap();
39578                     links.instantiations.set(getTypeListId(typeParameters), target);
39579                 }
39580             }
39581             if (typeParameters.length) {
39582                 var combinedMapper_1 = combineTypeMappers(type.mapper, mapper);
39583                 var typeArguments = ts.map(typeParameters, function (t) { return getMappedType(t, combinedMapper_1); });
39584                 var id = getTypeListId(typeArguments);
39585                 var result = links.instantiations.get(id);
39586                 if (!result) {
39587                     var newMapper = createTypeMapper(typeParameters, typeArguments);
39588                     result = target.objectFlags & 4 ? createDeferredTypeReference(type.target, type.node, newMapper) :
39589                         target.objectFlags & 32 ? instantiateMappedType(target, newMapper) :
39590                             instantiateAnonymousType(target, newMapper);
39591                     links.instantiations.set(id, result);
39592                 }
39593                 return result;
39594             }
39595             return type;
39596         }
39597         function maybeTypeParameterReference(node) {
39598             return !(node.kind === 153 ||
39599                 node.parent.kind === 169 && node.parent.typeArguments && node === node.parent.typeName ||
39600                 node.parent.kind === 188 && node.parent.typeArguments && node === node.parent.qualifier);
39601         }
39602         function isTypeParameterPossiblyReferenced(tp, node) {
39603             if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) {
39604                 var container = tp.symbol.declarations[0].parent;
39605                 for (var n = node; n !== container; n = n.parent) {
39606                     if (!n || n.kind === 223 || n.kind === 180 && ts.forEachChild(n.extendsType, containsReference)) {
39607                         return true;
39608                     }
39609                 }
39610                 return !!ts.forEachChild(node, containsReference);
39611             }
39612             return true;
39613             function containsReference(node) {
39614                 switch (node.kind) {
39615                     case 183:
39616                         return !!tp.isThisType;
39617                     case 75:
39618                         return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) &&
39619                             getTypeFromTypeNodeWorker(node) === tp;
39620                     case 172:
39621                         return true;
39622                 }
39623                 return !!ts.forEachChild(node, containsReference);
39624             }
39625         }
39626         function getHomomorphicTypeVariable(type) {
39627             var constraintType = getConstraintTypeFromMappedType(type);
39628             if (constraintType.flags & 4194304) {
39629                 var typeVariable = getActualTypeVariable(constraintType.type);
39630                 if (typeVariable.flags & 262144) {
39631                     return typeVariable;
39632                 }
39633             }
39634             return undefined;
39635         }
39636         function instantiateMappedType(type, mapper) {
39637             var typeVariable = getHomomorphicTypeVariable(type);
39638             if (typeVariable) {
39639                 var mappedTypeVariable = instantiateType(typeVariable, mapper);
39640                 if (typeVariable !== mappedTypeVariable) {
39641                     return mapType(getReducedType(mappedTypeVariable), function (t) {
39642                         if (t.flags & (3 | 58982400 | 524288 | 2097152) && t !== wildcardType && t !== errorType) {
39643                             var replacementMapper = prependTypeMapping(typeVariable, t, mapper);
39644                             return isArrayType(t) ? instantiateMappedArrayType(t, type, replacementMapper) :
39645                                 isTupleType(t) ? instantiateMappedTupleType(t, type, replacementMapper) :
39646                                     instantiateAnonymousType(type, replacementMapper);
39647                         }
39648                         return t;
39649                     });
39650                 }
39651             }
39652             return instantiateAnonymousType(type, mapper);
39653         }
39654         function getModifiedReadonlyState(state, modifiers) {
39655             return modifiers & 1 ? true : modifiers & 2 ? false : state;
39656         }
39657         function instantiateMappedArrayType(arrayType, mappedType, mapper) {
39658             var elementType = instantiateMappedTypeTemplate(mappedType, numberType, true, mapper);
39659             return elementType === errorType ? errorType :
39660                 createArrayType(elementType, getModifiedReadonlyState(isReadonlyArrayType(arrayType), getMappedTypeModifiers(mappedType)));
39661         }
39662         function instantiateMappedTupleType(tupleType, mappedType, mapper) {
39663             var minLength = tupleType.target.minLength;
39664             var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) {
39665                 return instantiateMappedTypeTemplate(mappedType, getLiteralType("" + i), i >= minLength, mapper);
39666             });
39667             var modifiers = getMappedTypeModifiers(mappedType);
39668             var newMinLength = modifiers & 4 ? 0 :
39669                 modifiers & 8 ? getTypeReferenceArity(tupleType) - (tupleType.target.hasRestElement ? 1 : 0) :
39670                     minLength;
39671             var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, modifiers);
39672             return ts.contains(elementTypes, errorType) ? errorType :
39673                 createTupleType(elementTypes, newMinLength, tupleType.target.hasRestElement, newReadonly, tupleType.target.associatedNames);
39674         }
39675         function instantiateMappedTypeTemplate(type, key, isOptional, mapper) {
39676             var templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key);
39677             var propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper);
39678             var modifiers = getMappedTypeModifiers(type);
39679             return strictNullChecks && modifiers & 4 && !maybeTypeOfKind(propType, 32768 | 16384) ? getOptionalType(propType) :
39680                 strictNullChecks && modifiers & 8 && isOptional ? getTypeWithFacts(propType, 524288) :
39681                     propType;
39682         }
39683         function instantiateAnonymousType(type, mapper) {
39684             var result = createObjectType(type.objectFlags | 64, type.symbol);
39685             if (type.objectFlags & 32) {
39686                 result.declaration = type.declaration;
39687                 var origTypeParameter = getTypeParameterFromMappedType(type);
39688                 var freshTypeParameter = cloneTypeParameter(origTypeParameter);
39689                 result.typeParameter = freshTypeParameter;
39690                 mapper = combineTypeMappers(makeUnaryTypeMapper(origTypeParameter, freshTypeParameter), mapper);
39691                 freshTypeParameter.mapper = mapper;
39692             }
39693             result.target = type;
39694             result.mapper = mapper;
39695             result.aliasSymbol = type.aliasSymbol;
39696             result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper);
39697             return result;
39698         }
39699         function getConditionalTypeInstantiation(type, mapper) {
39700             var root = type.root;
39701             if (root.outerTypeParameters) {
39702                 var typeArguments = ts.map(root.outerTypeParameters, function (t) { return getMappedType(t, mapper); });
39703                 var id = getTypeListId(typeArguments);
39704                 var result = root.instantiations.get(id);
39705                 if (!result) {
39706                     var newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
39707                     result = instantiateConditionalType(root, newMapper);
39708                     root.instantiations.set(id, result);
39709                 }
39710                 return result;
39711             }
39712             return type;
39713         }
39714         function instantiateConditionalType(root, mapper) {
39715             if (root.isDistributive) {
39716                 var checkType_1 = root.checkType;
39717                 var instantiatedType = getMappedType(checkType_1, mapper);
39718                 if (checkType_1 !== instantiatedType && instantiatedType.flags & (1048576 | 131072)) {
39719                     return mapType(instantiatedType, function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, mapper)); });
39720                 }
39721             }
39722             return getConditionalType(root, mapper);
39723         }
39724         function instantiateType(type, mapper) {
39725             if (!type || !mapper) {
39726                 return type;
39727             }
39728             if (instantiationDepth === 50 || instantiationCount >= 5000000) {
39729                 error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
39730                 return errorType;
39731             }
39732             totalInstantiationCount++;
39733             instantiationCount++;
39734             instantiationDepth++;
39735             var result = instantiateTypeWorker(type, mapper);
39736             instantiationDepth--;
39737             return result;
39738         }
39739         function instantiateTypeWithoutDepthIncrease(type, mapper) {
39740             instantiationDepth--;
39741             var result = instantiateType(type, mapper);
39742             instantiationDepth++;
39743             return result;
39744         }
39745         function instantiateTypeWorker(type, mapper) {
39746             var flags = type.flags;
39747             if (flags & 262144) {
39748                 return getMappedType(type, mapper);
39749             }
39750             if (flags & 524288) {
39751                 var objectFlags = type.objectFlags;
39752                 if (objectFlags & 16) {
39753                     return couldContainTypeVariables(type) ?
39754                         getObjectTypeInstantiation(type, mapper) : type;
39755                 }
39756                 if (objectFlags & 32) {
39757                     return getObjectTypeInstantiation(type, mapper);
39758                 }
39759                 if (objectFlags & 4) {
39760                     if (type.node) {
39761                         return getObjectTypeInstantiation(type, mapper);
39762                     }
39763                     var resolvedTypeArguments = type.resolvedTypeArguments;
39764                     var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper);
39765                     return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type;
39766                 }
39767                 return type;
39768             }
39769             if ((flags & 2097152) || (flags & 1048576 && !(flags & 131068))) {
39770                 if (!couldContainTypeVariables(type)) {
39771                     return type;
39772                 }
39773                 var types = type.types;
39774                 var newTypes = instantiateTypes(types, mapper);
39775                 return newTypes === types
39776                     ? type
39777                     : (flags & 2097152)
39778                         ? getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper))
39779                         : getUnionType(newTypes, 1, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper));
39780             }
39781             if (flags & 4194304) {
39782                 return getIndexType(instantiateType(type.type, mapper));
39783             }
39784             if (flags & 8388608) {
39785                 return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), undefined, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper));
39786             }
39787             if (flags & 16777216) {
39788                 return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper));
39789             }
39790             if (flags & 33554432) {
39791                 var maybeVariable = instantiateType(type.baseType, mapper);
39792                 if (maybeVariable.flags & 8650752) {
39793                     return getSubstitutionType(maybeVariable, instantiateType(type.substitute, mapper));
39794                 }
39795                 else {
39796                     var sub = instantiateType(type.substitute, mapper);
39797                     if (sub.flags & 3 || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) {
39798                         return maybeVariable;
39799                     }
39800                     return sub;
39801                 }
39802             }
39803             return type;
39804         }
39805         function getPermissiveInstantiation(type) {
39806             return type.flags & (131068 | 3 | 131072) ? type :
39807                 type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper));
39808         }
39809         function getRestrictiveInstantiation(type) {
39810             if (type.flags & (131068 | 3 | 131072)) {
39811                 return type;
39812             }
39813             if (type.restrictiveInstantiation) {
39814                 return type.restrictiveInstantiation;
39815             }
39816             type.restrictiveInstantiation = instantiateType(type, restrictiveMapper);
39817             type.restrictiveInstantiation.restrictiveInstantiation = type.restrictiveInstantiation;
39818             return type.restrictiveInstantiation;
39819         }
39820         function instantiateIndexInfo(info, mapper) {
39821             return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration);
39822         }
39823         function isContextSensitive(node) {
39824             ts.Debug.assert(node.kind !== 161 || ts.isObjectLiteralMethod(node));
39825             switch (node.kind) {
39826                 case 201:
39827                 case 202:
39828                 case 161:
39829                 case 244:
39830                     return isContextSensitiveFunctionLikeDeclaration(node);
39831                 case 193:
39832                     return ts.some(node.properties, isContextSensitive);
39833                 case 192:
39834                     return ts.some(node.elements, isContextSensitive);
39835                 case 210:
39836                     return isContextSensitive(node.whenTrue) ||
39837                         isContextSensitive(node.whenFalse);
39838                 case 209:
39839                     return (node.operatorToken.kind === 56 || node.operatorToken.kind === 60) &&
39840                         (isContextSensitive(node.left) || isContextSensitive(node.right));
39841                 case 281:
39842                     return isContextSensitive(node.initializer);
39843                 case 200:
39844                     return isContextSensitive(node.expression);
39845                 case 274:
39846                     return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive);
39847                 case 273: {
39848                     var initializer = node.initializer;
39849                     return !!initializer && isContextSensitive(initializer);
39850                 }
39851                 case 276: {
39852                     var expression = node.expression;
39853                     return !!expression && isContextSensitive(expression);
39854                 }
39855             }
39856             return false;
39857         }
39858         function isContextSensitiveFunctionLikeDeclaration(node) {
39859             return (!ts.isFunctionDeclaration(node) || ts.isInJSFile(node) && !!getTypeForDeclarationFromJSDocComment(node)) &&
39860                 (hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node));
39861         }
39862         function hasContextSensitiveParameters(node) {
39863             if (!node.typeParameters) {
39864                 if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) {
39865                     return true;
39866                 }
39867                 if (node.kind !== 202) {
39868                     var parameter = ts.firstOrUndefined(node.parameters);
39869                     if (!(parameter && ts.parameterIsThisKeyword(parameter))) {
39870                         return true;
39871                     }
39872                 }
39873             }
39874             return false;
39875         }
39876         function hasContextSensitiveReturnExpression(node) {
39877             return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 223 && isContextSensitive(node.body);
39878         }
39879         function isContextSensitiveFunctionOrObjectLiteralMethod(func) {
39880             return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
39881                 isContextSensitiveFunctionLikeDeclaration(func);
39882         }
39883         function getTypeWithoutSignatures(type) {
39884             if (type.flags & 524288) {
39885                 var resolved = resolveStructuredTypeMembers(type);
39886                 if (resolved.constructSignatures.length || resolved.callSignatures.length) {
39887                     var result = createObjectType(16, type.symbol);
39888                     result.members = resolved.members;
39889                     result.properties = resolved.properties;
39890                     result.callSignatures = ts.emptyArray;
39891                     result.constructSignatures = ts.emptyArray;
39892                     return result;
39893                 }
39894             }
39895             else if (type.flags & 2097152) {
39896                 return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures));
39897             }
39898             return type;
39899         }
39900         function isTypeIdenticalTo(source, target) {
39901             return isTypeRelatedTo(source, target, identityRelation);
39902         }
39903         function compareTypesIdentical(source, target) {
39904             return isTypeRelatedTo(source, target, identityRelation) ? -1 : 0;
39905         }
39906         function compareTypesAssignable(source, target) {
39907             return isTypeRelatedTo(source, target, assignableRelation) ? -1 : 0;
39908         }
39909         function compareTypesSubtypeOf(source, target) {
39910             return isTypeRelatedTo(source, target, subtypeRelation) ? -1 : 0;
39911         }
39912         function isTypeSubtypeOf(source, target) {
39913             return isTypeRelatedTo(source, target, subtypeRelation);
39914         }
39915         function isTypeAssignableTo(source, target) {
39916             return isTypeRelatedTo(source, target, assignableRelation);
39917         }
39918         function isTypeDerivedFrom(source, target) {
39919             return source.flags & 1048576 ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) :
39920                 target.flags & 1048576 ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) :
39921                     source.flags & 58982400 ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) :
39922                         target === globalObjectType ? !!(source.flags & (524288 | 67108864)) :
39923                             target === globalFunctionType ? !!(source.flags & 524288) && isFunctionObjectType(source) :
39924                                 hasBaseType(source, getTargetType(target));
39925         }
39926         function isTypeComparableTo(source, target) {
39927             return isTypeRelatedTo(source, target, comparableRelation);
39928         }
39929         function areTypesComparable(type1, type2) {
39930             return isTypeComparableTo(type1, type2) || isTypeComparableTo(type2, type1);
39931         }
39932         function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain, errorOutputObject) {
39933             return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain, errorOutputObject);
39934         }
39935         function checkTypeAssignableToAndOptionallyElaborate(source, target, errorNode, expr, headMessage, containingMessageChain) {
39936             return checkTypeRelatedToAndOptionallyElaborate(source, target, assignableRelation, errorNode, expr, headMessage, containingMessageChain, undefined);
39937         }
39938         function checkTypeRelatedToAndOptionallyElaborate(source, target, relation, errorNode, expr, headMessage, containingMessageChain, errorOutputContainer) {
39939             if (isTypeRelatedTo(source, target, relation))
39940                 return true;
39941             if (!errorNode || !elaborateError(expr, source, target, relation, headMessage, containingMessageChain, errorOutputContainer)) {
39942                 return checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer);
39943             }
39944             return false;
39945         }
39946         function isOrHasGenericConditional(type) {
39947             return !!(type.flags & 16777216 || (type.flags & 2097152 && ts.some(type.types, isOrHasGenericConditional)));
39948         }
39949         function elaborateError(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) {
39950             if (!node || isOrHasGenericConditional(target))
39951                 return false;
39952             if (!checkTypeRelatedTo(source, target, relation, undefined)
39953                 && elaborateDidYouMeanToCallOrConstruct(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer)) {
39954                 return true;
39955             }
39956             switch (node.kind) {
39957                 case 276:
39958                 case 200:
39959                     return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer);
39960                 case 209:
39961                     switch (node.operatorToken.kind) {
39962                         case 62:
39963                         case 27:
39964                             return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer);
39965                     }
39966                     break;
39967                 case 193:
39968                     return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer);
39969                 case 192:
39970                     return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer);
39971                 case 274:
39972                     return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer);
39973                 case 202:
39974                     return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer);
39975             }
39976             return false;
39977         }
39978         function elaborateDidYouMeanToCallOrConstruct(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) {
39979             var callSignatures = getSignaturesOfType(source, 0);
39980             var constructSignatures = getSignaturesOfType(source, 1);
39981             for (var _i = 0, _a = [constructSignatures, callSignatures]; _i < _a.length; _i++) {
39982                 var signatures = _a[_i];
39983                 if (ts.some(signatures, function (s) {
39984                     var returnType = getReturnTypeOfSignature(s);
39985                     return !(returnType.flags & (1 | 131072)) && checkTypeRelatedTo(returnType, target, relation, undefined);
39986                 })) {
39987                     var resultObj = errorOutputContainer || {};
39988                     checkTypeAssignableTo(source, target, node, headMessage, containingMessageChain, resultObj);
39989                     var diagnostic = resultObj.errors[resultObj.errors.length - 1];
39990                     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));
39991                     return true;
39992                 }
39993             }
39994             return false;
39995         }
39996         function elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer) {
39997             if (ts.isBlock(node.body)) {
39998                 return false;
39999             }
40000             if (ts.some(node.parameters, ts.hasType)) {
40001                 return false;
40002             }
40003             var sourceSig = getSingleCallSignature(source);
40004             if (!sourceSig) {
40005                 return false;
40006             }
40007             var targetSignatures = getSignaturesOfType(target, 0);
40008             if (!ts.length(targetSignatures)) {
40009                 return false;
40010             }
40011             var returnExpression = node.body;
40012             var sourceReturn = getReturnTypeOfSignature(sourceSig);
40013             var targetReturn = getUnionType(ts.map(targetSignatures, getReturnTypeOfSignature));
40014             if (!checkTypeRelatedTo(sourceReturn, targetReturn, relation, undefined)) {
40015                 var elaborated = returnExpression && elaborateError(returnExpression, sourceReturn, targetReturn, relation, undefined, containingMessageChain, errorOutputContainer);
40016                 if (elaborated) {
40017                     return elaborated;
40018                 }
40019                 var resultObj = errorOutputContainer || {};
40020                 checkTypeRelatedTo(sourceReturn, targetReturn, relation, returnExpression, undefined, containingMessageChain, resultObj);
40021                 if (resultObj.errors) {
40022                     if (target.symbol && ts.length(target.symbol.declarations)) {
40023                         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));
40024                     }
40025                     if ((ts.getFunctionFlags(node) & 2) === 0
40026                         && !getTypeOfPropertyOfType(sourceReturn, "then")
40027                         && checkTypeRelatedTo(createPromiseType(sourceReturn), targetReturn, relation, undefined)) {
40028                         ts.addRelatedInfo(resultObj.errors[resultObj.errors.length - 1], ts.createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async));
40029                     }
40030                     return true;
40031                 }
40032             }
40033             return false;
40034         }
40035         function getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType) {
40036             var idx = getIndexedAccessTypeOrUndefined(target, nameType);
40037             if (idx) {
40038                 return idx;
40039             }
40040             if (target.flags & 1048576) {
40041                 var best = getBestMatchingType(source, target);
40042                 if (best) {
40043                     return getIndexedAccessTypeOrUndefined(best, nameType);
40044                 }
40045             }
40046         }
40047         function checkExpressionForMutableLocationWithContextualType(next, sourcePropType) {
40048             next.contextualType = sourcePropType;
40049             try {
40050                 return checkExpressionForMutableLocation(next, 1, sourcePropType);
40051             }
40052             finally {
40053                 next.contextualType = undefined;
40054             }
40055         }
40056         function elaborateElementwise(iterator, source, target, relation, containingMessageChain, errorOutputContainer) {
40057             var reportedError = false;
40058             for (var status = iterator.next(); !status.done; status = iterator.next()) {
40059                 var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage;
40060                 var targetPropType = getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType);
40061                 if (!targetPropType || targetPropType.flags & 8388608)
40062                     continue;
40063                 var sourcePropType = getIndexedAccessTypeOrUndefined(source, nameType);
40064                 if (sourcePropType && !checkTypeRelatedTo(sourcePropType, targetPropType, relation, undefined)) {
40065                     var elaborated = next && elaborateError(next, sourcePropType, targetPropType, relation, undefined, containingMessageChain, errorOutputContainer);
40066                     if (elaborated) {
40067                         reportedError = true;
40068                     }
40069                     else {
40070                         var resultObj = errorOutputContainer || {};
40071                         var specificSource = next ? checkExpressionForMutableLocationWithContextualType(next, sourcePropType) : sourcePropType;
40072                         var result = checkTypeRelatedTo(specificSource, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj);
40073                         if (result && specificSource !== sourcePropType) {
40074                             checkTypeRelatedTo(sourcePropType, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj);
40075                         }
40076                         if (resultObj.errors) {
40077                             var reportedDiag = resultObj.errors[resultObj.errors.length - 1];
40078                             var propertyName = isTypeUsableAsPropertyName(nameType) ? getPropertyNameFromType(nameType) : undefined;
40079                             var targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined;
40080                             var issuedElaboration = false;
40081                             if (!targetProp) {
40082                                 var indexInfo = isTypeAssignableToKind(nameType, 296) && getIndexInfoOfType(target, 1) ||
40083                                     getIndexInfoOfType(target, 0) ||
40084                                     undefined;
40085                                 if (indexInfo && indexInfo.declaration && !ts.getSourceFileOfNode(indexInfo.declaration).hasNoDefaultLib) {
40086                                     issuedElaboration = true;
40087                                     ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(indexInfo.declaration, ts.Diagnostics.The_expected_type_comes_from_this_index_signature));
40088                                 }
40089                             }
40090                             if (!issuedElaboration && (targetProp && ts.length(targetProp.declarations) || target.symbol && ts.length(target.symbol.declarations))) {
40091                                 var targetNode = targetProp && ts.length(targetProp.declarations) ? targetProp.declarations[0] : target.symbol.declarations[0];
40092                                 if (!ts.getSourceFileOfNode(targetNode).hasNoDefaultLib) {
40093                                     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)));
40094                                 }
40095                             }
40096                         }
40097                         reportedError = true;
40098                     }
40099                 }
40100             }
40101             return reportedError;
40102         }
40103         function generateJsxAttributes(node) {
40104             var _i, _a, prop;
40105             return __generator(this, function (_b) {
40106                 switch (_b.label) {
40107                     case 0:
40108                         if (!ts.length(node.properties))
40109                             return [2];
40110                         _i = 0, _a = node.properties;
40111                         _b.label = 1;
40112                     case 1:
40113                         if (!(_i < _a.length)) return [3, 4];
40114                         prop = _a[_i];
40115                         if (ts.isJsxSpreadAttribute(prop))
40116                             return [3, 3];
40117                         return [4, { errorNode: prop.name, innerExpression: prop.initializer, nameType: getLiteralType(ts.idText(prop.name)) }];
40118                     case 2:
40119                         _b.sent();
40120                         _b.label = 3;
40121                     case 3:
40122                         _i++;
40123                         return [3, 1];
40124                     case 4: return [2];
40125                 }
40126             });
40127         }
40128         function generateJsxChildren(node, getInvalidTextDiagnostic) {
40129             var memberOffset, i, child, nameType, elem;
40130             return __generator(this, function (_a) {
40131                 switch (_a.label) {
40132                     case 0:
40133                         if (!ts.length(node.children))
40134                             return [2];
40135                         memberOffset = 0;
40136                         i = 0;
40137                         _a.label = 1;
40138                     case 1:
40139                         if (!(i < node.children.length)) return [3, 5];
40140                         child = node.children[i];
40141                         nameType = getLiteralType(i - memberOffset);
40142                         elem = getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic);
40143                         if (!elem) return [3, 3];
40144                         return [4, elem];
40145                     case 2:
40146                         _a.sent();
40147                         return [3, 4];
40148                     case 3:
40149                         memberOffset++;
40150                         _a.label = 4;
40151                     case 4:
40152                         i++;
40153                         return [3, 1];
40154                     case 5: return [2];
40155                 }
40156             });
40157         }
40158         function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) {
40159             switch (child.kind) {
40160                 case 276:
40161                     return { errorNode: child, innerExpression: child.expression, nameType: nameType };
40162                 case 11:
40163                     if (child.containsOnlyTriviaWhiteSpaces) {
40164                         break;
40165                     }
40166                     return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() };
40167                 case 266:
40168                 case 267:
40169                 case 270:
40170                     return { errorNode: child, innerExpression: child, nameType: nameType };
40171                 default:
40172                     return ts.Debug.assertNever(child, "Found invalid jsx child");
40173             }
40174         }
40175         function getSemanticJsxChildren(children) {
40176             return ts.filter(children, function (i) { return !ts.isJsxText(i) || !i.containsOnlyTriviaWhiteSpaces; });
40177         }
40178         function elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer) {
40179             var result = elaborateElementwise(generateJsxAttributes(node), source, target, relation, containingMessageChain, errorOutputContainer);
40180             var invalidTextDiagnostic;
40181             if (ts.isJsxOpeningElement(node.parent) && ts.isJsxElement(node.parent.parent)) {
40182                 var containingElement = node.parent.parent;
40183                 var childPropName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
40184                 var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName);
40185                 var childrenNameType = getLiteralType(childrenPropName);
40186                 var childrenTargetType = getIndexedAccessType(target, childrenNameType);
40187                 var validChildren = getSemanticJsxChildren(containingElement.children);
40188                 if (!ts.length(validChildren)) {
40189                     return result;
40190                 }
40191                 var moreThanOneRealChildren = ts.length(validChildren) > 1;
40192                 var arrayLikeTargetParts = filterType(childrenTargetType, isArrayOrTupleLikeType);
40193                 var nonArrayLikeTargetParts = filterType(childrenTargetType, function (t) { return !isArrayOrTupleLikeType(t); });
40194                 if (moreThanOneRealChildren) {
40195                     if (arrayLikeTargetParts !== neverType) {
40196                         var realSource = createTupleType(checkJsxChildren(containingElement, 0));
40197                         var children = generateJsxChildren(containingElement, getInvalidTextualChildDiagnostic);
40198                         result = elaborateElementwise(children, realSource, arrayLikeTargetParts, relation, containingMessageChain, errorOutputContainer) || result;
40199                     }
40200                     else if (!isTypeRelatedTo(getIndexedAccessType(source, childrenNameType), childrenTargetType, relation)) {
40201                         result = true;
40202                         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));
40203                         if (errorOutputContainer && errorOutputContainer.skipLogging) {
40204                             (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
40205                         }
40206                     }
40207                 }
40208                 else {
40209                     if (nonArrayLikeTargetParts !== neverType) {
40210                         var child = validChildren[0];
40211                         var elem_1 = getElaborationElementForJsxChild(child, childrenNameType, getInvalidTextualChildDiagnostic);
40212                         if (elem_1) {
40213                             result = elaborateElementwise((function () { return __generator(this, function (_a) {
40214                                 switch (_a.label) {
40215                                     case 0: return [4, elem_1];
40216                                     case 1:
40217                                         _a.sent();
40218                                         return [2];
40219                                 }
40220                             }); })(), source, target, relation, containingMessageChain, errorOutputContainer) || result;
40221                         }
40222                     }
40223                     else if (!isTypeRelatedTo(getIndexedAccessType(source, childrenNameType), childrenTargetType, relation)) {
40224                         result = true;
40225                         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));
40226                         if (errorOutputContainer && errorOutputContainer.skipLogging) {
40227                             (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
40228                         }
40229                     }
40230                 }
40231             }
40232             return result;
40233             function getInvalidTextualChildDiagnostic() {
40234                 if (!invalidTextDiagnostic) {
40235                     var tagNameText = ts.getTextOfNode(node.parent.tagName);
40236                     var childPropName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
40237                     var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName);
40238                     var childrenTargetType = getIndexedAccessType(target, getLiteralType(childrenPropName));
40239                     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;
40240                     invalidTextDiagnostic = __assign(__assign({}, diagnostic), { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) });
40241                 }
40242                 return invalidTextDiagnostic;
40243             }
40244         }
40245         function generateLimitedTupleElements(node, target) {
40246             var len, i, elem, nameType;
40247             return __generator(this, function (_a) {
40248                 switch (_a.label) {
40249                     case 0:
40250                         len = ts.length(node.elements);
40251                         if (!len)
40252                             return [2];
40253                         i = 0;
40254                         _a.label = 1;
40255                     case 1:
40256                         if (!(i < len)) return [3, 4];
40257                         if (isTupleLikeType(target) && !getPropertyOfType(target, ("" + i)))
40258                             return [3, 3];
40259                         elem = node.elements[i];
40260                         if (ts.isOmittedExpression(elem))
40261                             return [3, 3];
40262                         nameType = getLiteralType(i);
40263                         return [4, { errorNode: elem, innerExpression: elem, nameType: nameType }];
40264                     case 2:
40265                         _a.sent();
40266                         _a.label = 3;
40267                     case 3:
40268                         i++;
40269                         return [3, 1];
40270                     case 4: return [2];
40271                 }
40272             });
40273         }
40274         function elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) {
40275             if (target.flags & 131068)
40276                 return false;
40277             if (isTupleLikeType(source)) {
40278                 return elaborateElementwise(generateLimitedTupleElements(node, target), source, target, relation, containingMessageChain, errorOutputContainer);
40279             }
40280             var oldContext = node.contextualType;
40281             node.contextualType = target;
40282             try {
40283                 var tupleizedType = checkArrayLiteral(node, 1, true);
40284                 node.contextualType = oldContext;
40285                 if (isTupleLikeType(tupleizedType)) {
40286                     return elaborateElementwise(generateLimitedTupleElements(node, target), tupleizedType, target, relation, containingMessageChain, errorOutputContainer);
40287                 }
40288                 return false;
40289             }
40290             finally {
40291                 node.contextualType = oldContext;
40292             }
40293         }
40294         function generateObjectLiteralElements(node) {
40295             var _i, _a, prop, type, _b;
40296             return __generator(this, function (_c) {
40297                 switch (_c.label) {
40298                     case 0:
40299                         if (!ts.length(node.properties))
40300                             return [2];
40301                         _i = 0, _a = node.properties;
40302                         _c.label = 1;
40303                     case 1:
40304                         if (!(_i < _a.length)) return [3, 8];
40305                         prop = _a[_i];
40306                         if (ts.isSpreadAssignment(prop))
40307                             return [3, 7];
40308                         type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576);
40309                         if (!type || (type.flags & 131072)) {
40310                             return [3, 7];
40311                         }
40312                         _b = prop.kind;
40313                         switch (_b) {
40314                             case 164: return [3, 2];
40315                             case 163: return [3, 2];
40316                             case 161: return [3, 2];
40317                             case 282: return [3, 2];
40318                             case 281: return [3, 4];
40319                         }
40320                         return [3, 6];
40321                     case 2: return [4, { errorNode: prop.name, innerExpression: undefined, nameType: type }];
40322                     case 3:
40323                         _c.sent();
40324                         return [3, 7];
40325                     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 }];
40326                     case 5:
40327                         _c.sent();
40328                         return [3, 7];
40329                     case 6:
40330                         ts.Debug.assertNever(prop);
40331                         _c.label = 7;
40332                     case 7:
40333                         _i++;
40334                         return [3, 1];
40335                     case 8: return [2];
40336                 }
40337             });
40338         }
40339         function elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) {
40340             if (target.flags & 131068)
40341                 return false;
40342             return elaborateElementwise(generateObjectLiteralElements(node), source, target, relation, containingMessageChain, errorOutputContainer);
40343         }
40344         function checkTypeComparableTo(source, target, errorNode, headMessage, containingMessageChain) {
40345             return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain);
40346         }
40347         function isSignatureAssignableTo(source, target, ignoreReturnTypes) {
40348             return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 : 0, false, undefined, undefined, compareTypesAssignable, undefined) !== 0;
40349         }
40350         function isAnySignature(s) {
40351             return !s.typeParameters && (!s.thisParameter || isTypeAny(getTypeOfParameter(s.thisParameter))) && s.parameters.length === 1 &&
40352                 signatureHasRestParameter(s) && (getTypeOfParameter(s.parameters[0]) === anyArrayType || isTypeAny(getTypeOfParameter(s.parameters[0]))) &&
40353                 isTypeAny(getReturnTypeOfSignature(s));
40354         }
40355         function compareSignaturesRelated(source, target, checkMode, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) {
40356             if (source === target) {
40357                 return -1;
40358             }
40359             if (isAnySignature(target)) {
40360                 return -1;
40361             }
40362             var targetCount = getParameterCount(target);
40363             var sourceHasMoreParameters = !hasEffectiveRestParameter(target) &&
40364                 (checkMode & 8 ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount);
40365             if (sourceHasMoreParameters) {
40366                 return 0;
40367             }
40368             if (source.typeParameters && source.typeParameters !== target.typeParameters) {
40369                 target = getCanonicalSignature(target);
40370                 source = instantiateSignatureInContextOf(source, target, undefined, compareTypes);
40371             }
40372             var sourceCount = getParameterCount(source);
40373             var sourceRestType = getNonArrayRestType(source);
40374             var targetRestType = getNonArrayRestType(target);
40375             if (sourceRestType || targetRestType) {
40376                 void instantiateType(sourceRestType || targetRestType, reportUnreliableMarkers);
40377             }
40378             if (sourceRestType && targetRestType && sourceCount !== targetCount) {
40379                 return 0;
40380             }
40381             var kind = target.declaration ? target.declaration.kind : 0;
40382             var strictVariance = !(checkMode & 3) && strictFunctionTypes && kind !== 161 &&
40383                 kind !== 160 && kind !== 162;
40384             var result = -1;
40385             var sourceThisType = getThisTypeOfSignature(source);
40386             if (sourceThisType && sourceThisType !== voidType) {
40387                 var targetThisType = getThisTypeOfSignature(target);
40388                 if (targetThisType) {
40389                     var related = !strictVariance && compareTypes(sourceThisType, targetThisType, false)
40390                         || compareTypes(targetThisType, sourceThisType, reportErrors);
40391                     if (!related) {
40392                         if (reportErrors) {
40393                             errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible);
40394                         }
40395                         return 0;
40396                     }
40397                     result &= related;
40398                 }
40399             }
40400             var paramCount = sourceRestType || targetRestType ? Math.min(sourceCount, targetCount) : Math.max(sourceCount, targetCount);
40401             var restIndex = sourceRestType || targetRestType ? paramCount - 1 : -1;
40402             for (var i = 0; i < paramCount; i++) {
40403                 var sourceType = i === restIndex ? getRestTypeAtPosition(source, i) : getTypeAtPosition(source, i);
40404                 var targetType = i === restIndex ? getRestTypeAtPosition(target, i) : getTypeAtPosition(target, i);
40405                 var sourceSig = checkMode & 3 ? undefined : getSingleCallSignature(getNonNullableType(sourceType));
40406                 var targetSig = checkMode & 3 ? undefined : getSingleCallSignature(getNonNullableType(targetType));
40407                 var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) &&
40408                     (getFalsyFlags(sourceType) & 98304) === (getFalsyFlags(targetType) & 98304);
40409                 var related = callbacks ?
40410                     compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8) | (strictVariance ? 2 : 1), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) :
40411                     !(checkMode & 3) && !strictVariance && compareTypes(sourceType, targetType, false) || compareTypes(targetType, sourceType, reportErrors);
40412                 if (related && checkMode & 8 && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, false)) {
40413                     related = 0;
40414                 }
40415                 if (!related) {
40416                     if (reportErrors) {
40417                         errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i)));
40418                     }
40419                     return 0;
40420                 }
40421                 result &= related;
40422             }
40423             if (!(checkMode & 4)) {
40424                 var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType
40425                     : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(target.declaration.symbol))
40426                         : getReturnTypeOfSignature(target);
40427                 if (targetReturnType === voidType) {
40428                     return result;
40429                 }
40430                 var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType
40431                     : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(source.declaration.symbol))
40432                         : getReturnTypeOfSignature(source);
40433                 var targetTypePredicate = getTypePredicateOfSignature(target);
40434                 if (targetTypePredicate) {
40435                     var sourceTypePredicate = getTypePredicateOfSignature(source);
40436                     if (sourceTypePredicate) {
40437                         result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, reportErrors, errorReporter, compareTypes);
40438                     }
40439                     else if (ts.isIdentifierTypePredicate(targetTypePredicate)) {
40440                         if (reportErrors) {
40441                             errorReporter(ts.Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source));
40442                         }
40443                         return 0;
40444                     }
40445                 }
40446                 else {
40447                     result &= checkMode & 1 && compareTypes(targetReturnType, sourceReturnType, false) ||
40448                         compareTypes(sourceReturnType, targetReturnType, reportErrors);
40449                     if (!result && reportErrors && incompatibleErrorReporter) {
40450                         incompatibleErrorReporter(sourceReturnType, targetReturnType);
40451                     }
40452                 }
40453             }
40454             return result;
40455         }
40456         function compareTypePredicateRelatedTo(source, target, reportErrors, errorReporter, compareTypes) {
40457             if (source.kind !== target.kind) {
40458                 if (reportErrors) {
40459                     errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard);
40460                     errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
40461                 }
40462                 return 0;
40463             }
40464             if (source.kind === 1 || source.kind === 3) {
40465                 if (source.parameterIndex !== target.parameterIndex) {
40466                     if (reportErrors) {
40467                         errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName);
40468                         errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
40469                     }
40470                     return 0;
40471                 }
40472             }
40473             var related = source.type === target.type ? -1 :
40474                 source.type && target.type ? compareTypes(source.type, target.type, reportErrors) :
40475                     0;
40476             if (related === 0 && reportErrors) {
40477                 errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
40478             }
40479             return related;
40480         }
40481         function isImplementationCompatibleWithOverload(implementation, overload) {
40482             var erasedSource = getErasedSignature(implementation);
40483             var erasedTarget = getErasedSignature(overload);
40484             var sourceReturnType = getReturnTypeOfSignature(erasedSource);
40485             var targetReturnType = getReturnTypeOfSignature(erasedTarget);
40486             if (targetReturnType === voidType
40487                 || isTypeRelatedTo(targetReturnType, sourceReturnType, assignableRelation)
40488                 || isTypeRelatedTo(sourceReturnType, targetReturnType, assignableRelation)) {
40489                 return isSignatureAssignableTo(erasedSource, erasedTarget, true);
40490             }
40491             return false;
40492         }
40493         function isEmptyResolvedType(t) {
40494             return t !== anyFunctionType &&
40495                 t.properties.length === 0 &&
40496                 t.callSignatures.length === 0 &&
40497                 t.constructSignatures.length === 0 &&
40498                 !t.stringIndexInfo &&
40499                 !t.numberIndexInfo;
40500         }
40501         function isEmptyObjectType(type) {
40502             return type.flags & 524288 ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) :
40503                 type.flags & 67108864 ? true :
40504                     type.flags & 1048576 ? ts.some(type.types, isEmptyObjectType) :
40505                         type.flags & 2097152 ? ts.every(type.types, isEmptyObjectType) :
40506                             false;
40507         }
40508         function isEmptyAnonymousObjectType(type) {
40509             return !!(ts.getObjectFlags(type) & 16) && isEmptyObjectType(type);
40510         }
40511         function isStringIndexSignatureOnlyType(type) {
40512             return type.flags & 524288 && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfoOfType(type, 0) && !getIndexInfoOfType(type, 1) ||
40513                 type.flags & 3145728 && ts.every(type.types, isStringIndexSignatureOnlyType) ||
40514                 false;
40515         }
40516         function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) {
40517             if (sourceSymbol === targetSymbol) {
40518                 return true;
40519             }
40520             var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol);
40521             var entry = enumRelation.get(id);
40522             if (entry !== undefined && !(!(entry & 4) && entry & 2 && errorReporter)) {
40523                 return !!(entry & 1);
40524             }
40525             if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256) || !(targetSymbol.flags & 256)) {
40526                 enumRelation.set(id, 2 | 4);
40527                 return false;
40528             }
40529             var targetEnumType = getTypeOfSymbol(targetSymbol);
40530             for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(sourceSymbol)); _i < _a.length; _i++) {
40531                 var property = _a[_i];
40532                 if (property.flags & 8) {
40533                     var targetProperty = getPropertyOfType(targetEnumType, property.escapedName);
40534                     if (!targetProperty || !(targetProperty.flags & 8)) {
40535                         if (errorReporter) {
40536                             errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), undefined, 64));
40537                             enumRelation.set(id, 2 | 4);
40538                         }
40539                         else {
40540                             enumRelation.set(id, 2);
40541                         }
40542                         return false;
40543                     }
40544                 }
40545             }
40546             enumRelation.set(id, 1);
40547             return true;
40548         }
40549         function isSimpleTypeRelatedTo(source, target, relation, errorReporter) {
40550             var s = source.flags;
40551             var t = target.flags;
40552             if (t & 3 || s & 131072 || source === wildcardType)
40553                 return true;
40554             if (t & 131072)
40555                 return false;
40556             if (s & 132 && t & 4)
40557                 return true;
40558             if (s & 128 && s & 1024 &&
40559                 t & 128 && !(t & 1024) &&
40560                 source.value === target.value)
40561                 return true;
40562             if (s & 296 && t & 8)
40563                 return true;
40564             if (s & 256 && s & 1024 &&
40565                 t & 256 && !(t & 1024) &&
40566                 source.value === target.value)
40567                 return true;
40568             if (s & 2112 && t & 64)
40569                 return true;
40570             if (s & 528 && t & 16)
40571                 return true;
40572             if (s & 12288 && t & 4096)
40573                 return true;
40574             if (s & 32 && t & 32 && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter))
40575                 return true;
40576             if (s & 1024 && t & 1024) {
40577                 if (s & 1048576 && t & 1048576 && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter))
40578                     return true;
40579                 if (s & 2944 && t & 2944 &&
40580                     source.value === target.value &&
40581                     isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter))
40582                     return true;
40583             }
40584             if (s & 32768 && (!strictNullChecks || t & (32768 | 16384)))
40585                 return true;
40586             if (s & 65536 && (!strictNullChecks || t & 65536))
40587                 return true;
40588             if (s & 524288 && t & 67108864)
40589                 return true;
40590             if (relation === assignableRelation || relation === comparableRelation) {
40591                 if (s & 1)
40592                     return true;
40593                 if (s & (8 | 256) && !(s & 1024) && (t & 32 || t & 256 && t & 1024))
40594                     return true;
40595             }
40596             return false;
40597         }
40598         function isTypeRelatedTo(source, target, relation) {
40599             if (isFreshLiteralType(source)) {
40600                 source = source.regularType;
40601             }
40602             if (isFreshLiteralType(target)) {
40603                 target = target.regularType;
40604             }
40605             if (source === target) {
40606                 return true;
40607             }
40608             if (relation !== identityRelation) {
40609                 if (relation === comparableRelation && !(target.flags & 131072) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) {
40610                     return true;
40611                 }
40612             }
40613             else {
40614                 if (!(source.flags & 3145728) && !(target.flags & 3145728) &&
40615                     source.flags !== target.flags && !(source.flags & 66584576))
40616                     return false;
40617             }
40618             if (source.flags & 524288 && target.flags & 524288) {
40619                 var related = relation.get(getRelationKey(source, target, 0, relation));
40620                 if (related !== undefined) {
40621                     return !!(related & 1);
40622                 }
40623             }
40624             if (source.flags & 66846720 || target.flags & 66846720) {
40625                 return checkTypeRelatedTo(source, target, relation, undefined);
40626             }
40627             return false;
40628         }
40629         function isIgnoredJsxProperty(source, sourceProp) {
40630             return ts.getObjectFlags(source) & 4096 && !isUnhyphenatedJsxName(sourceProp.escapedName);
40631         }
40632         function getNormalizedType(type, writing) {
40633             while (true) {
40634                 var t = isFreshLiteralType(type) ? type.regularType :
40635                     ts.getObjectFlags(type) & 4 && type.node ? createTypeReference(type.target, getTypeArguments(type)) :
40636                         type.flags & 3145728 ? getReducedType(type) :
40637                             type.flags & 33554432 ? writing ? type.baseType : type.substitute :
40638                                 type.flags & 25165824 ? getSimplifiedType(type, writing) :
40639                                     type;
40640                 if (t === type)
40641                     break;
40642                 type = t;
40643             }
40644             return type;
40645         }
40646         function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) {
40647             var errorInfo;
40648             var relatedInfo;
40649             var maybeKeys;
40650             var sourceStack;
40651             var targetStack;
40652             var maybeCount = 0;
40653             var depth = 0;
40654             var expandingFlags = 0;
40655             var overflow = false;
40656             var overrideNextErrorInfo = 0;
40657             var lastSkippedInfo;
40658             var incompatibleStack = [];
40659             var inPropertyCheck = false;
40660             ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
40661             var result = isRelatedTo(source, target, !!errorNode, headMessage);
40662             if (incompatibleStack.length) {
40663                 reportIncompatibleStack();
40664             }
40665             if (overflow) {
40666                 var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target));
40667                 if (errorOutputContainer) {
40668                     (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
40669                 }
40670             }
40671             else if (errorInfo) {
40672                 if (containingMessageChain) {
40673                     var chain = containingMessageChain();
40674                     if (chain) {
40675                         ts.concatenateDiagnosticMessageChains(chain, errorInfo);
40676                         errorInfo = chain;
40677                     }
40678                 }
40679                 var relatedInformation = void 0;
40680                 if (headMessage && errorNode && !result && source.symbol) {
40681                     var links = getSymbolLinks(source.symbol);
40682                     if (links.originatingImport && !ts.isImportCall(links.originatingImport)) {
40683                         var helpfulRetry = checkTypeRelatedTo(getTypeOfSymbol(links.target), target, relation, undefined);
40684                         if (helpfulRetry) {
40685                             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);
40686                             relatedInformation = ts.append(relatedInformation, diag_1);
40687                         }
40688                     }
40689                 }
40690                 var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation);
40691                 if (relatedInfo) {
40692                     ts.addRelatedInfo.apply(void 0, __spreadArrays([diag], relatedInfo));
40693                 }
40694                 if (errorOutputContainer) {
40695                     (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
40696                 }
40697                 if (!errorOutputContainer || !errorOutputContainer.skipLogging) {
40698                     diagnostics.add(diag);
40699                 }
40700             }
40701             if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0) {
40702                 ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error.");
40703             }
40704             return result !== 0;
40705             function resetErrorInfo(saved) {
40706                 errorInfo = saved.errorInfo;
40707                 lastSkippedInfo = saved.lastSkippedInfo;
40708                 incompatibleStack = saved.incompatibleStack;
40709                 overrideNextErrorInfo = saved.overrideNextErrorInfo;
40710                 relatedInfo = saved.relatedInfo;
40711             }
40712             function captureErrorCalculationState() {
40713                 return {
40714                     errorInfo: errorInfo,
40715                     lastSkippedInfo: lastSkippedInfo,
40716                     incompatibleStack: incompatibleStack.slice(),
40717                     overrideNextErrorInfo: overrideNextErrorInfo,
40718                     relatedInfo: !relatedInfo ? undefined : relatedInfo.slice()
40719                 };
40720             }
40721             function reportIncompatibleError(message, arg0, arg1, arg2, arg3) {
40722                 overrideNextErrorInfo++;
40723                 lastSkippedInfo = undefined;
40724                 incompatibleStack.push([message, arg0, arg1, arg2, arg3]);
40725             }
40726             function reportIncompatibleStack() {
40727                 var stack = incompatibleStack;
40728                 incompatibleStack = [];
40729                 var info = lastSkippedInfo;
40730                 lastSkippedInfo = undefined;
40731                 if (stack.length === 1) {
40732                     reportError.apply(void 0, stack[0]);
40733                     if (info) {
40734                         reportRelationError.apply(void 0, __spreadArrays([undefined], info));
40735                     }
40736                     return;
40737                 }
40738                 var path = "";
40739                 var secondaryRootErrors = [];
40740                 while (stack.length) {
40741                     var _a = stack.pop(), msg = _a[0], args = _a.slice(1);
40742                     switch (msg.code) {
40743                         case ts.Diagnostics.Types_of_property_0_are_incompatible.code: {
40744                             if (path.indexOf("new ") === 0) {
40745                                 path = "(" + path + ")";
40746                             }
40747                             var str = "" + args[0];
40748                             if (path.length === 0) {
40749                                 path = "" + str;
40750                             }
40751                             else if (ts.isIdentifierText(str, compilerOptions.target)) {
40752                                 path = path + "." + str;
40753                             }
40754                             else if (str[0] === "[" && str[str.length - 1] === "]") {
40755                                 path = "" + path + str;
40756                             }
40757                             else {
40758                                 path = path + "[" + str + "]";
40759                             }
40760                             break;
40761                         }
40762                         case ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible.code:
40763                         case ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code:
40764                         case ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code:
40765                         case ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: {
40766                             if (path.length === 0) {
40767                                 var mappedMsg = msg;
40768                                 if (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) {
40769                                     mappedMsg = ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible;
40770                                 }
40771                                 else if (msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) {
40772                                     mappedMsg = ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible;
40773                                 }
40774                                 secondaryRootErrors.unshift([mappedMsg, args[0], args[1]]);
40775                             }
40776                             else {
40777                                 var prefix = (msg.code === ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code ||
40778                                     msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code)
40779                                     ? "new "
40780                                     : "";
40781                                 var params = (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code ||
40782                                     msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code)
40783                                     ? ""
40784                                     : "...";
40785                                 path = "" + prefix + path + "(" + params + ")";
40786                             }
40787                             break;
40788                         }
40789                         default:
40790                             return ts.Debug.fail("Unhandled Diagnostic: " + msg.code);
40791                     }
40792                 }
40793                 if (path) {
40794                     reportError(path[path.length - 1] === ")"
40795                         ? ts.Diagnostics.The_types_returned_by_0_are_incompatible_between_these_types
40796                         : ts.Diagnostics.The_types_of_0_are_incompatible_between_these_types, path);
40797                 }
40798                 else {
40799                     secondaryRootErrors.shift();
40800                 }
40801                 for (var _i = 0, secondaryRootErrors_1 = secondaryRootErrors; _i < secondaryRootErrors_1.length; _i++) {
40802                     var _b = secondaryRootErrors_1[_i], msg = _b[0], args = _b.slice(1);
40803                     var originalValue = msg.elidedInCompatabilityPyramid;
40804                     msg.elidedInCompatabilityPyramid = false;
40805                     reportError.apply(void 0, __spreadArrays([msg], args));
40806                     msg.elidedInCompatabilityPyramid = originalValue;
40807                 }
40808                 if (info) {
40809                     reportRelationError.apply(void 0, __spreadArrays([undefined], info));
40810                 }
40811             }
40812             function reportError(message, arg0, arg1, arg2, arg3) {
40813                 ts.Debug.assert(!!errorNode);
40814                 if (incompatibleStack.length)
40815                     reportIncompatibleStack();
40816                 if (message.elidedInCompatabilityPyramid)
40817                     return;
40818                 errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2, arg3);
40819             }
40820             function associateRelatedInfo(info) {
40821                 ts.Debug.assert(!!errorInfo);
40822                 if (!relatedInfo) {
40823                     relatedInfo = [info];
40824                 }
40825                 else {
40826                     relatedInfo.push(info);
40827                 }
40828             }
40829             function reportRelationError(message, source, target) {
40830                 if (incompatibleStack.length)
40831                     reportIncompatibleStack();
40832                 var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1];
40833                 if (target.flags & 262144) {
40834                     var constraint = getBaseConstraintOfType(target);
40835                     var constraintElab = constraint && isTypeAssignableTo(source, constraint);
40836                     if (constraintElab) {
40837                         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));
40838                     }
40839                     else {
40840                         reportError(ts.Diagnostics._0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1, targetType, sourceType);
40841                     }
40842                 }
40843                 if (!message) {
40844                     if (relation === comparableRelation) {
40845                         message = ts.Diagnostics.Type_0_is_not_comparable_to_type_1;
40846                     }
40847                     else if (sourceType === targetType) {
40848                         message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated;
40849                     }
40850                     else {
40851                         message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1;
40852                     }
40853                 }
40854                 reportError(message, sourceType, targetType);
40855             }
40856             function tryElaborateErrorsForPrimitivesAndObjects(source, target) {
40857                 var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source);
40858                 var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target);
40859                 if ((globalStringType === source && stringType === target) ||
40860                     (globalNumberType === source && numberType === target) ||
40861                     (globalBooleanType === source && booleanType === target) ||
40862                     (getGlobalESSymbolType(false) === source && esSymbolType === target)) {
40863                     reportError(ts.Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType);
40864                 }
40865             }
40866             function tryElaborateArrayLikeErrors(source, target, reportErrors) {
40867                 if (isTupleType(source)) {
40868                     if (source.target.readonly && isMutableArrayOrTuple(target)) {
40869                         if (reportErrors) {
40870                             reportError(ts.Diagnostics.The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1, typeToString(source), typeToString(target));
40871                         }
40872                         return false;
40873                     }
40874                     return isTupleType(target) || isArrayType(target);
40875                 }
40876                 if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) {
40877                     if (reportErrors) {
40878                         reportError(ts.Diagnostics.The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1, typeToString(source), typeToString(target));
40879                     }
40880                     return false;
40881                 }
40882                 if (isTupleType(target)) {
40883                     return isArrayType(source);
40884                 }
40885                 return true;
40886             }
40887             function isRelatedTo(originalSource, originalTarget, reportErrors, headMessage, intersectionState) {
40888                 if (reportErrors === void 0) { reportErrors = false; }
40889                 if (intersectionState === void 0) { intersectionState = 0; }
40890                 if (originalSource.flags & 524288 && originalTarget.flags & 131068) {
40891                     if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) {
40892                         return -1;
40893                     }
40894                     reportErrorResults(originalSource, originalTarget, 0, !!(ts.getObjectFlags(originalSource) & 4096));
40895                     return 0;
40896                 }
40897                 var source = getNormalizedType(originalSource, false);
40898                 var target = getNormalizedType(originalTarget, true);
40899                 if (source === target)
40900                     return -1;
40901                 if (relation === identityRelation) {
40902                     return isIdenticalTo(source, target);
40903                 }
40904                 if (source.flags & 262144 && getConstraintOfType(source) === target) {
40905                     return -1;
40906                 }
40907                 if (target.flags & 1048576 && source.flags & 524288 &&
40908                     target.types.length <= 3 && maybeTypeOfKind(target, 98304)) {
40909                     var nullStrippedTarget = extractTypesOfKind(target, ~98304);
40910                     if (!(nullStrippedTarget.flags & (1048576 | 131072))) {
40911                         if (source === nullStrippedTarget)
40912                             return -1;
40913                         target = nullStrippedTarget;
40914                     }
40915                 }
40916                 if (relation === comparableRelation && !(target.flags & 131072) && isSimpleTypeRelatedTo(target, source, relation) ||
40917                     isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined))
40918                     return -1;
40919                 var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096);
40920                 var isPerformingExcessPropertyChecks = !(intersectionState & 2) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768);
40921                 if (isPerformingExcessPropertyChecks) {
40922                     if (hasExcessProperties(source, target, reportErrors)) {
40923                         if (reportErrors) {
40924                             reportRelationError(headMessage, source, target);
40925                         }
40926                         return 0;
40927                     }
40928                 }
40929                 var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2) &&
40930                     source.flags & (131068 | 524288 | 2097152) && source !== globalObjectType &&
40931                     target.flags & (524288 | 2097152) && isWeakType(target) &&
40932                     (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
40933                 if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) {
40934                     if (reportErrors) {
40935                         var calls = getSignaturesOfType(source, 0);
40936                         var constructs = getSignaturesOfType(source, 1);
40937                         if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, false) ||
40938                             constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, false)) {
40939                             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));
40940                         }
40941                         else {
40942                             reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, typeToString(source), typeToString(target));
40943                         }
40944                     }
40945                     return 0;
40946                 }
40947                 var result = 0;
40948                 var saveErrorInfo = captureErrorCalculationState();
40949                 if (source.flags & 1048576) {
40950                     result = relation === comparableRelation ?
40951                         someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068), intersectionState) :
40952                         eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068), intersectionState);
40953                 }
40954                 else {
40955                     if (target.flags & 1048576) {
40956                         result = typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068) && !(target.flags & 131068));
40957                     }
40958                     else if (target.flags & 2097152) {
40959                         result = typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2);
40960                     }
40961                     else if (source.flags & 2097152) {
40962                         result = someTypeRelatedToType(source, target, false, 1);
40963                     }
40964                     if (!result && (source.flags & 66846720 || target.flags & 66846720)) {
40965                         if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState)) {
40966                             resetErrorInfo(saveErrorInfo);
40967                         }
40968                     }
40969                 }
40970                 if (!result && source.flags & (2097152 | 262144)) {
40971                     var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 ? source.types : [source], !!(target.flags & 1048576));
40972                     if (constraint && (source.flags & 2097152 || target.flags & 1048576)) {
40973                         if (everyType(constraint, function (c) { return c !== source; })) {
40974                             if (result = isRelatedTo(constraint, target, false, undefined, intersectionState)) {
40975                                 resetErrorInfo(saveErrorInfo);
40976                             }
40977                         }
40978                     }
40979                 }
40980                 if (result && !inPropertyCheck && (target.flags & 2097152 && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
40981                     isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 && getApparentType(source).flags & 3670016 && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152); }))) {
40982                     inPropertyCheck = true;
40983                     result &= recursiveTypeRelatedTo(source, target, reportErrors, 4);
40984                     inPropertyCheck = false;
40985                 }
40986                 reportErrorResults(source, target, result, isComparingJsxAttributes);
40987                 return result;
40988                 function reportErrorResults(source, target, result, isComparingJsxAttributes) {
40989                     if (!result && reportErrors) {
40990                         source = originalSource.aliasSymbol ? originalSource : source;
40991                         target = originalTarget.aliasSymbol ? originalTarget : target;
40992                         var maybeSuppress = overrideNextErrorInfo > 0;
40993                         if (maybeSuppress) {
40994                             overrideNextErrorInfo--;
40995                         }
40996                         if (source.flags & 524288 && target.flags & 524288) {
40997                             var currentError = errorInfo;
40998                             tryElaborateArrayLikeErrors(source, target, reportErrors);
40999                             if (errorInfo !== currentError) {
41000                                 maybeSuppress = !!errorInfo;
41001                             }
41002                         }
41003                         if (source.flags & 524288 && target.flags & 131068) {
41004                             tryElaborateErrorsForPrimitivesAndObjects(source, target);
41005                         }
41006                         else if (source.symbol && source.flags & 524288 && globalObjectType === source) {
41007                             reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
41008                         }
41009                         else if (isComparingJsxAttributes && target.flags & 2097152) {
41010                             var targetTypes = target.types;
41011                             var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
41012                             var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
41013                             if (intrinsicAttributes !== errorType && intrinsicClassAttributes !== errorType &&
41014                                 (ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
41015                                 return result;
41016                             }
41017                         }
41018                         else {
41019                             errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
41020                         }
41021                         if (!headMessage && maybeSuppress) {
41022                             lastSkippedInfo = [source, target];
41023                             return result;
41024                         }
41025                         reportRelationError(headMessage, source, target);
41026                     }
41027                 }
41028             }
41029             function isIdenticalTo(source, target) {
41030                 var flags = source.flags & target.flags;
41031                 if (!(flags & 66584576)) {
41032                     return 0;
41033                 }
41034                 if (flags & 3145728) {
41035                     var result_5 = eachTypeRelatedToSomeType(source, target);
41036                     if (result_5) {
41037                         result_5 &= eachTypeRelatedToSomeType(target, source);
41038                     }
41039                     return result_5;
41040                 }
41041                 return recursiveTypeRelatedTo(source, target, false, 0);
41042             }
41043             function getTypeOfPropertyInTypes(types, name) {
41044                 var appendPropType = function (propTypes, type) {
41045                     type = getApparentType(type);
41046                     var prop = type.flags & 3145728 ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name);
41047                     var propType = prop && getTypeOfSymbol(prop) || isNumericLiteralName(name) && getIndexTypeOfType(type, 1) || getIndexTypeOfType(type, 0) || undefinedType;
41048                     return ts.append(propTypes, propType);
41049                 };
41050                 return getUnionType(ts.reduceLeft(types, appendPropType, undefined) || ts.emptyArray);
41051             }
41052             function hasExcessProperties(source, target, reportErrors) {
41053                 if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 16384) {
41054                     return false;
41055                 }
41056                 var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096);
41057                 if ((relation === assignableRelation || relation === comparableRelation) &&
41058                     (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) {
41059                     return false;
41060                 }
41061                 var reducedTarget = target;
41062                 var checkTypes;
41063                 if (target.flags & 1048576) {
41064                     reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
41065                     checkTypes = reducedTarget.flags & 1048576 ? reducedTarget.types : [reducedTarget];
41066                 }
41067                 var _loop_13 = function (prop) {
41068                     if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
41069                         if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
41070                             if (reportErrors) {
41071                                 var errorTarget = filterType(reducedTarget, isExcessPropertyCheckTarget);
41072                                 if (!errorNode)
41073                                     return { value: ts.Debug.fail() };
41074                                 if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode) || ts.isJsxOpeningLikeElement(errorNode.parent)) {
41075                                     if (prop.valueDeclaration && ts.isJsxAttribute(prop.valueDeclaration) && ts.getSourceFileOfNode(errorNode) === ts.getSourceFileOfNode(prop.valueDeclaration.name)) {
41076                                         errorNode = prop.valueDeclaration.name;
41077                                     }
41078                                     reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(errorTarget));
41079                                 }
41080                                 else {
41081                                     var objectLiteralDeclaration_1 = source.symbol && ts.firstOrUndefined(source.symbol.declarations);
41082                                     var suggestion = void 0;
41083                                     if (prop.valueDeclaration && ts.findAncestor(prop.valueDeclaration, function (d) { return d === objectLiteralDeclaration_1; }) && ts.getSourceFileOfNode(objectLiteralDeclaration_1) === ts.getSourceFileOfNode(errorNode)) {
41084                                         var propDeclaration = prop.valueDeclaration;
41085                                         ts.Debug.assertNode(propDeclaration, ts.isObjectLiteralElementLike);
41086                                         errorNode = propDeclaration;
41087                                         var name = propDeclaration.name;
41088                                         if (ts.isIdentifier(name)) {
41089                                             suggestion = getSuggestionForNonexistentProperty(name, errorTarget);
41090                                         }
41091                                     }
41092                                     if (suggestion !== undefined) {
41093                                         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);
41094                                     }
41095                                     else {
41096                                         reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(errorTarget));
41097                                     }
41098                                 }
41099                             }
41100                             return { value: true };
41101                         }
41102                         if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), reportErrors)) {
41103                             if (reportErrors) {
41104                                 reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(prop));
41105                             }
41106                             return { value: true };
41107                         }
41108                     }
41109                 };
41110                 for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) {
41111                     var prop = _a[_i];
41112                     var state_5 = _loop_13(prop);
41113                     if (typeof state_5 === "object")
41114                         return state_5.value;
41115                 }
41116                 return false;
41117             }
41118             function shouldCheckAsExcessProperty(prop, container) {
41119                 return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration;
41120             }
41121             function eachTypeRelatedToSomeType(source, target) {
41122                 var result = -1;
41123                 var sourceTypes = source.types;
41124                 for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) {
41125                     var sourceType = sourceTypes_1[_i];
41126                     var related = typeRelatedToSomeType(sourceType, target, false);
41127                     if (!related) {
41128                         return 0;
41129                     }
41130                     result &= related;
41131                 }
41132                 return result;
41133             }
41134             function typeRelatedToSomeType(source, target, reportErrors) {
41135                 var targetTypes = target.types;
41136                 if (target.flags & 1048576 && containsType(targetTypes, source)) {
41137                     return -1;
41138                 }
41139                 for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) {
41140                     var type = targetTypes_1[_i];
41141                     var related = isRelatedTo(source, type, false);
41142                     if (related) {
41143                         return related;
41144                     }
41145                 }
41146                 if (reportErrors) {
41147                     var bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
41148                     isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], true);
41149                 }
41150                 return 0;
41151             }
41152             function typeRelatedToEachType(source, target, reportErrors, intersectionState) {
41153                 var result = -1;
41154                 var targetTypes = target.types;
41155                 for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) {
41156                     var targetType = targetTypes_2[_i];
41157                     var related = isRelatedTo(source, targetType, reportErrors, undefined, intersectionState);
41158                     if (!related) {
41159                         return 0;
41160                     }
41161                     result &= related;
41162                 }
41163                 return result;
41164             }
41165             function someTypeRelatedToType(source, target, reportErrors, intersectionState) {
41166                 var sourceTypes = source.types;
41167                 if (source.flags & 1048576 && containsType(sourceTypes, target)) {
41168                     return -1;
41169                 }
41170                 var len = sourceTypes.length;
41171                 for (var i = 0; i < len; i++) {
41172                     var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, undefined, intersectionState);
41173                     if (related) {
41174                         return related;
41175                     }
41176                 }
41177                 return 0;
41178             }
41179             function eachTypeRelatedToType(source, target, reportErrors, intersectionState) {
41180                 var result = -1;
41181                 var sourceTypes = source.types;
41182                 for (var i = 0; i < sourceTypes.length; i++) {
41183                     var sourceType = sourceTypes[i];
41184                     if (target.flags & 1048576 && target.types.length === sourceTypes.length) {
41185                         var related_1 = isRelatedTo(sourceType, target.types[i], false, undefined, intersectionState);
41186                         if (related_1) {
41187                             result &= related_1;
41188                             continue;
41189                         }
41190                     }
41191                     var related = isRelatedTo(sourceType, target, reportErrors, undefined, intersectionState);
41192                     if (!related) {
41193                         return 0;
41194                     }
41195                     result &= related;
41196                 }
41197                 return result;
41198             }
41199             function typeArgumentsRelatedTo(sources, targets, variances, reportErrors, intersectionState) {
41200                 if (sources === void 0) { sources = ts.emptyArray; }
41201                 if (targets === void 0) { targets = ts.emptyArray; }
41202                 if (variances === void 0) { variances = ts.emptyArray; }
41203                 if (sources.length !== targets.length && relation === identityRelation) {
41204                     return 0;
41205                 }
41206                 var length = sources.length <= targets.length ? sources.length : targets.length;
41207                 var result = -1;
41208                 for (var i = 0; i < length; i++) {
41209                     var varianceFlags = i < variances.length ? variances[i] : 1;
41210                     var variance = varianceFlags & 7;
41211                     if (variance !== 4) {
41212                         var s = sources[i];
41213                         var t = targets[i];
41214                         var related = -1;
41215                         if (varianceFlags & 8) {
41216                             related = relation === identityRelation ? isRelatedTo(s, t, false) : compareTypesIdentical(s, t);
41217                         }
41218                         else if (variance === 1) {
41219                             related = isRelatedTo(s, t, reportErrors, undefined, intersectionState);
41220                         }
41221                         else if (variance === 2) {
41222                             related = isRelatedTo(t, s, reportErrors, undefined, intersectionState);
41223                         }
41224                         else if (variance === 3) {
41225                             related = isRelatedTo(t, s, false);
41226                             if (!related) {
41227                                 related = isRelatedTo(s, t, reportErrors, undefined, intersectionState);
41228                             }
41229                         }
41230                         else {
41231                             related = isRelatedTo(s, t, reportErrors, undefined, intersectionState);
41232                             if (related) {
41233                                 related &= isRelatedTo(t, s, reportErrors, undefined, intersectionState);
41234                             }
41235                         }
41236                         if (!related) {
41237                             return 0;
41238                         }
41239                         result &= related;
41240                     }
41241                 }
41242                 return result;
41243             }
41244             function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState) {
41245                 if (overflow) {
41246                     return 0;
41247                 }
41248                 var id = getRelationKey(source, target, intersectionState | (inPropertyCheck ? 8 : 0), relation);
41249                 var entry = relation.get(id);
41250                 if (entry !== undefined) {
41251                     if (reportErrors && entry & 2 && !(entry & 4)) {
41252                     }
41253                     else {
41254                         if (outofbandVarianceMarkerHandler) {
41255                             var saved = entry & 24;
41256                             if (saved & 8) {
41257                                 instantiateType(source, makeFunctionTypeMapper(reportUnmeasurableMarkers));
41258                             }
41259                             if (saved & 16) {
41260                                 instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers));
41261                             }
41262                         }
41263                         return entry & 1 ? -1 : 0;
41264                     }
41265                 }
41266                 if (!maybeKeys) {
41267                     maybeKeys = [];
41268                     sourceStack = [];
41269                     targetStack = [];
41270                 }
41271                 else {
41272                     for (var i = 0; i < maybeCount; i++) {
41273                         if (id === maybeKeys[i]) {
41274                             return 1;
41275                         }
41276                     }
41277                     if (depth === 100) {
41278                         overflow = true;
41279                         return 0;
41280                     }
41281                 }
41282                 var maybeStart = maybeCount;
41283                 maybeKeys[maybeCount] = id;
41284                 maybeCount++;
41285                 sourceStack[depth] = source;
41286                 targetStack[depth] = target;
41287                 depth++;
41288                 var saveExpandingFlags = expandingFlags;
41289                 if (!(expandingFlags & 1) && isDeeplyNestedType(source, sourceStack, depth))
41290                     expandingFlags |= 1;
41291                 if (!(expandingFlags & 2) && isDeeplyNestedType(target, targetStack, depth))
41292                     expandingFlags |= 2;
41293                 var originalHandler;
41294                 var propagatingVarianceFlags = 0;
41295                 if (outofbandVarianceMarkerHandler) {
41296                     originalHandler = outofbandVarianceMarkerHandler;
41297                     outofbandVarianceMarkerHandler = function (onlyUnreliable) {
41298                         propagatingVarianceFlags |= onlyUnreliable ? 16 : 8;
41299                         return originalHandler(onlyUnreliable);
41300                     };
41301                 }
41302                 var result = expandingFlags !== 3 ? structuredTypeRelatedTo(source, target, reportErrors, intersectionState) : 1;
41303                 if (outofbandVarianceMarkerHandler) {
41304                     outofbandVarianceMarkerHandler = originalHandler;
41305                 }
41306                 expandingFlags = saveExpandingFlags;
41307                 depth--;
41308                 if (result) {
41309                     if (result === -1 || depth === 0) {
41310                         for (var i = maybeStart; i < maybeCount; i++) {
41311                             relation.set(maybeKeys[i], 1 | propagatingVarianceFlags);
41312                         }
41313                         maybeCount = maybeStart;
41314                     }
41315                 }
41316                 else {
41317                     relation.set(id, (reportErrors ? 4 : 0) | 2 | propagatingVarianceFlags);
41318                     maybeCount = maybeStart;
41319                 }
41320                 return result;
41321             }
41322             function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
41323                 if (intersectionState & 4) {
41324                     return propertiesRelatedTo(source, target, reportErrors, undefined, 0);
41325                 }
41326                 var flags = source.flags & target.flags;
41327                 if (relation === identityRelation && !(flags & 524288)) {
41328                     if (flags & 4194304) {
41329                         return isRelatedTo(source.type, target.type, false);
41330                     }
41331                     var result_6 = 0;
41332                     if (flags & 8388608) {
41333                         if (result_6 = isRelatedTo(source.objectType, target.objectType, false)) {
41334                             if (result_6 &= isRelatedTo(source.indexType, target.indexType, false)) {
41335                                 return result_6;
41336                             }
41337                         }
41338                     }
41339                     if (flags & 16777216) {
41340                         if (source.root.isDistributive === target.root.isDistributive) {
41341                             if (result_6 = isRelatedTo(source.checkType, target.checkType, false)) {
41342                                 if (result_6 &= isRelatedTo(source.extendsType, target.extendsType, false)) {
41343                                     if (result_6 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), false)) {
41344                                         if (result_6 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), false)) {
41345                                             return result_6;
41346                                         }
41347                                     }
41348                                 }
41349                             }
41350                         }
41351                     }
41352                     if (flags & 33554432) {
41353                         return isRelatedTo(source.substitute, target.substitute, false);
41354                     }
41355                     return 0;
41356                 }
41357                 var result;
41358                 var originalErrorInfo;
41359                 var varianceCheckFailed = false;
41360                 var saveErrorInfo = captureErrorCalculationState();
41361                 if (source.flags & (524288 | 16777216) && source.aliasSymbol &&
41362                     source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol &&
41363                     !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) {
41364                     var variances = getAliasVariances(source.aliasSymbol);
41365                     if (variances === ts.emptyArray) {
41366                         return 1;
41367                     }
41368                     var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, intersectionState);
41369                     if (varianceResult !== undefined) {
41370                         return varianceResult;
41371                     }
41372                 }
41373                 if (target.flags & 262144) {
41374                     if (ts.getObjectFlags(source) & 32 && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source))) {
41375                         if (!(getMappedTypeModifiers(source) & 4)) {
41376                             var templateType = getTemplateTypeFromMappedType(source);
41377                             var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source));
41378                             if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) {
41379                                 return result;
41380                             }
41381                         }
41382                     }
41383                 }
41384                 else if (target.flags & 4194304) {
41385                     if (source.flags & 4194304) {
41386                         if (result = isRelatedTo(target.type, source.type, false)) {
41387                             return result;
41388                         }
41389                     }
41390                     var constraint = getSimplifiedTypeOrConstraint(target.type);
41391                     if (constraint) {
41392                         if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), reportErrors) === -1) {
41393                             return -1;
41394                         }
41395                     }
41396                 }
41397                 else if (target.flags & 8388608) {
41398                     if (relation !== identityRelation) {
41399                         var objectType = target.objectType;
41400                         var indexType = target.indexType;
41401                         var baseObjectType = getBaseConstraintOfType(objectType) || objectType;
41402                         var baseIndexType = getBaseConstraintOfType(indexType) || indexType;
41403                         if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) {
41404                             var accessFlags = 2 | (baseObjectType !== objectType ? 1 : 0);
41405                             var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, undefined, accessFlags);
41406                             if (constraint && (result = isRelatedTo(source, constraint, reportErrors))) {
41407                                 return result;
41408                             }
41409                         }
41410                     }
41411                 }
41412                 else if (isGenericMappedType(target)) {
41413                     var template = getTemplateTypeFromMappedType(target);
41414                     var modifiers = getMappedTypeModifiers(target);
41415                     if (!(modifiers & 8)) {
41416                         if (template.flags & 8388608 && template.objectType === source &&
41417                             template.indexType === getTypeParameterFromMappedType(target)) {
41418                             return -1;
41419                         }
41420                         if (!isGenericMappedType(source)) {
41421                             var targetConstraint = getConstraintTypeFromMappedType(target);
41422                             var sourceKeys = getIndexType(source, undefined, true);
41423                             var includeOptional = modifiers & 4;
41424                             var filteredByApplicability = includeOptional ? intersectTypes(targetConstraint, sourceKeys) : undefined;
41425                             if (includeOptional
41426                                 ? !(filteredByApplicability.flags & 131072)
41427                                 : isRelatedTo(targetConstraint, sourceKeys)) {
41428                                 var typeParameter = getTypeParameterFromMappedType(target);
41429                                 var indexingType = filteredByApplicability ? getIntersectionType([filteredByApplicability, typeParameter]) : typeParameter;
41430                                 var indexedAccessType = getIndexedAccessType(source, indexingType);
41431                                 var templateType = getTemplateTypeFromMappedType(target);
41432                                 if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) {
41433                                     return result;
41434                                 }
41435                             }
41436                             originalErrorInfo = errorInfo;
41437                             resetErrorInfo(saveErrorInfo);
41438                         }
41439                     }
41440                 }
41441                 if (source.flags & 8650752) {
41442                     if (source.flags & 8388608 && target.flags & 8388608) {
41443                         if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) {
41444                             result &= isRelatedTo(source.indexType, target.indexType, reportErrors);
41445                         }
41446                         if (result) {
41447                             resetErrorInfo(saveErrorInfo);
41448                             return result;
41449                         }
41450                     }
41451                     else {
41452                         var constraint = getConstraintOfType(source);
41453                         if (!constraint || (source.flags & 262144 && constraint.flags & 1)) {
41454                             if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864))) {
41455                                 resetErrorInfo(saveErrorInfo);
41456                                 return result;
41457                             }
41458                         }
41459                         else if (result = isRelatedTo(constraint, target, false, undefined, intersectionState)) {
41460                             resetErrorInfo(saveErrorInfo);
41461                             return result;
41462                         }
41463                         else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors, undefined, intersectionState)) {
41464                             resetErrorInfo(saveErrorInfo);
41465                             return result;
41466                         }
41467                     }
41468                 }
41469                 else if (source.flags & 4194304) {
41470                     if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) {
41471                         resetErrorInfo(saveErrorInfo);
41472                         return result;
41473                     }
41474                 }
41475                 else if (source.flags & 16777216) {
41476                     if (target.flags & 16777216) {
41477                         var sourceParams = source.root.inferTypeParameters;
41478                         var sourceExtends = source.extendsType;
41479                         var mapper = void 0;
41480                         if (sourceParams) {
41481                             var ctx = createInferenceContext(sourceParams, undefined, 0, isRelatedTo);
41482                             inferTypes(ctx.inferences, target.extendsType, sourceExtends, 128 | 256);
41483                             sourceExtends = instantiateType(sourceExtends, ctx.mapper);
41484                             mapper = ctx.mapper;
41485                         }
41486                         if (isTypeIdenticalTo(sourceExtends, target.extendsType) &&
41487                             (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) {
41488                             if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) {
41489                                 result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors);
41490                             }
41491                             if (result) {
41492                                 resetErrorInfo(saveErrorInfo);
41493                                 return result;
41494                             }
41495                         }
41496                     }
41497                     else {
41498                         var distributiveConstraint = getConstraintOfDistributiveConditionalType(source);
41499                         if (distributiveConstraint) {
41500                             if (result = isRelatedTo(distributiveConstraint, target, reportErrors)) {
41501                                 resetErrorInfo(saveErrorInfo);
41502                                 return result;
41503                             }
41504                         }
41505                     }
41506                     var defaultConstraint = getDefaultConstraintOfConditionalType(source);
41507                     if (defaultConstraint) {
41508                         if (result = isRelatedTo(defaultConstraint, target, reportErrors)) {
41509                             resetErrorInfo(saveErrorInfo);
41510                             return result;
41511                         }
41512                     }
41513                 }
41514                 else {
41515                     if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target) && isEmptyObjectType(source)) {
41516                         return -1;
41517                     }
41518                     if (isGenericMappedType(target)) {
41519                         if (isGenericMappedType(source)) {
41520                             if (result = mappedTypeRelatedTo(source, target, reportErrors)) {
41521                                 resetErrorInfo(saveErrorInfo);
41522                                 return result;
41523                             }
41524                         }
41525                         return 0;
41526                     }
41527                     var sourceIsPrimitive = !!(source.flags & 131068);
41528                     if (relation !== identityRelation) {
41529                         source = getApparentType(source);
41530                     }
41531                     else if (isGenericMappedType(source)) {
41532                         return 0;
41533                     }
41534                     if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && source.target === target.target &&
41535                         !(ts.getObjectFlags(source) & 8192 || ts.getObjectFlags(target) & 8192)) {
41536                         var variances = getVariances(source.target);
41537                         if (variances === ts.emptyArray) {
41538                             return 1;
41539                         }
41540                         var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, intersectionState);
41541                         if (varianceResult !== undefined) {
41542                             return varianceResult;
41543                         }
41544                     }
41545                     else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
41546                         if (relation !== identityRelation) {
41547                             return isRelatedTo(getIndexTypeOfType(source, 1) || anyType, getIndexTypeOfType(target, 1) || anyType, reportErrors);
41548                         }
41549                         else {
41550                             return 0;
41551                         }
41552                     }
41553                     else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 32768 && !isEmptyObjectType(source)) {
41554                         return 0;
41555                     }
41556                     if (source.flags & (524288 | 2097152) && target.flags & 524288) {
41557                         var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive;
41558                         result = propertiesRelatedTo(source, target, reportStructuralErrors, undefined, intersectionState);
41559                         if (result) {
41560                             result &= signaturesRelatedTo(source, target, 0, reportStructuralErrors);
41561                             if (result) {
41562                                 result &= signaturesRelatedTo(source, target, 1, reportStructuralErrors);
41563                                 if (result) {
41564                                     result &= indexTypesRelatedTo(source, target, 0, sourceIsPrimitive, reportStructuralErrors, intersectionState);
41565                                     if (result) {
41566                                         result &= indexTypesRelatedTo(source, target, 1, sourceIsPrimitive, reportStructuralErrors, intersectionState);
41567                                     }
41568                                 }
41569                             }
41570                         }
41571                         if (varianceCheckFailed && result) {
41572                             errorInfo = originalErrorInfo || errorInfo || saveErrorInfo.errorInfo;
41573                         }
41574                         else if (result) {
41575                             return result;
41576                         }
41577                     }
41578                     if (source.flags & (524288 | 2097152) && target.flags & 1048576) {
41579                         var objectOnlyTarget = extractTypesOfKind(target, 524288 | 2097152 | 33554432);
41580                         if (objectOnlyTarget.flags & 1048576) {
41581                             var result_7 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
41582                             if (result_7) {
41583                                 return result_7;
41584                             }
41585                         }
41586                     }
41587                 }
41588                 return 0;
41589                 function relateVariances(sourceTypeArguments, targetTypeArguments, variances, intersectionState) {
41590                     if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, intersectionState)) {
41591                         return result;
41592                     }
41593                     if (ts.some(variances, function (v) { return !!(v & 24); })) {
41594                         originalErrorInfo = undefined;
41595                         resetErrorInfo(saveErrorInfo);
41596                         return undefined;
41597                     }
41598                     var allowStructuralFallback = targetTypeArguments && hasCovariantVoidArgument(targetTypeArguments, variances);
41599                     varianceCheckFailed = !allowStructuralFallback;
41600                     if (variances !== ts.emptyArray && !allowStructuralFallback) {
41601                         if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7) === 0; }))) {
41602                             return 0;
41603                         }
41604                         originalErrorInfo = errorInfo;
41605                         resetErrorInfo(saveErrorInfo);
41606                     }
41607                 }
41608             }
41609             function reportUnmeasurableMarkers(p) {
41610                 if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) {
41611                     outofbandVarianceMarkerHandler(false);
41612                 }
41613                 return p;
41614             }
41615             function reportUnreliableMarkers(p) {
41616                 if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) {
41617                     outofbandVarianceMarkerHandler(true);
41618                 }
41619                 return p;
41620             }
41621             function mappedTypeRelatedTo(source, target, reportErrors) {
41622                 var modifiersRelated = relation === comparableRelation || (relation === identityRelation ? getMappedTypeModifiers(source) === getMappedTypeModifiers(target) :
41623                     getCombinedMappedTypeOptionality(source) <= getCombinedMappedTypeOptionality(target));
41624                 if (modifiersRelated) {
41625                     var result_8;
41626                     var targetConstraint = getConstraintTypeFromMappedType(target);
41627                     var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers));
41628                     if (result_8 = isRelatedTo(targetConstraint, sourceConstraint, reportErrors)) {
41629                         var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]);
41630                         return result_8 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors);
41631                     }
41632                 }
41633                 return 0;
41634             }
41635             function typeRelatedToDiscriminatedType(source, target) {
41636                 var sourceProperties = getPropertiesOfType(source);
41637                 var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
41638                 if (!sourcePropertiesFiltered)
41639                     return 0;
41640                 var numCombinations = 1;
41641                 for (var _i = 0, sourcePropertiesFiltered_1 = sourcePropertiesFiltered; _i < sourcePropertiesFiltered_1.length; _i++) {
41642                     var sourceProperty = sourcePropertiesFiltered_1[_i];
41643                     numCombinations *= countTypes(getTypeOfSymbol(sourceProperty));
41644                     if (numCombinations > 25) {
41645                         return 0;
41646                     }
41647                 }
41648                 var sourceDiscriminantTypes = new Array(sourcePropertiesFiltered.length);
41649                 var excludedProperties = ts.createUnderscoreEscapedMap();
41650                 for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
41651                     var sourceProperty = sourcePropertiesFiltered[i];
41652                     var sourcePropertyType = getTypeOfSymbol(sourceProperty);
41653                     sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576
41654                         ? sourcePropertyType.types
41655                         : [sourcePropertyType];
41656                     excludedProperties.set(sourceProperty.escapedName, true);
41657                 }
41658                 var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
41659                 var matchingTypes = [];
41660                 var _loop_14 = function (combination) {
41661                     var hasMatch = false;
41662                     outer: for (var _i = 0, _a = target.types; _i < _a.length; _i++) {
41663                         var type = _a[_i];
41664                         var _loop_15 = function (i) {
41665                             var sourceProperty = sourcePropertiesFiltered[i];
41666                             var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
41667                             if (!targetProperty)
41668                                 return "continue-outer";
41669                             if (sourceProperty === targetProperty)
41670                                 return "continue";
41671                             var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, false, 0, strictNullChecks || relation === comparableRelation);
41672                             if (!related) {
41673                                 return "continue-outer";
41674                             }
41675                         };
41676                         for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
41677                             var state_7 = _loop_15(i);
41678                             switch (state_7) {
41679                                 case "continue-outer": continue outer;
41680                             }
41681                         }
41682                         ts.pushIfUnique(matchingTypes, type, ts.equateValues);
41683                         hasMatch = true;
41684                     }
41685                     if (!hasMatch) {
41686                         return { value: 0 };
41687                     }
41688                 };
41689                 for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
41690                     var combination = discriminantCombinations_1[_a];
41691                     var state_6 = _loop_14(combination);
41692                     if (typeof state_6 === "object")
41693                         return state_6.value;
41694                 }
41695                 var result = -1;
41696                 for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) {
41697                     var type = matchingTypes_1[_b];
41698                     result &= propertiesRelatedTo(source, type, false, excludedProperties, 0);
41699                     if (result) {
41700                         result &= signaturesRelatedTo(source, type, 0, false);
41701                         if (result) {
41702                             result &= signaturesRelatedTo(source, type, 1, false);
41703                             if (result) {
41704                                 result &= indexTypesRelatedTo(source, type, 0, false, false, 0);
41705                                 if (result) {
41706                                     result &= indexTypesRelatedTo(source, type, 1, false, false, 0);
41707                                 }
41708                             }
41709                         }
41710                     }
41711                     if (!result) {
41712                         return result;
41713                     }
41714                 }
41715                 return result;
41716             }
41717             function excludeProperties(properties, excludedProperties) {
41718                 if (!excludedProperties || properties.length === 0)
41719                     return properties;
41720                 var result;
41721                 for (var i = 0; i < properties.length; i++) {
41722                     if (!excludedProperties.has(properties[i].escapedName)) {
41723                         if (result) {
41724                             result.push(properties[i]);
41725                         }
41726                     }
41727                     else if (!result) {
41728                         result = properties.slice(0, i);
41729                     }
41730                 }
41731                 return result || properties;
41732             }
41733             function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) {
41734                 var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48);
41735                 var source = getTypeOfSourceProperty(sourceProp);
41736                 if (ts.getCheckFlags(targetProp) & 65536 && !getSymbolLinks(targetProp).type) {
41737                     var links = getSymbolLinks(targetProp);
41738                     ts.Debug.assertIsDefined(links.deferralParent);
41739                     ts.Debug.assertIsDefined(links.deferralConstituents);
41740                     var unionParent = !!(links.deferralParent.flags & 1048576);
41741                     var result_9 = unionParent ? 0 : -1;
41742                     var targetTypes = links.deferralConstituents;
41743                     for (var _i = 0, targetTypes_3 = targetTypes; _i < targetTypes_3.length; _i++) {
41744                         var targetType = targetTypes_3[_i];
41745                         var related = isRelatedTo(source, targetType, false, undefined, unionParent ? 0 : 2);
41746                         if (!unionParent) {
41747                             if (!related) {
41748                                 return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors);
41749                             }
41750                             result_9 &= related;
41751                         }
41752                         else {
41753                             if (related) {
41754                                 return related;
41755                             }
41756                         }
41757                     }
41758                     if (unionParent && !result_9 && targetIsOptional) {
41759                         result_9 = isRelatedTo(source, undefinedType);
41760                     }
41761                     if (unionParent && !result_9 && reportErrors) {
41762                         return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors);
41763                     }
41764                     return result_9;
41765                 }
41766                 else {
41767                     return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, undefined, intersectionState);
41768                 }
41769             }
41770             function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) {
41771                 var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp);
41772                 var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp);
41773                 if (sourcePropFlags & 8 || targetPropFlags & 8) {
41774                     if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) {
41775                         if (reportErrors) {
41776                             if (sourcePropFlags & 8 && targetPropFlags & 8) {
41777                                 reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp));
41778                             }
41779                             else {
41780                                 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));
41781                             }
41782                         }
41783                         return 0;
41784                     }
41785                 }
41786                 else if (targetPropFlags & 16) {
41787                     if (!isValidOverrideOf(sourceProp, targetProp)) {
41788                         if (reportErrors) {
41789                             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));
41790                         }
41791                         return 0;
41792                     }
41793                 }
41794                 else if (sourcePropFlags & 16) {
41795                     if (reportErrors) {
41796                         reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target));
41797                     }
41798                     return 0;
41799                 }
41800                 var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState);
41801                 if (!related) {
41802                     if (reportErrors) {
41803                         reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp));
41804                     }
41805                     return 0;
41806                 }
41807                 if (!skipOptional && sourceProp.flags & 16777216 && !(targetProp.flags & 16777216)) {
41808                     if (reportErrors) {
41809                         reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target));
41810                     }
41811                     return 0;
41812                 }
41813                 return related;
41814             }
41815             function reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties) {
41816                 var shouldSkipElaboration = false;
41817                 if (unmatchedProperty.valueDeclaration
41818                     && ts.isNamedDeclaration(unmatchedProperty.valueDeclaration)
41819                     && ts.isPrivateIdentifier(unmatchedProperty.valueDeclaration.name)
41820                     && source.symbol
41821                     && source.symbol.flags & 32) {
41822                     var privateIdentifierDescription = unmatchedProperty.valueDeclaration.name.escapedText;
41823                     var symbolTableKey = ts.getSymbolNameForPrivateIdentifier(source.symbol, privateIdentifierDescription);
41824                     if (symbolTableKey && getPropertyOfType(source, symbolTableKey)) {
41825                         var sourceName = ts.getDeclarationName(source.symbol.valueDeclaration);
41826                         var targetName = ts.getDeclarationName(target.symbol.valueDeclaration);
41827                         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));
41828                         return;
41829                     }
41830                 }
41831                 var props = ts.arrayFrom(getUnmatchedProperties(source, target, requireOptionalProperties, false));
41832                 if (!headMessage || (headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code &&
41833                     headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code)) {
41834                     shouldSkipElaboration = true;
41835                 }
41836                 if (props.length === 1) {
41837                     var propName = symbolToString(unmatchedProperty);
41838                     reportError.apply(void 0, __spreadArrays([ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName], getTypeNamesForErrorDisplay(source, target)));
41839                     if (ts.length(unmatchedProperty.declarations)) {
41840                         associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName));
41841                     }
41842                     if (shouldSkipElaboration && errorInfo) {
41843                         overrideNextErrorInfo++;
41844                     }
41845                 }
41846                 else if (tryElaborateArrayLikeErrors(source, target, false)) {
41847                     if (props.length > 5) {
41848                         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);
41849                     }
41850                     else {
41851                         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(", "));
41852                     }
41853                     if (shouldSkipElaboration && errorInfo) {
41854                         overrideNextErrorInfo++;
41855                     }
41856                 }
41857             }
41858             function propertiesRelatedTo(source, target, reportErrors, excludedProperties, intersectionState) {
41859                 if (relation === identityRelation) {
41860                     return propertiesIdenticalTo(source, target, excludedProperties);
41861                 }
41862                 var requireOptionalProperties = (relation === subtypeRelation || relation === strictSubtypeRelation) && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source);
41863                 var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties, false);
41864                 if (unmatchedProperty) {
41865                     if (reportErrors) {
41866                         reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties);
41867                     }
41868                     return 0;
41869                 }
41870                 if (isObjectLiteralType(target)) {
41871                     for (var _i = 0, _a = excludeProperties(getPropertiesOfType(source), excludedProperties); _i < _a.length; _i++) {
41872                         var sourceProp = _a[_i];
41873                         if (!getPropertyOfObjectType(target, sourceProp.escapedName)) {
41874                             var sourceType = getTypeOfSymbol(sourceProp);
41875                             if (!(sourceType === undefinedType || sourceType === undefinedWideningType || sourceType === optionalType)) {
41876                                 if (reportErrors) {
41877                                     reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target));
41878                                 }
41879                                 return 0;
41880                             }
41881                         }
41882                     }
41883                 }
41884                 var result = -1;
41885                 if (isTupleType(target)) {
41886                     var targetRestType = getRestTypeOfTupleType(target);
41887                     if (targetRestType) {
41888                         if (!isTupleType(source)) {
41889                             return 0;
41890                         }
41891                         var sourceRestType = getRestTypeOfTupleType(source);
41892                         if (sourceRestType && !isRelatedTo(sourceRestType, targetRestType, reportErrors)) {
41893                             if (reportErrors) {
41894                                 reportError(ts.Diagnostics.Rest_signatures_are_incompatible);
41895                             }
41896                             return 0;
41897                         }
41898                         var targetCount = getTypeReferenceArity(target) - 1;
41899                         var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0);
41900                         var sourceTypeArguments = getTypeArguments(source);
41901                         for (var i = targetCount; i < sourceCount; i++) {
41902                             var related = isRelatedTo(sourceTypeArguments[i], targetRestType, reportErrors);
41903                             if (!related) {
41904                                 if (reportErrors) {
41905                                     reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i);
41906                                 }
41907                                 return 0;
41908                             }
41909                             result &= related;
41910                         }
41911                     }
41912                 }
41913                 var properties = getPropertiesOfType(target);
41914                 var numericNamesOnly = isTupleType(source) && isTupleType(target);
41915                 for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) {
41916                     var targetProp = _c[_b];
41917                     var name = targetProp.escapedName;
41918                     if (!(targetProp.flags & 4194304) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) {
41919                         var sourceProp = getPropertyOfType(source, name);
41920                         if (sourceProp && sourceProp !== targetProp) {
41921                             var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation);
41922                             if (!related) {
41923                                 return 0;
41924                             }
41925                             result &= related;
41926                         }
41927                     }
41928                 }
41929                 return result;
41930             }
41931             function propertiesIdenticalTo(source, target, excludedProperties) {
41932                 if (!(source.flags & 524288 && target.flags & 524288)) {
41933                     return 0;
41934                 }
41935                 var sourceProperties = excludeProperties(getPropertiesOfObjectType(source), excludedProperties);
41936                 var targetProperties = excludeProperties(getPropertiesOfObjectType(target), excludedProperties);
41937                 if (sourceProperties.length !== targetProperties.length) {
41938                     return 0;
41939                 }
41940                 var result = -1;
41941                 for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) {
41942                     var sourceProp = sourceProperties_1[_i];
41943                     var targetProp = getPropertyOfObjectType(target, sourceProp.escapedName);
41944                     if (!targetProp) {
41945                         return 0;
41946                     }
41947                     var related = compareProperties(sourceProp, targetProp, isRelatedTo);
41948                     if (!related) {
41949                         return 0;
41950                     }
41951                     result &= related;
41952                 }
41953                 return result;
41954             }
41955             function signaturesRelatedTo(source, target, kind, reportErrors) {
41956                 if (relation === identityRelation) {
41957                     return signaturesIdenticalTo(source, target, kind);
41958                 }
41959                 if (target === anyFunctionType || source === anyFunctionType) {
41960                     return -1;
41961                 }
41962                 var sourceIsJSConstructor = source.symbol && isJSConstructor(source.symbol.valueDeclaration);
41963                 var targetIsJSConstructor = target.symbol && isJSConstructor(target.symbol.valueDeclaration);
41964                 var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1) ?
41965                     0 : kind);
41966                 var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1) ?
41967                     0 : kind);
41968                 if (kind === 1 && sourceSignatures.length && targetSignatures.length) {
41969                     if (ts.isAbstractConstructorType(source) && !ts.isAbstractConstructorType(target)) {
41970                         if (reportErrors) {
41971                             reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type);
41972                         }
41973                         return 0;
41974                     }
41975                     if (!constructorVisibilitiesAreCompatible(sourceSignatures[0], targetSignatures[0], reportErrors)) {
41976                         return 0;
41977                     }
41978                 }
41979                 var result = -1;
41980                 var saveErrorInfo = captureErrorCalculationState();
41981                 var incompatibleReporter = kind === 1 ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
41982                 if (ts.getObjectFlags(source) & 64 && ts.getObjectFlags(target) & 64 && source.symbol === target.symbol) {
41983                     for (var i = 0; i < targetSignatures.length; i++) {
41984                         var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i]));
41985                         if (!related) {
41986                             return 0;
41987                         }
41988                         result &= related;
41989                     }
41990                 }
41991                 else if (sourceSignatures.length === 1 && targetSignatures.length === 1) {
41992                     var eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks;
41993                     result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors, incompatibleReporter(sourceSignatures[0], targetSignatures[0]));
41994                 }
41995                 else {
41996                     outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) {
41997                         var t = targetSignatures_1[_i];
41998                         var shouldElaborateErrors = reportErrors;
41999                         for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) {
42000                             var s = sourceSignatures_1[_a];
42001                             var related = signatureRelatedTo(s, t, true, shouldElaborateErrors, incompatibleReporter(s, t));
42002                             if (related) {
42003                                 result &= related;
42004                                 resetErrorInfo(saveErrorInfo);
42005                                 continue outer;
42006                             }
42007                             shouldElaborateErrors = false;
42008                         }
42009                         if (shouldElaborateErrors) {
42010                             reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, undefined, undefined, kind));
42011                         }
42012                         return 0;
42013                     }
42014                 }
42015                 return result;
42016             }
42017             function reportIncompatibleCallSignatureReturn(siga, sigb) {
42018                 if (siga.parameters.length === 0 && sigb.parameters.length === 0) {
42019                     return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); };
42020                 }
42021                 return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); };
42022             }
42023             function reportIncompatibleConstructSignatureReturn(siga, sigb) {
42024                 if (siga.parameters.length === 0 && sigb.parameters.length === 0) {
42025                     return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); };
42026                 }
42027                 return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); };
42028             }
42029             function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) {
42030                 return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 : 0, reportErrors, reportError, incompatibleReporter, isRelatedTo, makeFunctionTypeMapper(reportUnreliableMarkers));
42031             }
42032             function signaturesIdenticalTo(source, target, kind) {
42033                 var sourceSignatures = getSignaturesOfType(source, kind);
42034                 var targetSignatures = getSignaturesOfType(target, kind);
42035                 if (sourceSignatures.length !== targetSignatures.length) {
42036                     return 0;
42037                 }
42038                 var result = -1;
42039                 for (var i = 0; i < sourceSignatures.length; i++) {
42040                     var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], false, false, false, isRelatedTo);
42041                     if (!related) {
42042                         return 0;
42043                     }
42044                     result &= related;
42045                 }
42046                 return result;
42047             }
42048             function eachPropertyRelatedTo(source, target, kind, reportErrors) {
42049                 var result = -1;
42050                 var props = source.flags & 2097152 ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source);
42051                 for (var _i = 0, props_2 = props; _i < props_2.length; _i++) {
42052                     var prop = props_2[_i];
42053                     if (isIgnoredJsxProperty(source, prop)) {
42054                         continue;
42055                     }
42056                     var nameType = getSymbolLinks(prop).nameType;
42057                     if (nameType && nameType.flags & 8192) {
42058                         continue;
42059                     }
42060                     if (kind === 0 || isNumericLiteralName(prop.escapedName)) {
42061                         var related = isRelatedTo(getTypeOfSymbol(prop), target, reportErrors);
42062                         if (!related) {
42063                             if (reportErrors) {
42064                                 reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop));
42065                             }
42066                             return 0;
42067                         }
42068                         result &= related;
42069                     }
42070                 }
42071                 return result;
42072             }
42073             function indexTypeRelatedTo(sourceType, targetType, reportErrors) {
42074                 var related = isRelatedTo(sourceType, targetType, reportErrors);
42075                 if (!related && reportErrors) {
42076                     reportError(ts.Diagnostics.Index_signatures_are_incompatible);
42077                 }
42078                 return related;
42079             }
42080             function indexTypesRelatedTo(source, target, kind, sourceIsPrimitive, reportErrors, intersectionState) {
42081                 if (relation === identityRelation) {
42082                     return indexTypesIdenticalTo(source, target, kind);
42083                 }
42084                 var targetType = getIndexTypeOfType(target, kind);
42085                 if (!targetType || targetType.flags & 1 && !sourceIsPrimitive) {
42086                     return -1;
42087                 }
42088                 if (isGenericMappedType(source)) {
42089                     return kind === 0 ? isRelatedTo(getTemplateTypeFromMappedType(source), targetType, reportErrors) : 0;
42090                 }
42091                 var indexType = getIndexTypeOfType(source, kind) || kind === 1 && getIndexTypeOfType(source, 0);
42092                 if (indexType) {
42093                     return indexTypeRelatedTo(indexType, targetType, reportErrors);
42094                 }
42095                 if (!(intersectionState & 1) && isObjectTypeWithInferableIndex(source)) {
42096                     var related = eachPropertyRelatedTo(source, targetType, kind, reportErrors);
42097                     if (related && kind === 0) {
42098                         var numberIndexType = getIndexTypeOfType(source, 1);
42099                         if (numberIndexType) {
42100                             related &= indexTypeRelatedTo(numberIndexType, targetType, reportErrors);
42101                         }
42102                     }
42103                     return related;
42104                 }
42105                 if (reportErrors) {
42106                     reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source));
42107                 }
42108                 return 0;
42109             }
42110             function indexTypesIdenticalTo(source, target, indexKind) {
42111                 var targetInfo = getIndexInfoOfType(target, indexKind);
42112                 var sourceInfo = getIndexInfoOfType(source, indexKind);
42113                 if (!sourceInfo && !targetInfo) {
42114                     return -1;
42115                 }
42116                 if (sourceInfo && targetInfo && sourceInfo.isReadonly === targetInfo.isReadonly) {
42117                     return isRelatedTo(sourceInfo.type, targetInfo.type);
42118                 }
42119                 return 0;
42120             }
42121             function constructorVisibilitiesAreCompatible(sourceSignature, targetSignature, reportErrors) {
42122                 if (!sourceSignature.declaration || !targetSignature.declaration) {
42123                     return true;
42124                 }
42125                 var sourceAccessibility = ts.getSelectedModifierFlags(sourceSignature.declaration, 24);
42126                 var targetAccessibility = ts.getSelectedModifierFlags(targetSignature.declaration, 24);
42127                 if (targetAccessibility === 8) {
42128                     return true;
42129                 }
42130                 if (targetAccessibility === 16 && sourceAccessibility !== 8) {
42131                     return true;
42132                 }
42133                 if (targetAccessibility !== 16 && !sourceAccessibility) {
42134                     return true;
42135                 }
42136                 if (reportErrors) {
42137                     reportError(ts.Diagnostics.Cannot_assign_a_0_constructor_type_to_a_1_constructor_type, visibilityToString(sourceAccessibility), visibilityToString(targetAccessibility));
42138                 }
42139                 return false;
42140             }
42141         }
42142         function getBestMatchingType(source, target, isRelatedTo) {
42143             if (isRelatedTo === void 0) { isRelatedTo = compareTypesAssignable; }
42144             return findMatchingDiscriminantType(source, target, isRelatedTo, true) ||
42145                 findMatchingTypeReferenceOrTypeAliasReference(source, target) ||
42146                 findBestTypeForObjectLiteral(source, target) ||
42147                 findBestTypeForInvokable(source, target) ||
42148                 findMostOverlappyType(source, target);
42149         }
42150         function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue, skipPartial) {
42151             var discriminable = target.types.map(function (_) { return undefined; });
42152             for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) {
42153                 var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1];
42154                 var targetProp = getUnionOrIntersectionProperty(target, propertyName);
42155                 if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16) {
42156                     continue;
42157                 }
42158                 var i = 0;
42159                 for (var _b = 0, _c = target.types; _b < _c.length; _b++) {
42160                     var type = _c[_b];
42161                     var targetType = getTypeOfPropertyOfType(type, propertyName);
42162                     if (targetType && related(getDiscriminatingType(), targetType)) {
42163                         discriminable[i] = discriminable[i] === undefined ? true : discriminable[i];
42164                     }
42165                     else {
42166                         discriminable[i] = false;
42167                     }
42168                     i++;
42169                 }
42170             }
42171             var match = discriminable.indexOf(true);
42172             return match === -1 || discriminable.indexOf(true, match + 1) !== -1 ? defaultValue : target.types[match];
42173         }
42174         function isWeakType(type) {
42175             if (type.flags & 524288) {
42176                 var resolved = resolveStructuredTypeMembers(type);
42177                 return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 &&
42178                     !resolved.stringIndexInfo && !resolved.numberIndexInfo &&
42179                     resolved.properties.length > 0 &&
42180                     ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216); });
42181             }
42182             if (type.flags & 2097152) {
42183                 return ts.every(type.types, isWeakType);
42184             }
42185             return false;
42186         }
42187         function hasCommonProperties(source, target, isComparingJsxAttributes) {
42188             for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) {
42189                 var prop = _a[_i];
42190                 if (isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) {
42191                     return true;
42192                 }
42193             }
42194             return false;
42195         }
42196         function getMarkerTypeReference(type, source, target) {
42197             var result = createTypeReference(type, ts.map(type.typeParameters, function (t) { return t === source ? target : t; }));
42198             result.objectFlags |= 8192;
42199             return result;
42200         }
42201         function getAliasVariances(symbol) {
42202             var links = getSymbolLinks(symbol);
42203             return getVariancesWorker(links.typeParameters, links, function (_links, param, marker) {
42204                 var type = getTypeAliasInstantiation(symbol, instantiateTypes(links.typeParameters, makeUnaryTypeMapper(param, marker)));
42205                 type.aliasTypeArgumentsContainsMarker = true;
42206                 return type;
42207             });
42208         }
42209         function getVariancesWorker(typeParameters, cache, createMarkerType) {
42210             if (typeParameters === void 0) { typeParameters = ts.emptyArray; }
42211             var variances = cache.variances;
42212             if (!variances) {
42213                 cache.variances = ts.emptyArray;
42214                 variances = [];
42215                 var _loop_16 = function (tp) {
42216                     var unmeasurable = false;
42217                     var unreliable = false;
42218                     var oldHandler = outofbandVarianceMarkerHandler;
42219                     outofbandVarianceMarkerHandler = function (onlyUnreliable) { return onlyUnreliable ? unreliable = true : unmeasurable = true; };
42220                     var typeWithSuper = createMarkerType(cache, tp, markerSuperType);
42221                     var typeWithSub = createMarkerType(cache, tp, markerSubType);
42222                     var variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 : 0) |
42223                         (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 : 0);
42224                     if (variance === 3 && isTypeAssignableTo(createMarkerType(cache, tp, markerOtherType), typeWithSuper)) {
42225                         variance = 4;
42226                     }
42227                     outofbandVarianceMarkerHandler = oldHandler;
42228                     if (unmeasurable || unreliable) {
42229                         if (unmeasurable) {
42230                             variance |= 8;
42231                         }
42232                         if (unreliable) {
42233                             variance |= 16;
42234                         }
42235                     }
42236                     variances.push(variance);
42237                 };
42238                 for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) {
42239                     var tp = typeParameters_1[_i];
42240                     _loop_16(tp);
42241                 }
42242                 cache.variances = variances;
42243             }
42244             return variances;
42245         }
42246         function getVariances(type) {
42247             if (type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8) {
42248                 return arrayVariances;
42249             }
42250             return getVariancesWorker(type.typeParameters, type, getMarkerTypeReference);
42251         }
42252         function hasCovariantVoidArgument(typeArguments, variances) {
42253             for (var i = 0; i < variances.length; i++) {
42254                 if ((variances[i] & 7) === 1 && typeArguments[i].flags & 16384) {
42255                     return true;
42256                 }
42257             }
42258             return false;
42259         }
42260         function isUnconstrainedTypeParameter(type) {
42261             return type.flags & 262144 && !getConstraintOfTypeParameter(type);
42262         }
42263         function isNonDeferredTypeReference(type) {
42264             return !!(ts.getObjectFlags(type) & 4) && !type.node;
42265         }
42266         function isTypeReferenceWithGenericArguments(type) {
42267             return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); });
42268         }
42269         function getTypeReferenceId(type, typeParameters, depth) {
42270             if (depth === void 0) { depth = 0; }
42271             var result = "" + type.target.id;
42272             for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) {
42273                 var t = _a[_i];
42274                 if (isUnconstrainedTypeParameter(t)) {
42275                     var index = typeParameters.indexOf(t);
42276                     if (index < 0) {
42277                         index = typeParameters.length;
42278                         typeParameters.push(t);
42279                     }
42280                     result += "=" + index;
42281                 }
42282                 else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) {
42283                     result += "<" + getTypeReferenceId(t, typeParameters, depth + 1) + ">";
42284                 }
42285                 else {
42286                     result += "-" + t.id;
42287                 }
42288             }
42289             return result;
42290         }
42291         function getRelationKey(source, target, intersectionState, relation) {
42292             if (relation === identityRelation && source.id > target.id) {
42293                 var temp = source;
42294                 source = target;
42295                 target = temp;
42296             }
42297             var postFix = intersectionState ? ":" + intersectionState : "";
42298             if (isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target)) {
42299                 var typeParameters = [];
42300                 return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters) + postFix;
42301             }
42302             return source.id + "," + target.id + postFix;
42303         }
42304         function forEachProperty(prop, callback) {
42305             if (ts.getCheckFlags(prop) & 6) {
42306                 for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) {
42307                     var t = _a[_i];
42308                     var p = getPropertyOfType(t, prop.escapedName);
42309                     var result = p && forEachProperty(p, callback);
42310                     if (result) {
42311                         return result;
42312                     }
42313                 }
42314                 return undefined;
42315             }
42316             return callback(prop);
42317         }
42318         function getDeclaringClass(prop) {
42319             return prop.parent && prop.parent.flags & 32 ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined;
42320         }
42321         function isPropertyInClassDerivedFrom(prop, baseClass) {
42322             return forEachProperty(prop, function (sp) {
42323                 var sourceClass = getDeclaringClass(sp);
42324                 return sourceClass ? hasBaseType(sourceClass, baseClass) : false;
42325             });
42326         }
42327         function isValidOverrideOf(sourceProp, targetProp) {
42328             return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 ?
42329                 !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; });
42330         }
42331         function isClassDerivedFromDeclaringClasses(checkClass, prop) {
42332             return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p) & 16 ?
42333                 !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass;
42334         }
42335         function isDeeplyNestedType(type, stack, depth) {
42336             if (depth >= 5 && type.flags & 524288 && !isObjectOrArrayLiteralType(type)) {
42337                 var symbol = type.symbol;
42338                 if (symbol) {
42339                     var count = 0;
42340                     for (var i = 0; i < depth; i++) {
42341                         var t = stack[i];
42342                         if (t.flags & 524288 && t.symbol === symbol) {
42343                             count++;
42344                             if (count >= 5)
42345                                 return true;
42346                         }
42347                     }
42348                 }
42349             }
42350             if (depth >= 5 && type.flags & 8388608) {
42351                 var root = getRootObjectTypeFromIndexedAccessChain(type);
42352                 var count = 0;
42353                 for (var i = 0; i < depth; i++) {
42354                     var t = stack[i];
42355                     if (getRootObjectTypeFromIndexedAccessChain(t) === root) {
42356                         count++;
42357                         if (count >= 5)
42358                             return true;
42359                     }
42360                 }
42361             }
42362             return false;
42363         }
42364         function getRootObjectTypeFromIndexedAccessChain(type) {
42365             var t = type;
42366             while (t.flags & 8388608) {
42367                 t = t.objectType;
42368             }
42369             return t;
42370         }
42371         function isPropertyIdenticalTo(sourceProp, targetProp) {
42372             return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0;
42373         }
42374         function compareProperties(sourceProp, targetProp, compareTypes) {
42375             if (sourceProp === targetProp) {
42376                 return -1;
42377             }
42378             var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24;
42379             var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24;
42380             if (sourcePropAccessibility !== targetPropAccessibility) {
42381                 return 0;
42382             }
42383             if (sourcePropAccessibility) {
42384                 if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) {
42385                     return 0;
42386                 }
42387             }
42388             else {
42389                 if ((sourceProp.flags & 16777216) !== (targetProp.flags & 16777216)) {
42390                     return 0;
42391                 }
42392             }
42393             if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) {
42394                 return 0;
42395             }
42396             return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
42397         }
42398         function isMatchingSignature(source, target, partialMatch) {
42399             var sourceParameterCount = getParameterCount(source);
42400             var targetParameterCount = getParameterCount(target);
42401             var sourceMinArgumentCount = getMinArgumentCount(source);
42402             var targetMinArgumentCount = getMinArgumentCount(target);
42403             var sourceHasRestParameter = hasEffectiveRestParameter(source);
42404             var targetHasRestParameter = hasEffectiveRestParameter(target);
42405             if (sourceParameterCount === targetParameterCount &&
42406                 sourceMinArgumentCount === targetMinArgumentCount &&
42407                 sourceHasRestParameter === targetHasRestParameter) {
42408                 return true;
42409             }
42410             if (partialMatch && sourceMinArgumentCount <= targetMinArgumentCount) {
42411                 return true;
42412             }
42413             return false;
42414         }
42415         function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypes) {
42416             if (source === target) {
42417                 return -1;
42418             }
42419             if (!(isMatchingSignature(source, target, partialMatch))) {
42420                 return 0;
42421             }
42422             if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) {
42423                 return 0;
42424             }
42425             if (target.typeParameters) {
42426                 var mapper = createTypeMapper(source.typeParameters, target.typeParameters);
42427                 for (var i = 0; i < target.typeParameters.length; i++) {
42428                     var s = source.typeParameters[i];
42429                     var t = target.typeParameters[i];
42430                     if (!(s === t || compareTypes(instantiateType(getConstraintFromTypeParameter(s), mapper) || unknownType, getConstraintFromTypeParameter(t) || unknownType) &&
42431                         compareTypes(instantiateType(getDefaultFromTypeParameter(s), mapper) || unknownType, getDefaultFromTypeParameter(t) || unknownType))) {
42432                         return 0;
42433                     }
42434                 }
42435                 source = instantiateSignature(source, mapper, true);
42436             }
42437             var result = -1;
42438             if (!ignoreThisTypes) {
42439                 var sourceThisType = getThisTypeOfSignature(source);
42440                 if (sourceThisType) {
42441                     var targetThisType = getThisTypeOfSignature(target);
42442                     if (targetThisType) {
42443                         var related = compareTypes(sourceThisType, targetThisType);
42444                         if (!related) {
42445                             return 0;
42446                         }
42447                         result &= related;
42448                     }
42449                 }
42450             }
42451             var targetLen = getParameterCount(target);
42452             for (var i = 0; i < targetLen; i++) {
42453                 var s = getTypeAtPosition(source, i);
42454                 var t = getTypeAtPosition(target, i);
42455                 var related = compareTypes(t, s);
42456                 if (!related) {
42457                     return 0;
42458                 }
42459                 result &= related;
42460             }
42461             if (!ignoreReturnTypes) {
42462                 var sourceTypePredicate = getTypePredicateOfSignature(source);
42463                 var targetTypePredicate = getTypePredicateOfSignature(target);
42464                 result &= sourceTypePredicate || targetTypePredicate ?
42465                     compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) :
42466                     compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target));
42467             }
42468             return result;
42469         }
42470         function compareTypePredicatesIdentical(source, target, compareTypes) {
42471             return !(source && target && typePredicateKindsMatch(source, target)) ? 0 :
42472                 source.type === target.type ? -1 :
42473                     source.type && target.type ? compareTypes(source.type, target.type) :
42474                         0;
42475         }
42476         function literalTypesWithSameBaseType(types) {
42477             var commonBaseType;
42478             for (var _i = 0, types_12 = types; _i < types_12.length; _i++) {
42479                 var t = types_12[_i];
42480                 var baseType = getBaseTypeOfLiteralType(t);
42481                 if (!commonBaseType) {
42482                     commonBaseType = baseType;
42483                 }
42484                 if (baseType === t || baseType !== commonBaseType) {
42485                     return false;
42486                 }
42487             }
42488             return true;
42489         }
42490         function getSupertypeOrUnion(types) {
42491             return literalTypesWithSameBaseType(types) ?
42492                 getUnionType(types) :
42493                 ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; });
42494         }
42495         function getCommonSupertype(types) {
42496             if (!strictNullChecks) {
42497                 return getSupertypeOrUnion(types);
42498             }
42499             var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304); });
42500             return primaryTypes.length ?
42501                 getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304) :
42502                 getUnionType(types, 2);
42503         }
42504         function getCommonSubtype(types) {
42505             return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; });
42506         }
42507         function isArrayType(type) {
42508             return !!(ts.getObjectFlags(type) & 4) && (type.target === globalArrayType || type.target === globalReadonlyArrayType);
42509         }
42510         function isReadonlyArrayType(type) {
42511             return !!(ts.getObjectFlags(type) & 4) && type.target === globalReadonlyArrayType;
42512         }
42513         function isMutableArrayOrTuple(type) {
42514             return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly;
42515         }
42516         function getElementTypeOfArrayType(type) {
42517             return isArrayType(type) ? getTypeArguments(type)[0] : undefined;
42518         }
42519         function isArrayLikeType(type) {
42520             return isArrayType(type) || !(type.flags & 98304) && isTypeAssignableTo(type, anyReadonlyArrayType);
42521         }
42522         function isEmptyArrayLiteralType(type) {
42523             var elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined;
42524             return elementType === undefinedWideningType || elementType === implicitNeverType;
42525         }
42526         function isTupleLikeType(type) {
42527             return isTupleType(type) || !!getPropertyOfType(type, "0");
42528         }
42529         function isArrayOrTupleLikeType(type) {
42530             return isArrayLikeType(type) || isTupleLikeType(type);
42531         }
42532         function getTupleElementType(type, index) {
42533             var propType = getTypeOfPropertyOfType(type, "" + index);
42534             if (propType) {
42535                 return propType;
42536             }
42537             if (everyType(type, isTupleType)) {
42538                 return mapType(type, function (t) { return getRestTypeOfTupleType(t) || undefinedType; });
42539             }
42540             return undefined;
42541         }
42542         function isNeitherUnitTypeNorNever(type) {
42543             return !(type.flags & (109440 | 131072));
42544         }
42545         function isUnitType(type) {
42546             return !!(type.flags & 109440);
42547         }
42548         function isLiteralType(type) {
42549             return type.flags & 16 ? true :
42550                 type.flags & 1048576 ? type.flags & 1024 ? true : ts.every(type.types, isUnitType) :
42551                     isUnitType(type);
42552         }
42553         function getBaseTypeOfLiteralType(type) {
42554             return type.flags & 1024 ? getBaseTypeOfEnumLiteralType(type) :
42555                 type.flags & 128 ? stringType :
42556                     type.flags & 256 ? numberType :
42557                         type.flags & 2048 ? bigintType :
42558                             type.flags & 512 ? booleanType :
42559                                 type.flags & 1048576 ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) :
42560                                     type;
42561         }
42562         function getWidenedLiteralType(type) {
42563             return type.flags & 1024 && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) :
42564                 type.flags & 128 && isFreshLiteralType(type) ? stringType :
42565                     type.flags & 256 && isFreshLiteralType(type) ? numberType :
42566                         type.flags & 2048 && isFreshLiteralType(type) ? bigintType :
42567                             type.flags & 512 && isFreshLiteralType(type) ? booleanType :
42568                                 type.flags & 1048576 ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) :
42569                                     type;
42570         }
42571         function getWidenedUniqueESSymbolType(type) {
42572             return type.flags & 8192 ? esSymbolType :
42573                 type.flags & 1048576 ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) :
42574                     type;
42575         }
42576         function getWidenedLiteralLikeTypeForContextualType(type, contextualType) {
42577             if (!isLiteralOfContextualType(type, contextualType)) {
42578                 type = getWidenedUniqueESSymbolType(getWidenedLiteralType(type));
42579             }
42580             return type;
42581         }
42582         function getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(type, contextualSignatureReturnType, isAsync) {
42583             if (type && isUnitType(type)) {
42584                 var contextualType = !contextualSignatureReturnType ? undefined :
42585                     isAsync ? getPromisedTypeOfPromise(contextualSignatureReturnType) :
42586                         contextualSignatureReturnType;
42587                 type = getWidenedLiteralLikeTypeForContextualType(type, contextualType);
42588             }
42589             return type;
42590         }
42591         function getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(type, contextualSignatureReturnType, kind, isAsyncGenerator) {
42592             if (type && isUnitType(type)) {
42593                 var contextualType = !contextualSignatureReturnType ? undefined :
42594                     getIterationTypeOfGeneratorFunctionReturnType(kind, contextualSignatureReturnType, isAsyncGenerator);
42595                 type = getWidenedLiteralLikeTypeForContextualType(type, contextualType);
42596             }
42597             return type;
42598         }
42599         function isTupleType(type) {
42600             return !!(ts.getObjectFlags(type) & 4 && type.target.objectFlags & 8);
42601         }
42602         function getRestTypeOfTupleType(type) {
42603             return type.target.hasRestElement ? getTypeArguments(type)[type.target.typeParameters.length - 1] : undefined;
42604         }
42605         function getRestArrayTypeOfTupleType(type) {
42606             var restType = getRestTypeOfTupleType(type);
42607             return restType && createArrayType(restType);
42608         }
42609         function getLengthOfTupleType(type) {
42610             return getTypeReferenceArity(type) - (type.target.hasRestElement ? 1 : 0);
42611         }
42612         function isZeroBigInt(_a) {
42613             var value = _a.value;
42614             return value.base10Value === "0";
42615         }
42616         function getFalsyFlagsOfTypes(types) {
42617             var result = 0;
42618             for (var _i = 0, types_13 = types; _i < types_13.length; _i++) {
42619                 var t = types_13[_i];
42620                 result |= getFalsyFlags(t);
42621             }
42622             return result;
42623         }
42624         function getFalsyFlags(type) {
42625             return type.flags & 1048576 ? getFalsyFlagsOfTypes(type.types) :
42626                 type.flags & 128 ? type.value === "" ? 128 : 0 :
42627                     type.flags & 256 ? type.value === 0 ? 256 : 0 :
42628                         type.flags & 2048 ? isZeroBigInt(type) ? 2048 : 0 :
42629                             type.flags & 512 ? (type === falseType || type === regularFalseType) ? 512 : 0 :
42630                                 type.flags & 117724;
42631         }
42632         function removeDefinitelyFalsyTypes(type) {
42633             return getFalsyFlags(type) & 117632 ?
42634                 filterType(type, function (t) { return !(getFalsyFlags(t) & 117632); }) :
42635                 type;
42636         }
42637         function extractDefinitelyFalsyTypes(type) {
42638             return mapType(type, getDefinitelyFalsyPartOfType);
42639         }
42640         function getDefinitelyFalsyPartOfType(type) {
42641             return type.flags & 4 ? emptyStringType :
42642                 type.flags & 8 ? zeroType :
42643                     type.flags & 64 ? zeroBigIntType :
42644                         type === regularFalseType ||
42645                             type === falseType ||
42646                             type.flags & (16384 | 32768 | 65536) ||
42647                             type.flags & 128 && type.value === "" ||
42648                             type.flags & 256 && type.value === 0 ||
42649                             type.flags & 2048 && isZeroBigInt(type) ? type :
42650                             neverType;
42651         }
42652         function getNullableType(type, flags) {
42653             var missing = (flags & ~type.flags) & (32768 | 65536);
42654             return missing === 0 ? type :
42655                 missing === 32768 ? getUnionType([type, undefinedType]) :
42656                     missing === 65536 ? getUnionType([type, nullType]) :
42657                         getUnionType([type, undefinedType, nullType]);
42658         }
42659         function getOptionalType(type) {
42660             ts.Debug.assert(strictNullChecks);
42661             return type.flags & 32768 ? type : getUnionType([type, undefinedType]);
42662         }
42663         function getGlobalNonNullableTypeInstantiation(type) {
42664             if (!deferredGlobalNonNullableTypeAlias) {
42665                 deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288, undefined) || unknownSymbol;
42666             }
42667             if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) {
42668                 return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]);
42669             }
42670             return getTypeWithFacts(type, 2097152);
42671         }
42672         function getNonNullableType(type) {
42673             return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type;
42674         }
42675         function addOptionalTypeMarker(type) {
42676             return strictNullChecks ? getUnionType([type, optionalType]) : type;
42677         }
42678         function isNotOptionalTypeMarker(type) {
42679             return type !== optionalType;
42680         }
42681         function removeOptionalTypeMarker(type) {
42682             return strictNullChecks ? filterType(type, isNotOptionalTypeMarker) : type;
42683         }
42684         function propagateOptionalTypeMarker(type, node, wasOptional) {
42685             return wasOptional ? ts.isOutermostOptionalChain(node) ? getOptionalType(type) : addOptionalTypeMarker(type) : type;
42686         }
42687         function getOptionalExpressionType(exprType, expression) {
42688             return ts.isExpressionOfOptionalChainRoot(expression) ? getNonNullableType(exprType) :
42689                 ts.isOptionalChain(expression) ? removeOptionalTypeMarker(exprType) :
42690                     exprType;
42691         }
42692         function isCoercibleUnderDoubleEquals(source, target) {
42693             return ((source.flags & (8 | 4 | 512)) !== 0)
42694                 && ((target.flags & (8 | 4 | 16)) !== 0);
42695         }
42696         function isObjectTypeWithInferableIndex(type) {
42697             return type.flags & 2097152 ? ts.every(type.types, isObjectTypeWithInferableIndex) :
42698                 !!(type.symbol && (type.symbol.flags & (4096 | 2048 | 384 | 512)) !== 0 &&
42699                     !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 && isObjectTypeWithInferableIndex(type.source));
42700         }
42701         function createSymbolWithType(source, type) {
42702             var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8);
42703             symbol.declarations = source.declarations;
42704             symbol.parent = source.parent;
42705             symbol.type = type;
42706             symbol.target = source;
42707             if (source.valueDeclaration) {
42708                 symbol.valueDeclaration = source.valueDeclaration;
42709             }
42710             var nameType = getSymbolLinks(source).nameType;
42711             if (nameType) {
42712                 symbol.nameType = nameType;
42713             }
42714             return symbol;
42715         }
42716         function transformTypeOfMembers(type, f) {
42717             var members = ts.createSymbolTable();
42718             for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) {
42719                 var property = _a[_i];
42720                 var original = getTypeOfSymbol(property);
42721                 var updated = f(original);
42722                 members.set(property.escapedName, updated === original ? property : createSymbolWithType(property, updated));
42723             }
42724             return members;
42725         }
42726         function getRegularTypeOfObjectLiteral(type) {
42727             if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 32768)) {
42728                 return type;
42729             }
42730             var regularType = type.regularType;
42731             if (regularType) {
42732                 return regularType;
42733             }
42734             var resolved = type;
42735             var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral);
42736             var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo);
42737             regularNew.flags = resolved.flags;
42738             regularNew.objectFlags |= resolved.objectFlags & ~32768;
42739             type.regularType = regularNew;
42740             return regularNew;
42741         }
42742         function createWideningContext(parent, propertyName, siblings) {
42743             return { parent: parent, propertyName: propertyName, siblings: siblings, resolvedProperties: undefined };
42744         }
42745         function getSiblingsOfContext(context) {
42746             if (!context.siblings) {
42747                 var siblings_1 = [];
42748                 for (var _i = 0, _a = getSiblingsOfContext(context.parent); _i < _a.length; _i++) {
42749                     var type = _a[_i];
42750                     if (isObjectLiteralType(type)) {
42751                         var prop = getPropertyOfObjectType(type, context.propertyName);
42752                         if (prop) {
42753                             forEachType(getTypeOfSymbol(prop), function (t) {
42754                                 siblings_1.push(t);
42755                             });
42756                         }
42757                     }
42758                 }
42759                 context.siblings = siblings_1;
42760             }
42761             return context.siblings;
42762         }
42763         function getPropertiesOfContext(context) {
42764             if (!context.resolvedProperties) {
42765                 var names = ts.createMap();
42766                 for (var _i = 0, _a = getSiblingsOfContext(context); _i < _a.length; _i++) {
42767                     var t = _a[_i];
42768                     if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 1024)) {
42769                         for (var _b = 0, _c = getPropertiesOfType(t); _b < _c.length; _b++) {
42770                             var prop = _c[_b];
42771                             names.set(prop.escapedName, prop);
42772                         }
42773                     }
42774                 }
42775                 context.resolvedProperties = ts.arrayFrom(names.values());
42776             }
42777             return context.resolvedProperties;
42778         }
42779         function getWidenedProperty(prop, context) {
42780             if (!(prop.flags & 4)) {
42781                 return prop;
42782             }
42783             var original = getTypeOfSymbol(prop);
42784             var propContext = context && createWideningContext(context, prop.escapedName, undefined);
42785             var widened = getWidenedTypeWithContext(original, propContext);
42786             return widened === original ? prop : createSymbolWithType(prop, widened);
42787         }
42788         function getUndefinedProperty(prop) {
42789             var cached = undefinedProperties.get(prop.escapedName);
42790             if (cached) {
42791                 return cached;
42792             }
42793             var result = createSymbolWithType(prop, undefinedType);
42794             result.flags |= 16777216;
42795             undefinedProperties.set(prop.escapedName, result);
42796             return result;
42797         }
42798         function getWidenedTypeOfObjectLiteral(type, context) {
42799             var members = ts.createSymbolTable();
42800             for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) {
42801                 var prop = _a[_i];
42802                 members.set(prop.escapedName, getWidenedProperty(prop, context));
42803             }
42804             if (context) {
42805                 for (var _b = 0, _c = getPropertiesOfContext(context); _b < _c.length; _b++) {
42806                     var prop = _c[_b];
42807                     if (!members.has(prop.escapedName)) {
42808                         members.set(prop.escapedName, getUndefinedProperty(prop));
42809                     }
42810                 }
42811             }
42812             var stringIndexInfo = getIndexInfoOfType(type, 0);
42813             var numberIndexInfo = getIndexInfoOfType(type, 1);
42814             var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo && createIndexInfo(getWidenedType(stringIndexInfo.type), stringIndexInfo.isReadonly), numberIndexInfo && createIndexInfo(getWidenedType(numberIndexInfo.type), numberIndexInfo.isReadonly));
42815             result.objectFlags |= (ts.getObjectFlags(type) & (16384 | 2097152));
42816             return result;
42817         }
42818         function getWidenedType(type) {
42819             return getWidenedTypeWithContext(type, undefined);
42820         }
42821         function getWidenedTypeWithContext(type, context) {
42822             if (ts.getObjectFlags(type) & 1572864) {
42823                 if (context === undefined && type.widened) {
42824                     return type.widened;
42825                 }
42826                 var result = void 0;
42827                 if (type.flags & (1 | 98304)) {
42828                     result = anyType;
42829                 }
42830                 else if (isObjectLiteralType(type)) {
42831                     result = getWidenedTypeOfObjectLiteral(type, context);
42832                 }
42833                 else if (type.flags & 1048576) {
42834                     var unionContext_1 = context || createWideningContext(undefined, undefined, type.types);
42835                     var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 ? t : getWidenedTypeWithContext(t, unionContext_1); });
42836                     result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 : 1);
42837                 }
42838                 else if (type.flags & 2097152) {
42839                     result = getIntersectionType(ts.sameMap(type.types, getWidenedType));
42840                 }
42841                 else if (isArrayType(type) || isTupleType(type)) {
42842                     result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType));
42843                 }
42844                 if (result && context === undefined) {
42845                     type.widened = result;
42846                 }
42847                 return result || type;
42848             }
42849             return type;
42850         }
42851         function reportWideningErrorsInType(type) {
42852             var errorReported = false;
42853             if (ts.getObjectFlags(type) & 524288) {
42854                 if (type.flags & 1048576) {
42855                     if (ts.some(type.types, isEmptyObjectType)) {
42856                         errorReported = true;
42857                     }
42858                     else {
42859                         for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
42860                             var t = _a[_i];
42861                             if (reportWideningErrorsInType(t)) {
42862                                 errorReported = true;
42863                             }
42864                         }
42865                     }
42866                 }
42867                 if (isArrayType(type) || isTupleType(type)) {
42868                     for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) {
42869                         var t = _c[_b];
42870                         if (reportWideningErrorsInType(t)) {
42871                             errorReported = true;
42872                         }
42873                     }
42874                 }
42875                 if (isObjectLiteralType(type)) {
42876                     for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) {
42877                         var p = _e[_d];
42878                         var t = getTypeOfSymbol(p);
42879                         if (ts.getObjectFlags(t) & 524288) {
42880                             if (!reportWideningErrorsInType(t)) {
42881                                 error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t)));
42882                             }
42883                             errorReported = true;
42884                         }
42885                     }
42886                 }
42887             }
42888             return errorReported;
42889         }
42890         function reportImplicitAny(declaration, type, wideningKind) {
42891             var typeAsString = typeToString(getWidenedType(type));
42892             if (ts.isInJSFile(declaration) && !ts.isCheckJsEnabledForFile(ts.getSourceFileOfNode(declaration), compilerOptions)) {
42893                 return;
42894             }
42895             var diagnostic;
42896             switch (declaration.kind) {
42897                 case 209:
42898                 case 159:
42899                 case 158:
42900                     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;
42901                     break;
42902                 case 156:
42903                     var param = declaration;
42904                     if (ts.isIdentifier(param.name) &&
42905                         (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) &&
42906                         param.parent.parameters.indexOf(param) > -1 &&
42907                         (resolveName(param, param.name.escapedText, 788968, undefined, param.name.escapedText, true) ||
42908                             param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) {
42909                         var newName = "arg" + param.parent.parameters.indexOf(param);
42910                         errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, ts.declarationNameToString(param.name));
42911                         return;
42912                     }
42913                     diagnostic = declaration.dotDotDotToken ?
42914                         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 :
42915                         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;
42916                     break;
42917                 case 191:
42918                     diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type;
42919                     if (!noImplicitAny) {
42920                         return;
42921                     }
42922                     break;
42923                 case 300:
42924                     error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString);
42925                     return;
42926                 case 244:
42927                 case 161:
42928                 case 160:
42929                 case 163:
42930                 case 164:
42931                 case 201:
42932                 case 202:
42933                     if (noImplicitAny && !declaration.name) {
42934                         if (wideningKind === 3) {
42935                             error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString);
42936                         }
42937                         else {
42938                             error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString);
42939                         }
42940                         return;
42941                     }
42942                     diagnostic = !noImplicitAny ? ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage :
42943                         wideningKind === 3 ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type :
42944                             ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type;
42945                     break;
42946                 case 186:
42947                     if (noImplicitAny) {
42948                         error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type);
42949                     }
42950                     return;
42951                 default:
42952                     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;
42953             }
42954             errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString);
42955         }
42956         function reportErrorsFromWidening(declaration, type, wideningKind) {
42957             if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 524288 && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) {
42958                 if (!reportWideningErrorsInType(type)) {
42959                     reportImplicitAny(declaration, type, wideningKind);
42960                 }
42961             }
42962         }
42963         function applyToParameterTypes(source, target, callback) {
42964             var sourceCount = getParameterCount(source);
42965             var targetCount = getParameterCount(target);
42966             var sourceRestType = getEffectiveRestType(source);
42967             var targetRestType = getEffectiveRestType(target);
42968             var targetNonRestCount = targetRestType ? targetCount - 1 : targetCount;
42969             var paramCount = sourceRestType ? targetNonRestCount : Math.min(sourceCount, targetNonRestCount);
42970             var sourceThisType = getThisTypeOfSignature(source);
42971             if (sourceThisType) {
42972                 var targetThisType = getThisTypeOfSignature(target);
42973                 if (targetThisType) {
42974                     callback(sourceThisType, targetThisType);
42975                 }
42976             }
42977             for (var i = 0; i < paramCount; i++) {
42978                 callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i));
42979             }
42980             if (targetRestType) {
42981                 callback(getRestTypeAtPosition(source, paramCount), targetRestType);
42982             }
42983         }
42984         function applyToReturnTypes(source, target, callback) {
42985             var sourceTypePredicate = getTypePredicateOfSignature(source);
42986             var targetTypePredicate = getTypePredicateOfSignature(target);
42987             if (sourceTypePredicate && targetTypePredicate && typePredicateKindsMatch(sourceTypePredicate, targetTypePredicate) && sourceTypePredicate.type && targetTypePredicate.type) {
42988                 callback(sourceTypePredicate.type, targetTypePredicate.type);
42989             }
42990             else {
42991                 callback(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target));
42992             }
42993         }
42994         function createInferenceContext(typeParameters, signature, flags, compareTypes) {
42995             return createInferenceContextWorker(typeParameters.map(createInferenceInfo), signature, flags, compareTypes || compareTypesAssignable);
42996         }
42997         function cloneInferenceContext(context, extraFlags) {
42998             if (extraFlags === void 0) { extraFlags = 0; }
42999             return context && createInferenceContextWorker(ts.map(context.inferences, cloneInferenceInfo), context.signature, context.flags | extraFlags, context.compareTypes);
43000         }
43001         function createInferenceContextWorker(inferences, signature, flags, compareTypes) {
43002             var context = {
43003                 inferences: inferences,
43004                 signature: signature,
43005                 flags: flags,
43006                 compareTypes: compareTypes,
43007                 mapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, true); }),
43008                 nonFixingMapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, false); }),
43009             };
43010             return context;
43011         }
43012         function mapToInferredType(context, t, fix) {
43013             var inferences = context.inferences;
43014             for (var i = 0; i < inferences.length; i++) {
43015                 var inference = inferences[i];
43016                 if (t === inference.typeParameter) {
43017                     if (fix && !inference.isFixed) {
43018                         clearCachedInferences(inferences);
43019                         inference.isFixed = true;
43020                     }
43021                     return getInferredType(context, i);
43022                 }
43023             }
43024             return t;
43025         }
43026         function clearCachedInferences(inferences) {
43027             for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) {
43028                 var inference = inferences_1[_i];
43029                 if (!inference.isFixed) {
43030                     inference.inferredType = undefined;
43031                 }
43032             }
43033         }
43034         function createInferenceInfo(typeParameter) {
43035             return {
43036                 typeParameter: typeParameter,
43037                 candidates: undefined,
43038                 contraCandidates: undefined,
43039                 inferredType: undefined,
43040                 priority: undefined,
43041                 topLevel: true,
43042                 isFixed: false
43043             };
43044         }
43045         function cloneInferenceInfo(inference) {
43046             return {
43047                 typeParameter: inference.typeParameter,
43048                 candidates: inference.candidates && inference.candidates.slice(),
43049                 contraCandidates: inference.contraCandidates && inference.contraCandidates.slice(),
43050                 inferredType: inference.inferredType,
43051                 priority: inference.priority,
43052                 topLevel: inference.topLevel,
43053                 isFixed: inference.isFixed
43054             };
43055         }
43056         function cloneInferredPartOfContext(context) {
43057             var inferences = ts.filter(context.inferences, hasInferenceCandidates);
43058             return inferences.length ?
43059                 createInferenceContextWorker(ts.map(inferences, cloneInferenceInfo), context.signature, context.flags, context.compareTypes) :
43060                 undefined;
43061         }
43062         function getMapperFromContext(context) {
43063             return context && context.mapper;
43064         }
43065         function couldContainTypeVariables(type) {
43066             var objectFlags = ts.getObjectFlags(type);
43067             if (objectFlags & 67108864) {
43068                 return !!(objectFlags & 134217728);
43069             }
43070             var result = !!(type.flags & 63176704 ||
43071                 objectFlags & 4 && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) ||
43072                 objectFlags & 16 && type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) && type.symbol.declarations ||
43073                 objectFlags & (32 | 131072) ||
43074                 type.flags & 3145728 && !(type.flags & 1024) && ts.some(type.types, couldContainTypeVariables));
43075             if (type.flags & 3899393) {
43076                 type.objectFlags |= 67108864 | (result ? 134217728 : 0);
43077             }
43078             return result;
43079         }
43080         function isTypeParameterAtTopLevel(type, typeParameter) {
43081             return !!(type === typeParameter ||
43082                 type.flags & 3145728 && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) ||
43083                 type.flags & 16777216 && (isTypeParameterAtTopLevel(getTrueTypeFromConditionalType(type), typeParameter) ||
43084                     isTypeParameterAtTopLevel(getFalseTypeFromConditionalType(type), typeParameter)));
43085         }
43086         function createEmptyObjectTypeFromStringLiteral(type) {
43087             var members = ts.createSymbolTable();
43088             forEachType(type, function (t) {
43089                 if (!(t.flags & 128)) {
43090                     return;
43091                 }
43092                 var name = ts.escapeLeadingUnderscores(t.value);
43093                 var literalProp = createSymbol(4, name);
43094                 literalProp.type = anyType;
43095                 if (t.symbol) {
43096                     literalProp.declarations = t.symbol.declarations;
43097                     literalProp.valueDeclaration = t.symbol.valueDeclaration;
43098                 }
43099                 members.set(name, literalProp);
43100             });
43101             var indexInfo = type.flags & 4 ? createIndexInfo(emptyObjectType, false) : undefined;
43102             return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfo, undefined);
43103         }
43104         function inferTypeForHomomorphicMappedType(source, target, constraint) {
43105             var key = source.id + "," + target.id + "," + constraint.id;
43106             if (reverseMappedCache.has(key)) {
43107                 return reverseMappedCache.get(key);
43108             }
43109             reverseMappedCache.set(key, undefined);
43110             var type = createReverseMappedType(source, target, constraint);
43111             reverseMappedCache.set(key, type);
43112             return type;
43113         }
43114         function isPartiallyInferableType(type) {
43115             return !(ts.getObjectFlags(type) & 2097152) ||
43116                 isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); });
43117         }
43118         function createReverseMappedType(source, target, constraint) {
43119             if (!(getIndexInfoOfType(source, 0) || getPropertiesOfType(source).length !== 0 && isPartiallyInferableType(source))) {
43120                 return undefined;
43121             }
43122             if (isArrayType(source)) {
43123                 return createArrayType(inferReverseMappedType(getTypeArguments(source)[0], target, constraint), isReadonlyArrayType(source));
43124             }
43125             if (isTupleType(source)) {
43126                 var elementTypes = ts.map(getTypeArguments(source), function (t) { return inferReverseMappedType(t, target, constraint); });
43127                 var minLength = getMappedTypeModifiers(target) & 4 ?
43128                     getTypeReferenceArity(source) - (source.target.hasRestElement ? 1 : 0) : source.target.minLength;
43129                 return createTupleType(elementTypes, minLength, source.target.hasRestElement, source.target.readonly, source.target.associatedNames);
43130             }
43131             var reversed = createObjectType(2048 | 16, undefined);
43132             reversed.source = source;
43133             reversed.mappedType = target;
43134             reversed.constraintType = constraint;
43135             return reversed;
43136         }
43137         function getTypeOfReverseMappedSymbol(symbol) {
43138             return inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType);
43139         }
43140         function inferReverseMappedType(sourceType, target, constraint) {
43141             var typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target));
43142             var templateType = getTemplateTypeFromMappedType(target);
43143             var inference = createInferenceInfo(typeParameter);
43144             inferTypes([inference], sourceType, templateType);
43145             return getTypeFromInference(inference) || unknownType;
43146         }
43147         function getUnmatchedProperties(source, target, requireOptionalProperties, matchDiscriminantProperties) {
43148             var properties, _i, properties_2, targetProp, sourceProp, targetType, sourceType;
43149             return __generator(this, function (_a) {
43150                 switch (_a.label) {
43151                     case 0:
43152                         properties = getPropertiesOfType(target);
43153                         _i = 0, properties_2 = properties;
43154                         _a.label = 1;
43155                     case 1:
43156                         if (!(_i < properties_2.length)) return [3, 6];
43157                         targetProp = properties_2[_i];
43158                         if (isStaticPrivateIdentifierProperty(targetProp)) {
43159                             return [3, 5];
43160                         }
43161                         if (!(requireOptionalProperties || !(targetProp.flags & 16777216 || ts.getCheckFlags(targetProp) & 48))) return [3, 5];
43162                         sourceProp = getPropertyOfType(source, targetProp.escapedName);
43163                         if (!!sourceProp) return [3, 3];
43164                         return [4, targetProp];
43165                     case 2:
43166                         _a.sent();
43167                         return [3, 5];
43168                     case 3:
43169                         if (!matchDiscriminantProperties) return [3, 5];
43170                         targetType = getTypeOfSymbol(targetProp);
43171                         if (!(targetType.flags & 109440)) return [3, 5];
43172                         sourceType = getTypeOfSymbol(sourceProp);
43173                         if (!!(sourceType.flags & 1 || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3, 5];
43174                         return [4, targetProp];
43175                     case 4:
43176                         _a.sent();
43177                         _a.label = 5;
43178                     case 5:
43179                         _i++;
43180                         return [3, 1];
43181                     case 6: return [2];
43182                 }
43183             });
43184         }
43185         function getUnmatchedProperty(source, target, requireOptionalProperties, matchDiscriminantProperties) {
43186             var result = getUnmatchedProperties(source, target, requireOptionalProperties, matchDiscriminantProperties).next();
43187             if (!result.done)
43188                 return result.value;
43189         }
43190         function tupleTypesDefinitelyUnrelated(source, target) {
43191             return target.target.minLength > source.target.minLength ||
43192                 !getRestTypeOfTupleType(target) && (!!getRestTypeOfTupleType(source) || getLengthOfTupleType(target) < getLengthOfTupleType(source));
43193         }
43194         function typesDefinitelyUnrelated(source, target) {
43195             return isTupleType(source) && isTupleType(target) && tupleTypesDefinitelyUnrelated(source, target) ||
43196                 !!getUnmatchedProperty(source, target, false, true) &&
43197                     !!getUnmatchedProperty(target, source, false, true);
43198         }
43199         function getTypeFromInference(inference) {
43200             return inference.candidates ? getUnionType(inference.candidates, 2) :
43201                 inference.contraCandidates ? getIntersectionType(inference.contraCandidates) :
43202                     undefined;
43203         }
43204         function hasSkipDirectInferenceFlag(node) {
43205             return !!getNodeLinks(node).skipDirectInference;
43206         }
43207         function isFromInferenceBlockedSource(type) {
43208             return !!(type.symbol && ts.some(type.symbol.declarations, hasSkipDirectInferenceFlag));
43209         }
43210         function inferTypes(inferences, originalSource, originalTarget, priority, contravariant) {
43211             if (priority === void 0) { priority = 0; }
43212             if (contravariant === void 0) { contravariant = false; }
43213             var symbolOrTypeStack;
43214             var visited;
43215             var bivariant = false;
43216             var propagationType;
43217             var inferencePriority = 512;
43218             var allowComplexConstraintInference = true;
43219             inferFromTypes(originalSource, originalTarget);
43220             function inferFromTypes(source, target) {
43221                 if (!couldContainTypeVariables(target)) {
43222                     return;
43223                 }
43224                 if (source === wildcardType) {
43225                     var savePropagationType = propagationType;
43226                     propagationType = source;
43227                     inferFromTypes(target, target);
43228                     propagationType = savePropagationType;
43229                     return;
43230                 }
43231                 if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) {
43232                     inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol));
43233                     return;
43234                 }
43235                 if (source === target && source.flags & 3145728) {
43236                     for (var _i = 0, _a = source.types; _i < _a.length; _i++) {
43237                         var t = _a[_i];
43238                         inferFromTypes(t, t);
43239                     }
43240                     return;
43241                 }
43242                 if (target.flags & 1048576) {
43243                     var _b = inferFromMatchingTypes(source.flags & 1048576 ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1];
43244                     var _c = inferFromMatchingTypes(tempSources, tempTargets, isTypeCloselyMatchedBy), sources = _c[0], targets = _c[1];
43245                     if (targets.length === 0) {
43246                         return;
43247                     }
43248                     target = getUnionType(targets);
43249                     if (sources.length === 0) {
43250                         inferWithPriority(source, target, 1);
43251                         return;
43252                     }
43253                     source = getUnionType(sources);
43254                 }
43255                 else if (target.flags & 2097152 && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) {
43256                     if (!(source.flags & 1048576)) {
43257                         var _d = inferFromMatchingTypes(source.flags & 2097152 ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1];
43258                         if (sources.length === 0 || targets.length === 0) {
43259                             return;
43260                         }
43261                         source = getIntersectionType(sources);
43262                         target = getIntersectionType(targets);
43263                     }
43264                 }
43265                 else if (target.flags & (8388608 | 33554432)) {
43266                     target = getActualTypeVariable(target);
43267                 }
43268                 if (target.flags & 8650752) {
43269                     if (ts.getObjectFlags(source) & 2097152 || source === nonInferrableAnyType || source === silentNeverType ||
43270                         (priority & 32 && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) {
43271                         return;
43272                     }
43273                     var inference = getInferenceInfoForType(target);
43274                     if (inference) {
43275                         if (!inference.isFixed) {
43276                             if (inference.priority === undefined || priority < inference.priority) {
43277                                 inference.candidates = undefined;
43278                                 inference.contraCandidates = undefined;
43279                                 inference.topLevel = true;
43280                                 inference.priority = priority;
43281                             }
43282                             if (priority === inference.priority) {
43283                                 var candidate = propagationType || source;
43284                                 if (contravariant && !bivariant) {
43285                                     if (!ts.contains(inference.contraCandidates, candidate)) {
43286                                         inference.contraCandidates = ts.append(inference.contraCandidates, candidate);
43287                                         clearCachedInferences(inferences);
43288                                     }
43289                                 }
43290                                 else if (!ts.contains(inference.candidates, candidate)) {
43291                                     inference.candidates = ts.append(inference.candidates, candidate);
43292                                     clearCachedInferences(inferences);
43293                                 }
43294                             }
43295                             if (!(priority & 32) && target.flags & 262144 && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) {
43296                                 inference.topLevel = false;
43297                                 clearCachedInferences(inferences);
43298                             }
43299                         }
43300                         inferencePriority = Math.min(inferencePriority, priority);
43301                         return;
43302                     }
43303                     else {
43304                         var simplified = getSimplifiedType(target, false);
43305                         if (simplified !== target) {
43306                             invokeOnce(source, simplified, inferFromTypes);
43307                         }
43308                         else if (target.flags & 8388608) {
43309                             var indexType = getSimplifiedType(target.indexType, false);
43310                             if (indexType.flags & 63176704) {
43311                                 var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, false), indexType, false);
43312                                 if (simplified_1 && simplified_1 !== target) {
43313                                     invokeOnce(source, simplified_1, inferFromTypes);
43314                                 }
43315                             }
43316                         }
43317                     }
43318                 }
43319                 if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && (source.target === target.target || isArrayType(source) && isArrayType(target)) &&
43320                     !(source.node && target.node)) {
43321                     inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
43322                 }
43323                 else if (source.flags & 4194304 && target.flags & 4194304) {
43324                     contravariant = !contravariant;
43325                     inferFromTypes(source.type, target.type);
43326                     contravariant = !contravariant;
43327                 }
43328                 else if ((isLiteralType(source) || source.flags & 4) && target.flags & 4194304) {
43329                     var empty = createEmptyObjectTypeFromStringLiteral(source);
43330                     contravariant = !contravariant;
43331                     inferWithPriority(empty, target.type, 64);
43332                     contravariant = !contravariant;
43333                 }
43334                 else if (source.flags & 8388608 && target.flags & 8388608) {
43335                     inferFromTypes(source.objectType, target.objectType);
43336                     inferFromTypes(source.indexType, target.indexType);
43337                 }
43338                 else if (source.flags & 16777216 && target.flags & 16777216) {
43339                     inferFromTypes(source.checkType, target.checkType);
43340                     inferFromTypes(source.extendsType, target.extendsType);
43341                     inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target));
43342                     inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target));
43343                 }
43344                 else if (target.flags & 16777216) {
43345                     var savePriority = priority;
43346                     priority |= contravariant ? 16 : 0;
43347                     var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)];
43348                     inferToMultipleTypes(source, targetTypes, target.flags);
43349                     priority = savePriority;
43350                 }
43351                 else if (target.flags & 3145728) {
43352                     inferToMultipleTypes(source, target.types, target.flags);
43353                 }
43354                 else if (source.flags & 1048576) {
43355                     var sourceTypes = source.types;
43356                     for (var _e = 0, sourceTypes_2 = sourceTypes; _e < sourceTypes_2.length; _e++) {
43357                         var sourceType = sourceTypes_2[_e];
43358                         inferFromTypes(sourceType, target);
43359                     }
43360                 }
43361                 else {
43362                     source = getReducedType(source);
43363                     if (!(priority & 128 && source.flags & (2097152 | 63176704))) {
43364                         var apparentSource = getApparentType(source);
43365                         if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 | 2097152))) {
43366                             allowComplexConstraintInference = false;
43367                             return inferFromTypes(apparentSource, target);
43368                         }
43369                         source = apparentSource;
43370                     }
43371                     if (source.flags & (524288 | 2097152)) {
43372                         invokeOnce(source, target, inferFromObjectTypes);
43373                     }
43374                 }
43375                 if (source.flags & 25165824) {
43376                     var simplified = getSimplifiedType(source, contravariant);
43377                     if (simplified !== source) {
43378                         inferFromTypes(simplified, target);
43379                     }
43380                 }
43381             }
43382             function inferWithPriority(source, target, newPriority) {
43383                 var savePriority = priority;
43384                 priority |= newPriority;
43385                 inferFromTypes(source, target);
43386                 priority = savePriority;
43387             }
43388             function invokeOnce(source, target, action) {
43389                 var key = source.id + "," + target.id;
43390                 var status = visited && visited.get(key);
43391                 if (status !== undefined) {
43392                     inferencePriority = Math.min(inferencePriority, status);
43393                     return;
43394                 }
43395                 (visited || (visited = ts.createMap())).set(key, -1);
43396                 var saveInferencePriority = inferencePriority;
43397                 inferencePriority = 512;
43398                 action(source, target);
43399                 visited.set(key, inferencePriority);
43400                 inferencePriority = Math.min(inferencePriority, saveInferencePriority);
43401             }
43402             function inferFromMatchingTypes(sources, targets, matches) {
43403                 var matchedSources;
43404                 var matchedTargets;
43405                 for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) {
43406                     var t = targets_1[_i];
43407                     for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) {
43408                         var s = sources_1[_a];
43409                         if (matches(s, t)) {
43410                             inferFromTypes(s, t);
43411                             matchedSources = ts.appendIfUnique(matchedSources, s);
43412                             matchedTargets = ts.appendIfUnique(matchedTargets, t);
43413                         }
43414                     }
43415                 }
43416                 return [
43417                     matchedSources ? ts.filter(sources, function (t) { return !ts.contains(matchedSources, t); }) : sources,
43418                     matchedTargets ? ts.filter(targets, function (t) { return !ts.contains(matchedTargets, t); }) : targets,
43419                 ];
43420             }
43421             function inferFromTypeArguments(sourceTypes, targetTypes, variances) {
43422                 var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length;
43423                 for (var i = 0; i < count; i++) {
43424                     if (i < variances.length && (variances[i] & 7) === 2) {
43425                         inferFromContravariantTypes(sourceTypes[i], targetTypes[i]);
43426                     }
43427                     else {
43428                         inferFromTypes(sourceTypes[i], targetTypes[i]);
43429                     }
43430                 }
43431             }
43432             function inferFromContravariantTypes(source, target) {
43433                 if (strictFunctionTypes || priority & 256) {
43434                     contravariant = !contravariant;
43435                     inferFromTypes(source, target);
43436                     contravariant = !contravariant;
43437                 }
43438                 else {
43439                     inferFromTypes(source, target);
43440                 }
43441             }
43442             function getInferenceInfoForType(type) {
43443                 if (type.flags & 8650752) {
43444                     for (var _i = 0, inferences_2 = inferences; _i < inferences_2.length; _i++) {
43445                         var inference = inferences_2[_i];
43446                         if (type === inference.typeParameter) {
43447                             return inference;
43448                         }
43449                     }
43450                 }
43451                 return undefined;
43452             }
43453             function getSingleTypeVariableFromIntersectionTypes(types) {
43454                 var typeVariable;
43455                 for (var _i = 0, types_14 = types; _i < types_14.length; _i++) {
43456                     var type = types_14[_i];
43457                     var t = type.flags & 2097152 && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); });
43458                     if (!t || typeVariable && t !== typeVariable) {
43459                         return undefined;
43460                     }
43461                     typeVariable = t;
43462                 }
43463                 return typeVariable;
43464             }
43465             function inferToMultipleTypes(source, targets, targetFlags) {
43466                 var typeVariableCount = 0;
43467                 if (targetFlags & 1048576) {
43468                     var nakedTypeVariable = void 0;
43469                     var sources = source.flags & 1048576 ? source.types : [source];
43470                     var matched_1 = new Array(sources.length);
43471                     var inferenceCircularity = false;
43472                     for (var _i = 0, targets_2 = targets; _i < targets_2.length; _i++) {
43473                         var t = targets_2[_i];
43474                         if (getInferenceInfoForType(t)) {
43475                             nakedTypeVariable = t;
43476                             typeVariableCount++;
43477                         }
43478                         else {
43479                             for (var i = 0; i < sources.length; i++) {
43480                                 var saveInferencePriority = inferencePriority;
43481                                 inferencePriority = 512;
43482                                 inferFromTypes(sources[i], t);
43483                                 if (inferencePriority === priority)
43484                                     matched_1[i] = true;
43485                                 inferenceCircularity = inferenceCircularity || inferencePriority === -1;
43486                                 inferencePriority = Math.min(inferencePriority, saveInferencePriority);
43487                             }
43488                         }
43489                     }
43490                     if (typeVariableCount === 0) {
43491                         var intersectionTypeVariable = getSingleTypeVariableFromIntersectionTypes(targets);
43492                         if (intersectionTypeVariable) {
43493                             inferWithPriority(source, intersectionTypeVariable, 1);
43494                         }
43495                         return;
43496                     }
43497                     if (typeVariableCount === 1 && !inferenceCircularity) {
43498                         var unmatched = ts.flatMap(sources, function (s, i) { return matched_1[i] ? undefined : s; });
43499                         if (unmatched.length) {
43500                             inferFromTypes(getUnionType(unmatched), nakedTypeVariable);
43501                             return;
43502                         }
43503                     }
43504                 }
43505                 else {
43506                     for (var _a = 0, targets_3 = targets; _a < targets_3.length; _a++) {
43507                         var t = targets_3[_a];
43508                         if (getInferenceInfoForType(t)) {
43509                             typeVariableCount++;
43510                         }
43511                         else {
43512                             inferFromTypes(source, t);
43513                         }
43514                     }
43515                 }
43516                 if (targetFlags & 2097152 ? typeVariableCount === 1 : typeVariableCount > 0) {
43517                     for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) {
43518                         var t = targets_4[_b];
43519                         if (getInferenceInfoForType(t)) {
43520                             inferWithPriority(source, t, 1);
43521                         }
43522                     }
43523                 }
43524             }
43525             function inferToMappedType(source, target, constraintType) {
43526                 if (constraintType.flags & 1048576) {
43527                     var result = false;
43528                     for (var _i = 0, _a = constraintType.types; _i < _a.length; _i++) {
43529                         var type = _a[_i];
43530                         result = inferToMappedType(source, target, type) || result;
43531                     }
43532                     return result;
43533                 }
43534                 if (constraintType.flags & 4194304) {
43535                     var inference = getInferenceInfoForType(constraintType.type);
43536                     if (inference && !inference.isFixed && !isFromInferenceBlockedSource(source)) {
43537                         var inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType);
43538                         if (inferredType) {
43539                             inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 2097152 ?
43540                                 4 :
43541                                 2);
43542                         }
43543                     }
43544                     return true;
43545                 }
43546                 if (constraintType.flags & 262144) {
43547                     inferWithPriority(getIndexType(source), constraintType, 8);
43548                     var extendedConstraint = getConstraintOfType(constraintType);
43549                     if (extendedConstraint && inferToMappedType(source, target, extendedConstraint)) {
43550                         return true;
43551                     }
43552                     var propTypes = ts.map(getPropertiesOfType(source), getTypeOfSymbol);
43553                     var stringIndexType = getIndexTypeOfType(source, 0);
43554                     var numberIndexInfo = getNonEnumNumberIndexInfo(source);
43555                     var numberIndexType = numberIndexInfo && numberIndexInfo.type;
43556                     inferFromTypes(getUnionType(ts.append(ts.append(propTypes, stringIndexType), numberIndexType)), getTemplateTypeFromMappedType(target));
43557                     return true;
43558                 }
43559                 return false;
43560             }
43561             function inferFromObjectTypes(source, target) {
43562                 var isNonConstructorObject = target.flags & 524288 &&
43563                     !(ts.getObjectFlags(target) & 16 && target.symbol && target.symbol.flags & 32);
43564                 var symbolOrType = isNonConstructorObject ? isTupleType(target) ? target.target : target.symbol : undefined;
43565                 if (symbolOrType) {
43566                     if (ts.contains(symbolOrTypeStack, symbolOrType)) {
43567                         inferencePriority = -1;
43568                         return;
43569                     }
43570                     (symbolOrTypeStack || (symbolOrTypeStack = [])).push(symbolOrType);
43571                     inferFromObjectTypesWorker(source, target);
43572                     symbolOrTypeStack.pop();
43573                 }
43574                 else {
43575                     inferFromObjectTypesWorker(source, target);
43576                 }
43577             }
43578             function inferFromObjectTypesWorker(source, target) {
43579                 if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && (source.target === target.target || isArrayType(source) && isArrayType(target))) {
43580                     inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
43581                     return;
43582                 }
43583                 if (isGenericMappedType(source) && isGenericMappedType(target)) {
43584                     inferFromTypes(getConstraintTypeFromMappedType(source), getConstraintTypeFromMappedType(target));
43585                     inferFromTypes(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target));
43586                 }
43587                 if (ts.getObjectFlags(target) & 32) {
43588                     var constraintType = getConstraintTypeFromMappedType(target);
43589                     if (inferToMappedType(source, target, constraintType)) {
43590                         return;
43591                     }
43592                 }
43593                 if (!typesDefinitelyUnrelated(source, target)) {
43594                     if (isArrayType(source) || isTupleType(source)) {
43595                         if (isTupleType(target)) {
43596                             var sourceLength = isTupleType(source) ? getLengthOfTupleType(source) : 0;
43597                             var targetLength = getLengthOfTupleType(target);
43598                             var sourceRestType = isTupleType(source) ? getRestTypeOfTupleType(source) : getElementTypeOfArrayType(source);
43599                             var targetRestType = getRestTypeOfTupleType(target);
43600                             var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength;
43601                             for (var i = 0; i < fixedLength; i++) {
43602                                 inferFromTypes(i < sourceLength ? getTypeArguments(source)[i] : sourceRestType, getTypeArguments(target)[i]);
43603                             }
43604                             if (targetRestType) {
43605                                 var types = fixedLength < sourceLength ? getTypeArguments(source).slice(fixedLength, sourceLength) : [];
43606                                 if (sourceRestType) {
43607                                     types.push(sourceRestType);
43608                                 }
43609                                 if (types.length) {
43610                                     inferFromTypes(getUnionType(types), targetRestType);
43611                                 }
43612                             }
43613                             return;
43614                         }
43615                         if (isArrayType(target)) {
43616                             inferFromIndexTypes(source, target);
43617                             return;
43618                         }
43619                     }
43620                     inferFromProperties(source, target);
43621                     inferFromSignatures(source, target, 0);
43622                     inferFromSignatures(source, target, 1);
43623                     inferFromIndexTypes(source, target);
43624                 }
43625             }
43626             function inferFromProperties(source, target) {
43627                 var properties = getPropertiesOfObjectType(target);
43628                 for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) {
43629                     var targetProp = properties_3[_i];
43630                     var sourceProp = getPropertyOfType(source, targetProp.escapedName);
43631                     if (sourceProp) {
43632                         inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
43633                     }
43634                 }
43635             }
43636             function inferFromSignatures(source, target, kind) {
43637                 var sourceSignatures = getSignaturesOfType(source, kind);
43638                 var targetSignatures = getSignaturesOfType(target, kind);
43639                 var sourceLen = sourceSignatures.length;
43640                 var targetLen = targetSignatures.length;
43641                 var len = sourceLen < targetLen ? sourceLen : targetLen;
43642                 var skipParameters = !!(ts.getObjectFlags(source) & 2097152);
43643                 for (var i = 0; i < len; i++) {
43644                     inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters);
43645                 }
43646             }
43647             function inferFromSignature(source, target, skipParameters) {
43648                 if (!skipParameters) {
43649                     var saveBivariant = bivariant;
43650                     var kind = target.declaration ? target.declaration.kind : 0;
43651                     bivariant = bivariant || kind === 161 || kind === 160 || kind === 162;
43652                     applyToParameterTypes(source, target, inferFromContravariantTypes);
43653                     bivariant = saveBivariant;
43654                 }
43655                 applyToReturnTypes(source, target, inferFromTypes);
43656             }
43657             function inferFromIndexTypes(source, target) {
43658                 var targetStringIndexType = getIndexTypeOfType(target, 0);
43659                 if (targetStringIndexType) {
43660                     var sourceIndexType = getIndexTypeOfType(source, 0) ||
43661                         getImplicitIndexTypeOfType(source, 0);
43662                     if (sourceIndexType) {
43663                         inferFromTypes(sourceIndexType, targetStringIndexType);
43664                     }
43665                 }
43666                 var targetNumberIndexType = getIndexTypeOfType(target, 1);
43667                 if (targetNumberIndexType) {
43668                     var sourceIndexType = getIndexTypeOfType(source, 1) ||
43669                         getIndexTypeOfType(source, 0) ||
43670                         getImplicitIndexTypeOfType(source, 1);
43671                     if (sourceIndexType) {
43672                         inferFromTypes(sourceIndexType, targetNumberIndexType);
43673                     }
43674                 }
43675             }
43676         }
43677         function isTypeOrBaseIdenticalTo(s, t) {
43678             return isTypeIdenticalTo(s, t) || !!(t.flags & 4 && s.flags & 128 || t.flags & 8 && s.flags & 256);
43679         }
43680         function isTypeCloselyMatchedBy(s, t) {
43681             return !!(s.flags & 524288 && t.flags & 524288 && s.symbol && s.symbol === t.symbol ||
43682                 s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol);
43683         }
43684         function hasPrimitiveConstraint(type) {
43685             var constraint = getConstraintOfTypeParameter(type);
43686             return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 | 4194304);
43687         }
43688         function isObjectLiteralType(type) {
43689             return !!(ts.getObjectFlags(type) & 128);
43690         }
43691         function isObjectOrArrayLiteralType(type) {
43692             return !!(ts.getObjectFlags(type) & (128 | 65536));
43693         }
43694         function unionObjectAndArrayLiteralCandidates(candidates) {
43695             if (candidates.length > 1) {
43696                 var objectLiterals = ts.filter(candidates, isObjectOrArrayLiteralType);
43697                 if (objectLiterals.length) {
43698                     var literalsType = getUnionType(objectLiterals, 2);
43699                     return ts.concatenate(ts.filter(candidates, function (t) { return !isObjectOrArrayLiteralType(t); }), [literalsType]);
43700                 }
43701             }
43702             return candidates;
43703         }
43704         function getContravariantInference(inference) {
43705             return inference.priority & 104 ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates);
43706         }
43707         function getCovariantInference(inference, signature) {
43708             var candidates = unionObjectAndArrayLiteralCandidates(inference.candidates);
43709             var primitiveConstraint = hasPrimitiveConstraint(inference.typeParameter);
43710             var widenLiteralTypes = !primitiveConstraint && inference.topLevel &&
43711                 (inference.isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), inference.typeParameter));
43712             var baseCandidates = primitiveConstraint ? ts.sameMap(candidates, getRegularTypeOfLiteralType) :
43713                 widenLiteralTypes ? ts.sameMap(candidates, getWidenedLiteralType) :
43714                     candidates;
43715             var unwidenedType = inference.priority & 104 ?
43716                 getUnionType(baseCandidates, 2) :
43717                 getCommonSupertype(baseCandidates);
43718             return getWidenedType(unwidenedType);
43719         }
43720         function getInferredType(context, index) {
43721             var inference = context.inferences[index];
43722             if (!inference.inferredType) {
43723                 var inferredType = void 0;
43724                 var signature = context.signature;
43725                 if (signature) {
43726                     var inferredCovariantType = inference.candidates ? getCovariantInference(inference, signature) : undefined;
43727                     if (inference.contraCandidates) {
43728                         var inferredContravariantType = getContravariantInference(inference);
43729                         inferredType = inferredCovariantType && !(inferredCovariantType.flags & 131072) &&
43730                             isTypeSubtypeOf(inferredCovariantType, inferredContravariantType) ?
43731                             inferredCovariantType : inferredContravariantType;
43732                     }
43733                     else if (inferredCovariantType) {
43734                         inferredType = inferredCovariantType;
43735                     }
43736                     else if (context.flags & 1) {
43737                         inferredType = silentNeverType;
43738                     }
43739                     else {
43740                         var defaultType = getDefaultFromTypeParameter(inference.typeParameter);
43741                         if (defaultType) {
43742                             inferredType = instantiateType(defaultType, mergeTypeMappers(createBackreferenceMapper(context, index), context.nonFixingMapper));
43743                         }
43744                     }
43745                 }
43746                 else {
43747                     inferredType = getTypeFromInference(inference);
43748                 }
43749                 inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2));
43750                 var constraint = getConstraintOfTypeParameter(inference.typeParameter);
43751                 if (constraint) {
43752                     var instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
43753                     if (!inferredType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
43754                         inference.inferredType = inferredType = instantiatedConstraint;
43755                     }
43756                 }
43757             }
43758             return inference.inferredType;
43759         }
43760         function getDefaultTypeArgumentType(isInJavaScriptFile) {
43761             return isInJavaScriptFile ? anyType : unknownType;
43762         }
43763         function getInferredTypes(context) {
43764             var result = [];
43765             for (var i = 0; i < context.inferences.length; i++) {
43766                 result.push(getInferredType(context, i));
43767             }
43768             return result;
43769         }
43770         function getCannotFindNameDiagnosticForName(node) {
43771             switch (node.escapedText) {
43772                 case "document":
43773                 case "console":
43774                     return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom;
43775                 case "$":
43776                     return compilerOptions.types
43777                         ? 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
43778                         : ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery;
43779                 case "describe":
43780                 case "suite":
43781                 case "it":
43782                 case "test":
43783                     return compilerOptions.types
43784                         ? 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
43785                         : 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;
43786                 case "process":
43787                 case "require":
43788                 case "Buffer":
43789                 case "module":
43790                     return compilerOptions.types
43791                         ? 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
43792                         : ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode;
43793                 case "Map":
43794                 case "Set":
43795                 case "Promise":
43796                 case "Symbol":
43797                 case "WeakMap":
43798                 case "WeakSet":
43799                 case "Iterator":
43800                 case "AsyncIterator":
43801                     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;
43802                 default:
43803                     if (node.parent.kind === 282) {
43804                         return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer;
43805                     }
43806                     else {
43807                         return ts.Diagnostics.Cannot_find_name_0;
43808                     }
43809             }
43810         }
43811         function getResolvedSymbol(node) {
43812             var links = getNodeLinks(node);
43813             if (!links.resolvedSymbol) {
43814                 links.resolvedSymbol = !ts.nodeIsMissing(node) &&
43815                     resolveName(node, node.escapedText, 111551 | 1048576, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), false, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol;
43816             }
43817             return links.resolvedSymbol;
43818         }
43819         function isInTypeQuery(node) {
43820             return !!ts.findAncestor(node, function (n) { return n.kind === 172 ? true : n.kind === 75 || n.kind === 153 ? false : "quit"; });
43821         }
43822         function getFlowCacheKey(node, declaredType, initialType, flowContainer) {
43823             switch (node.kind) {
43824                 case 75:
43825                     var symbol = getResolvedSymbol(node);
43826                     return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined;
43827                 case 104:
43828                     return "0";
43829                 case 218:
43830                 case 200:
43831                     return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer);
43832                 case 194:
43833                 case 195:
43834                     var propName = getAccessedPropertyName(node);
43835                     if (propName !== undefined) {
43836                         var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer);
43837                         return key && key + "." + propName;
43838                     }
43839             }
43840             return undefined;
43841         }
43842         function isMatchingReference(source, target) {
43843             switch (target.kind) {
43844                 case 200:
43845                 case 218:
43846                     return isMatchingReference(source, target.expression);
43847             }
43848             switch (source.kind) {
43849                 case 75:
43850                     return target.kind === 75 && getResolvedSymbol(source) === getResolvedSymbol(target) ||
43851                         (target.kind === 242 || target.kind === 191) &&
43852                             getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target);
43853                 case 104:
43854                     return target.kind === 104;
43855                 case 102:
43856                     return target.kind === 102;
43857                 case 218:
43858                 case 200:
43859                     return isMatchingReference(source.expression, target);
43860                 case 194:
43861                 case 195:
43862                     return ts.isAccessExpression(target) &&
43863                         getAccessedPropertyName(source) === getAccessedPropertyName(target) &&
43864                         isMatchingReference(source.expression, target.expression);
43865             }
43866             return false;
43867         }
43868         function containsTruthyCheck(source, target) {
43869             return isMatchingReference(source, target) ||
43870                 (target.kind === 209 && target.operatorToken.kind === 55 &&
43871                     (containsTruthyCheck(source, target.left) || containsTruthyCheck(source, target.right)));
43872         }
43873         function getAccessedPropertyName(access) {
43874             return access.kind === 194 ? access.name.escapedText :
43875                 ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) :
43876                     undefined;
43877         }
43878         function containsMatchingReference(source, target) {
43879             while (ts.isAccessExpression(source)) {
43880                 source = source.expression;
43881                 if (isMatchingReference(source, target)) {
43882                     return true;
43883                 }
43884             }
43885             return false;
43886         }
43887         function optionalChainContainsReference(source, target) {
43888             while (ts.isOptionalChain(source)) {
43889                 source = source.expression;
43890                 if (isMatchingReference(source, target)) {
43891                     return true;
43892                 }
43893             }
43894             return false;
43895         }
43896         function isDiscriminantProperty(type, name) {
43897             if (type && type.flags & 1048576) {
43898                 var prop = getUnionOrIntersectionProperty(type, name);
43899                 if (prop && ts.getCheckFlags(prop) & 2) {
43900                     if (prop.isDiscriminantProperty === undefined) {
43901                         prop.isDiscriminantProperty =
43902                             (prop.checkFlags & 192) === 192 &&
43903                                 !maybeTypeOfKind(getTypeOfSymbol(prop), 63176704);
43904                     }
43905                     return !!prop.isDiscriminantProperty;
43906                 }
43907             }
43908             return false;
43909         }
43910         function findDiscriminantProperties(sourceProperties, target) {
43911             var result;
43912             for (var _i = 0, sourceProperties_2 = sourceProperties; _i < sourceProperties_2.length; _i++) {
43913                 var sourceProperty = sourceProperties_2[_i];
43914                 if (isDiscriminantProperty(target, sourceProperty.escapedName)) {
43915                     if (result) {
43916                         result.push(sourceProperty);
43917                         continue;
43918                     }
43919                     result = [sourceProperty];
43920                 }
43921             }
43922             return result;
43923         }
43924         function isOrContainsMatchingReference(source, target) {
43925             return isMatchingReference(source, target) || containsMatchingReference(source, target);
43926         }
43927         function hasMatchingArgument(callExpression, reference) {
43928             if (callExpression.arguments) {
43929                 for (var _i = 0, _a = callExpression.arguments; _i < _a.length; _i++) {
43930                     var argument = _a[_i];
43931                     if (isOrContainsMatchingReference(reference, argument)) {
43932                         return true;
43933                     }
43934                 }
43935             }
43936             if (callExpression.expression.kind === 194 &&
43937                 isOrContainsMatchingReference(reference, callExpression.expression.expression)) {
43938                 return true;
43939             }
43940             return false;
43941         }
43942         function getFlowNodeId(flow) {
43943             if (!flow.id || flow.id < 0) {
43944                 flow.id = nextFlowId;
43945                 nextFlowId++;
43946             }
43947             return flow.id;
43948         }
43949         function typeMaybeAssignableTo(source, target) {
43950             if (!(source.flags & 1048576)) {
43951                 return isTypeAssignableTo(source, target);
43952             }
43953             for (var _i = 0, _a = source.types; _i < _a.length; _i++) {
43954                 var t = _a[_i];
43955                 if (isTypeAssignableTo(t, target)) {
43956                     return true;
43957                 }
43958             }
43959             return false;
43960         }
43961         function getAssignmentReducedType(declaredType, assignedType) {
43962             if (declaredType !== assignedType) {
43963                 if (assignedType.flags & 131072) {
43964                     return assignedType;
43965                 }
43966                 var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); });
43967                 if (assignedType.flags & 512 && isFreshLiteralType(assignedType)) {
43968                     reducedType = mapType(reducedType, getFreshTypeOfLiteralType);
43969                 }
43970                 if (isTypeAssignableTo(assignedType, reducedType)) {
43971                     return reducedType;
43972                 }
43973             }
43974             return declaredType;
43975         }
43976         function getTypeFactsOfTypes(types) {
43977             var result = 0;
43978             for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
43979                 var t = types_15[_i];
43980                 result |= getTypeFacts(t);
43981             }
43982             return result;
43983         }
43984         function isFunctionObjectType(type) {
43985             var resolved = resolveStructuredTypeMembers(type);
43986             return !!(resolved.callSignatures.length || resolved.constructSignatures.length ||
43987                 resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType));
43988         }
43989         function getTypeFacts(type) {
43990             var flags = type.flags;
43991             if (flags & 4) {
43992                 return strictNullChecks ? 16317953 : 16776705;
43993             }
43994             if (flags & 128) {
43995                 var isEmpty = type.value === "";
43996                 return strictNullChecks ?
43997                     isEmpty ? 12123649 : 7929345 :
43998                     isEmpty ? 12582401 : 16776705;
43999             }
44000             if (flags & (8 | 32)) {
44001                 return strictNullChecks ? 16317698 : 16776450;
44002             }
44003             if (flags & 256) {
44004                 var isZero = type.value === 0;
44005                 return strictNullChecks ?
44006                     isZero ? 12123394 : 7929090 :
44007                     isZero ? 12582146 : 16776450;
44008             }
44009             if (flags & 64) {
44010                 return strictNullChecks ? 16317188 : 16775940;
44011             }
44012             if (flags & 2048) {
44013                 var isZero = isZeroBigInt(type);
44014                 return strictNullChecks ?
44015                     isZero ? 12122884 : 7928580 :
44016                     isZero ? 12581636 : 16775940;
44017             }
44018             if (flags & 16) {
44019                 return strictNullChecks ? 16316168 : 16774920;
44020             }
44021             if (flags & 528) {
44022                 return strictNullChecks ?
44023                     (type === falseType || type === regularFalseType) ? 12121864 : 7927560 :
44024                     (type === falseType || type === regularFalseType) ? 12580616 : 16774920;
44025             }
44026             if (flags & 524288) {
44027                 return ts.getObjectFlags(type) & 16 && isEmptyObjectType(type) ?
44028                     strictNullChecks ? 16318463 : 16777215 :
44029                     isFunctionObjectType(type) ?
44030                         strictNullChecks ? 7880640 : 16728000 :
44031                         strictNullChecks ? 7888800 : 16736160;
44032             }
44033             if (flags & (16384 | 32768)) {
44034                 return 9830144;
44035             }
44036             if (flags & 65536) {
44037                 return 9363232;
44038             }
44039             if (flags & 12288) {
44040                 return strictNullChecks ? 7925520 : 16772880;
44041             }
44042             if (flags & 67108864) {
44043                 return strictNullChecks ? 7888800 : 16736160;
44044             }
44045             if (flags & 131072) {
44046                 return 0;
44047             }
44048             if (flags & 63176704) {
44049                 return getTypeFacts(getBaseConstraintOfType(type) || unknownType);
44050             }
44051             if (flags & 3145728) {
44052                 return getTypeFactsOfTypes(type.types);
44053             }
44054             return 16777215;
44055         }
44056         function getTypeWithFacts(type, include) {
44057             return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
44058         }
44059         function getTypeWithDefault(type, defaultExpression) {
44060             if (defaultExpression) {
44061                 var defaultType = getTypeOfExpression(defaultExpression);
44062                 return getUnionType([getTypeWithFacts(type, 524288), defaultType]);
44063             }
44064             return type;
44065         }
44066         function getTypeOfDestructuredProperty(type, name) {
44067             var nameType = getLiteralTypeFromPropertyName(name);
44068             if (!isTypeUsableAsPropertyName(nameType))
44069                 return errorType;
44070             var text = getPropertyNameFromType(nameType);
44071             return getConstraintForLocation(getTypeOfPropertyOfType(type, text), name) ||
44072                 isNumericLiteralName(text) && getIndexTypeOfType(type, 1) ||
44073                 getIndexTypeOfType(type, 0) ||
44074                 errorType;
44075         }
44076         function getTypeOfDestructuredArrayElement(type, index) {
44077             return everyType(type, isTupleLikeType) && getTupleElementType(type, index) ||
44078                 checkIteratedTypeOrElementType(65, type, undefinedType, undefined) ||
44079                 errorType;
44080         }
44081         function getTypeOfDestructuredSpreadExpression(type) {
44082             return createArrayType(checkIteratedTypeOrElementType(65, type, undefinedType, undefined) || errorType);
44083         }
44084         function getAssignedTypeOfBinaryExpression(node) {
44085             var isDestructuringDefaultAssignment = node.parent.kind === 192 && isDestructuringAssignmentTarget(node.parent) ||
44086                 node.parent.kind === 281 && isDestructuringAssignmentTarget(node.parent.parent);
44087             return isDestructuringDefaultAssignment ?
44088                 getTypeWithDefault(getAssignedType(node), node.right) :
44089                 getTypeOfExpression(node.right);
44090         }
44091         function isDestructuringAssignmentTarget(parent) {
44092             return parent.parent.kind === 209 && parent.parent.left === parent ||
44093                 parent.parent.kind === 232 && parent.parent.initializer === parent;
44094         }
44095         function getAssignedTypeOfArrayLiteralElement(node, element) {
44096             return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element));
44097         }
44098         function getAssignedTypeOfSpreadExpression(node) {
44099             return getTypeOfDestructuredSpreadExpression(getAssignedType(node.parent));
44100         }
44101         function getAssignedTypeOfPropertyAssignment(node) {
44102             return getTypeOfDestructuredProperty(getAssignedType(node.parent), node.name);
44103         }
44104         function getAssignedTypeOfShorthandPropertyAssignment(node) {
44105             return getTypeWithDefault(getAssignedTypeOfPropertyAssignment(node), node.objectAssignmentInitializer);
44106         }
44107         function getAssignedType(node) {
44108             var parent = node.parent;
44109             switch (parent.kind) {
44110                 case 231:
44111                     return stringType;
44112                 case 232:
44113                     return checkRightHandSideOfForOf(parent) || errorType;
44114                 case 209:
44115                     return getAssignedTypeOfBinaryExpression(parent);
44116                 case 203:
44117                     return undefinedType;
44118                 case 192:
44119                     return getAssignedTypeOfArrayLiteralElement(parent, node);
44120                 case 213:
44121                     return getAssignedTypeOfSpreadExpression(parent);
44122                 case 281:
44123                     return getAssignedTypeOfPropertyAssignment(parent);
44124                 case 282:
44125                     return getAssignedTypeOfShorthandPropertyAssignment(parent);
44126             }
44127             return errorType;
44128         }
44129         function getInitialTypeOfBindingElement(node) {
44130             var pattern = node.parent;
44131             var parentType = getInitialType(pattern.parent);
44132             var type = pattern.kind === 189 ?
44133                 getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) :
44134                 !node.dotDotDotToken ?
44135                     getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) :
44136                     getTypeOfDestructuredSpreadExpression(parentType);
44137             return getTypeWithDefault(type, node.initializer);
44138         }
44139         function getTypeOfInitializer(node) {
44140             var links = getNodeLinks(node);
44141             return links.resolvedType || getTypeOfExpression(node);
44142         }
44143         function getInitialTypeOfVariableDeclaration(node) {
44144             if (node.initializer) {
44145                 return getTypeOfInitializer(node.initializer);
44146             }
44147             if (node.parent.parent.kind === 231) {
44148                 return stringType;
44149             }
44150             if (node.parent.parent.kind === 232) {
44151                 return checkRightHandSideOfForOf(node.parent.parent) || errorType;
44152             }
44153             return errorType;
44154         }
44155         function getInitialType(node) {
44156             return node.kind === 242 ?
44157                 getInitialTypeOfVariableDeclaration(node) :
44158                 getInitialTypeOfBindingElement(node);
44159         }
44160         function isEmptyArrayAssignment(node) {
44161             return node.kind === 242 && node.initializer &&
44162                 isEmptyArrayLiteral(node.initializer) ||
44163                 node.kind !== 191 && node.parent.kind === 209 &&
44164                     isEmptyArrayLiteral(node.parent.right);
44165         }
44166         function getReferenceCandidate(node) {
44167             switch (node.kind) {
44168                 case 200:
44169                     return getReferenceCandidate(node.expression);
44170                 case 209:
44171                     switch (node.operatorToken.kind) {
44172                         case 62:
44173                             return getReferenceCandidate(node.left);
44174                         case 27:
44175                             return getReferenceCandidate(node.right);
44176                     }
44177             }
44178             return node;
44179         }
44180         function getReferenceRoot(node) {
44181             var parent = node.parent;
44182             return parent.kind === 200 ||
44183                 parent.kind === 209 && parent.operatorToken.kind === 62 && parent.left === node ||
44184                 parent.kind === 209 && parent.operatorToken.kind === 27 && parent.right === node ?
44185                 getReferenceRoot(parent) : node;
44186         }
44187         function getTypeOfSwitchClause(clause) {
44188             if (clause.kind === 277) {
44189                 return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression));
44190             }
44191             return neverType;
44192         }
44193         function getSwitchClauseTypes(switchStatement) {
44194             var links = getNodeLinks(switchStatement);
44195             if (!links.switchTypes) {
44196                 links.switchTypes = [];
44197                 for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) {
44198                     var clause = _a[_i];
44199                     links.switchTypes.push(getTypeOfSwitchClause(clause));
44200                 }
44201             }
44202             return links.switchTypes;
44203         }
44204         function getSwitchClauseTypeOfWitnesses(switchStatement, retainDefault) {
44205             var witnesses = [];
44206             for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) {
44207                 var clause = _a[_i];
44208                 if (clause.kind === 277) {
44209                     if (ts.isStringLiteralLike(clause.expression)) {
44210                         witnesses.push(clause.expression.text);
44211                         continue;
44212                     }
44213                     return ts.emptyArray;
44214                 }
44215                 if (retainDefault)
44216                     witnesses.push(undefined);
44217             }
44218             return witnesses;
44219         }
44220         function eachTypeContainedIn(source, types) {
44221             return source.flags & 1048576 ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source);
44222         }
44223         function isTypeSubsetOf(source, target) {
44224             return source === target || target.flags & 1048576 && isTypeSubsetOfUnion(source, target);
44225         }
44226         function isTypeSubsetOfUnion(source, target) {
44227             if (source.flags & 1048576) {
44228                 for (var _i = 0, _a = source.types; _i < _a.length; _i++) {
44229                     var t = _a[_i];
44230                     if (!containsType(target.types, t)) {
44231                         return false;
44232                     }
44233                 }
44234                 return true;
44235             }
44236             if (source.flags & 1024 && getBaseTypeOfEnumLiteralType(source) === target) {
44237                 return true;
44238             }
44239             return containsType(target.types, source);
44240         }
44241         function forEachType(type, f) {
44242             return type.flags & 1048576 ? ts.forEach(type.types, f) : f(type);
44243         }
44244         function everyType(type, f) {
44245             return type.flags & 1048576 ? ts.every(type.types, f) : f(type);
44246         }
44247         function filterType(type, f) {
44248             if (type.flags & 1048576) {
44249                 var types = type.types;
44250                 var filtered = ts.filter(types, f);
44251                 return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.objectFlags);
44252             }
44253             return type.flags & 131072 || f(type) ? type : neverType;
44254         }
44255         function countTypes(type) {
44256             return type.flags & 1048576 ? type.types.length : 1;
44257         }
44258         function mapType(type, mapper, noReductions) {
44259             if (type.flags & 131072) {
44260                 return type;
44261             }
44262             if (!(type.flags & 1048576)) {
44263                 return mapper(type);
44264             }
44265             var mappedTypes;
44266             for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
44267                 var t = _a[_i];
44268                 var mapped = mapper(t);
44269                 if (mapped) {
44270                     if (!mappedTypes) {
44271                         mappedTypes = [mapped];
44272                     }
44273                     else {
44274                         mappedTypes.push(mapped);
44275                     }
44276                 }
44277             }
44278             return mappedTypes && getUnionType(mappedTypes, noReductions ? 0 : 1);
44279         }
44280         function extractTypesOfKind(type, kind) {
44281             return filterType(type, function (t) { return (t.flags & kind) !== 0; });
44282         }
44283         function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) {
44284             if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128) ||
44285                 isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 256) ||
44286                 isTypeSubsetOf(bigintType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 2048)) {
44287                 return mapType(typeWithPrimitives, function (t) {
44288                     return t.flags & 4 ? extractTypesOfKind(typeWithLiterals, 4 | 128) :
44289                         t.flags & 8 ? extractTypesOfKind(typeWithLiterals, 8 | 256) :
44290                             t.flags & 64 ? extractTypesOfKind(typeWithLiterals, 64 | 2048) : t;
44291                 });
44292             }
44293             return typeWithPrimitives;
44294         }
44295         function isIncomplete(flowType) {
44296             return flowType.flags === 0;
44297         }
44298         function getTypeFromFlowType(flowType) {
44299             return flowType.flags === 0 ? flowType.type : flowType;
44300         }
44301         function createFlowType(type, incomplete) {
44302             return incomplete ? { flags: 0, type: type } : type;
44303         }
44304         function createEvolvingArrayType(elementType) {
44305             var result = createObjectType(256);
44306             result.elementType = elementType;
44307             return result;
44308         }
44309         function getEvolvingArrayType(elementType) {
44310             return evolvingArrayTypes[elementType.id] || (evolvingArrayTypes[elementType.id] = createEvolvingArrayType(elementType));
44311         }
44312         function addEvolvingArrayElementType(evolvingArrayType, node) {
44313             var elementType = getBaseTypeOfLiteralType(getContextFreeTypeOfExpression(node));
44314             return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType]));
44315         }
44316         function createFinalArrayType(elementType) {
44317             return elementType.flags & 131072 ?
44318                 autoArrayType :
44319                 createArrayType(elementType.flags & 1048576 ?
44320                     getUnionType(elementType.types, 2) :
44321                     elementType);
44322         }
44323         function getFinalArrayType(evolvingArrayType) {
44324             return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType));
44325         }
44326         function finalizeEvolvingArrayType(type) {
44327             return ts.getObjectFlags(type) & 256 ? getFinalArrayType(type) : type;
44328         }
44329         function getElementTypeOfEvolvingArrayType(type) {
44330             return ts.getObjectFlags(type) & 256 ? type.elementType : neverType;
44331         }
44332         function isEvolvingArrayTypeList(types) {
44333             var hasEvolvingArrayType = false;
44334             for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
44335                 var t = types_16[_i];
44336                 if (!(t.flags & 131072)) {
44337                     if (!(ts.getObjectFlags(t) & 256)) {
44338                         return false;
44339                     }
44340                     hasEvolvingArrayType = true;
44341                 }
44342             }
44343             return hasEvolvingArrayType;
44344         }
44345         function getUnionOrEvolvingArrayType(types, subtypeReduction) {
44346             return isEvolvingArrayTypeList(types) ?
44347                 getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))) :
44348                 getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction);
44349         }
44350         function isEvolvingArrayOperationTarget(node) {
44351             var root = getReferenceRoot(node);
44352             var parent = root.parent;
44353             var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" ||
44354                 parent.parent.kind === 196
44355                     && ts.isIdentifier(parent.name)
44356                     && ts.isPushOrUnshiftIdentifier(parent.name));
44357             var isElementAssignment = parent.kind === 195 &&
44358                 parent.expression === root &&
44359                 parent.parent.kind === 209 &&
44360                 parent.parent.operatorToken.kind === 62 &&
44361                 parent.parent.left === parent &&
44362                 !ts.isAssignmentTarget(parent.parent) &&
44363                 isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296);
44364             return isLengthPushOrUnshift || isElementAssignment;
44365         }
44366         function isDeclarationWithExplicitTypeAnnotation(declaration) {
44367             return (declaration.kind === 242 || declaration.kind === 156 ||
44368                 declaration.kind === 159 || declaration.kind === 158) &&
44369                 !!ts.getEffectiveTypeAnnotationNode(declaration);
44370         }
44371         function getExplicitTypeOfSymbol(symbol, diagnostic) {
44372             if (symbol.flags & (16 | 8192 | 32 | 512)) {
44373                 return getTypeOfSymbol(symbol);
44374             }
44375             if (symbol.flags & (3 | 4)) {
44376                 var declaration = symbol.valueDeclaration;
44377                 if (declaration) {
44378                     if (isDeclarationWithExplicitTypeAnnotation(declaration)) {
44379                         return getTypeOfSymbol(symbol);
44380                     }
44381                     if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 232) {
44382                         var statement = declaration.parent.parent;
44383                         var expressionType = getTypeOfDottedName(statement.expression, undefined);
44384                         if (expressionType) {
44385                             var use = statement.awaitModifier ? 15 : 13;
44386                             return checkIteratedTypeOrElementType(use, expressionType, undefinedType, undefined);
44387                         }
44388                     }
44389                     if (diagnostic) {
44390                         ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_needs_an_explicit_type_annotation, symbolToString(symbol)));
44391                     }
44392                 }
44393             }
44394         }
44395         function getTypeOfDottedName(node, diagnostic) {
44396             if (!(node.flags & 16777216)) {
44397                 switch (node.kind) {
44398                     case 75:
44399                         var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node));
44400                         return getExplicitTypeOfSymbol(symbol.flags & 2097152 ? resolveAlias(symbol) : symbol, diagnostic);
44401                     case 104:
44402                         return getExplicitThisType(node);
44403                     case 102:
44404                         return checkSuperExpression(node);
44405                     case 194:
44406                         var type = getTypeOfDottedName(node.expression, diagnostic);
44407                         var prop = type && getPropertyOfType(type, node.name.escapedText);
44408                         return prop && getExplicitTypeOfSymbol(prop, diagnostic);
44409                     case 200:
44410                         return getTypeOfDottedName(node.expression, diagnostic);
44411                 }
44412             }
44413         }
44414         function getEffectsSignature(node) {
44415             var links = getNodeLinks(node);
44416             var signature = links.effectsSignature;
44417             if (signature === undefined) {
44418                 var funcType = void 0;
44419                 if (node.parent.kind === 226) {
44420                     funcType = getTypeOfDottedName(node.expression, undefined);
44421                 }
44422                 else if (node.expression.kind !== 102) {
44423                     if (ts.isOptionalChain(node)) {
44424                         funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression);
44425                     }
44426                     else {
44427                         funcType = checkNonNullExpression(node.expression);
44428                     }
44429                 }
44430                 var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0);
44431                 var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] :
44432                     ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) :
44433                         undefined;
44434                 signature = links.effectsSignature = candidate && hasTypePredicateOrNeverReturnType(candidate) ? candidate : unknownSignature;
44435             }
44436             return signature === unknownSignature ? undefined : signature;
44437         }
44438         function hasTypePredicateOrNeverReturnType(signature) {
44439             return !!(getTypePredicateOfSignature(signature) ||
44440                 signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072);
44441         }
44442         function getTypePredicateArgument(predicate, callExpression) {
44443             if (predicate.kind === 1 || predicate.kind === 3) {
44444                 return callExpression.arguments[predicate.parameterIndex];
44445             }
44446             var invokedExpression = ts.skipParentheses(callExpression.expression);
44447             return ts.isAccessExpression(invokedExpression) ? ts.skipParentheses(invokedExpression.expression) : undefined;
44448         }
44449         function reportFlowControlError(node) {
44450             var block = ts.findAncestor(node, ts.isFunctionOrModuleBlock);
44451             var sourceFile = ts.getSourceFileOfNode(node);
44452             var span = ts.getSpanOfTokenAtPosition(sourceFile, block.statements.pos);
44453             diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis));
44454         }
44455         function isReachableFlowNode(flow) {
44456             var result = isReachableFlowNodeWorker(flow, false);
44457             lastFlowNode = flow;
44458             lastFlowNodeReachable = result;
44459             return result;
44460         }
44461         function isFalseExpression(expr) {
44462             var node = ts.skipParentheses(expr);
44463             return node.kind === 91 || node.kind === 209 && (node.operatorToken.kind === 55 && (isFalseExpression(node.left) || isFalseExpression(node.right)) ||
44464                 node.operatorToken.kind === 56 && isFalseExpression(node.left) && isFalseExpression(node.right));
44465         }
44466         function isReachableFlowNodeWorker(flow, noCacheCheck) {
44467             while (true) {
44468                 if (flow === lastFlowNode) {
44469                     return lastFlowNodeReachable;
44470                 }
44471                 var flags = flow.flags;
44472                 if (flags & 4096) {
44473                     if (!noCacheCheck) {
44474                         var id = getFlowNodeId(flow);
44475                         var reachable = flowNodeReachable[id];
44476                         return reachable !== undefined ? reachable : (flowNodeReachable[id] = isReachableFlowNodeWorker(flow, true));
44477                     }
44478                     noCacheCheck = false;
44479                 }
44480                 if (flags & (16 | 96 | 256)) {
44481                     flow = flow.antecedent;
44482                 }
44483                 else if (flags & 512) {
44484                     var signature = getEffectsSignature(flow.node);
44485                     if (signature) {
44486                         var predicate = getTypePredicateOfSignature(signature);
44487                         if (predicate && predicate.kind === 3) {
44488                             var predicateArgument = flow.node.arguments[predicate.parameterIndex];
44489                             if (predicateArgument && isFalseExpression(predicateArgument)) {
44490                                 return false;
44491                             }
44492                         }
44493                         if (getReturnTypeOfSignature(signature).flags & 131072) {
44494                             return false;
44495                         }
44496                     }
44497                     flow = flow.antecedent;
44498                 }
44499                 else if (flags & 4) {
44500                     return ts.some(flow.antecedents, function (f) { return isReachableFlowNodeWorker(f, false); });
44501                 }
44502                 else if (flags & 8) {
44503                     flow = flow.antecedents[0];
44504                 }
44505                 else if (flags & 128) {
44506                     if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) {
44507                         return false;
44508                     }
44509                     flow = flow.antecedent;
44510                 }
44511                 else if (flags & 1024) {
44512                     lastFlowNode = undefined;
44513                     var target = flow.target;
44514                     var saveAntecedents = target.antecedents;
44515                     target.antecedents = flow.antecedents;
44516                     var result = isReachableFlowNodeWorker(flow.antecedent, false);
44517                     target.antecedents = saveAntecedents;
44518                     return result;
44519                 }
44520                 else {
44521                     return !(flags & 1);
44522                 }
44523             }
44524         }
44525         function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) {
44526             if (initialType === void 0) { initialType = declaredType; }
44527             var key;
44528             var keySet = false;
44529             var flowDepth = 0;
44530             if (flowAnalysisDisabled) {
44531                 return errorType;
44532             }
44533             if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943)) {
44534                 return declaredType;
44535             }
44536             flowInvocationCount++;
44537             var sharedFlowStart = sharedFlowCount;
44538             var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode));
44539             sharedFlowCount = sharedFlowStart;
44540             var resultType = ts.getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType);
44541             if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 218 && getTypeWithFacts(resultType, 2097152).flags & 131072) {
44542                 return declaredType;
44543             }
44544             return resultType;
44545             function getOrSetCacheKey() {
44546                 if (keySet) {
44547                     return key;
44548                 }
44549                 keySet = true;
44550                 return key = getFlowCacheKey(reference, declaredType, initialType, flowContainer);
44551             }
44552             function getTypeAtFlowNode(flow) {
44553                 if (flowDepth === 2000) {
44554                     flowAnalysisDisabled = true;
44555                     reportFlowControlError(reference);
44556                     return errorType;
44557                 }
44558                 flowDepth++;
44559                 while (true) {
44560                     var flags = flow.flags;
44561                     if (flags & 4096) {
44562                         for (var i = sharedFlowStart; i < sharedFlowCount; i++) {
44563                             if (sharedFlowNodes[i] === flow) {
44564                                 flowDepth--;
44565                                 return sharedFlowTypes[i];
44566                             }
44567                         }
44568                     }
44569                     var type = void 0;
44570                     if (flags & 16) {
44571                         type = getTypeAtFlowAssignment(flow);
44572                         if (!type) {
44573                             flow = flow.antecedent;
44574                             continue;
44575                         }
44576                     }
44577                     else if (flags & 512) {
44578                         type = getTypeAtFlowCall(flow);
44579                         if (!type) {
44580                             flow = flow.antecedent;
44581                             continue;
44582                         }
44583                     }
44584                     else if (flags & 96) {
44585                         type = getTypeAtFlowCondition(flow);
44586                     }
44587                     else if (flags & 128) {
44588                         type = getTypeAtSwitchClause(flow);
44589                     }
44590                     else if (flags & 12) {
44591                         if (flow.antecedents.length === 1) {
44592                             flow = flow.antecedents[0];
44593                             continue;
44594                         }
44595                         type = flags & 4 ?
44596                             getTypeAtFlowBranchLabel(flow) :
44597                             getTypeAtFlowLoopLabel(flow);
44598                     }
44599                     else if (flags & 256) {
44600                         type = getTypeAtFlowArrayMutation(flow);
44601                         if (!type) {
44602                             flow = flow.antecedent;
44603                             continue;
44604                         }
44605                     }
44606                     else if (flags & 1024) {
44607                         var target = flow.target;
44608                         var saveAntecedents = target.antecedents;
44609                         target.antecedents = flow.antecedents;
44610                         type = getTypeAtFlowNode(flow.antecedent);
44611                         target.antecedents = saveAntecedents;
44612                     }
44613                     else if (flags & 2) {
44614                         var container = flow.node;
44615                         if (container && container !== flowContainer &&
44616                             reference.kind !== 194 &&
44617                             reference.kind !== 195 &&
44618                             reference.kind !== 104) {
44619                             flow = container.flowNode;
44620                             continue;
44621                         }
44622                         type = initialType;
44623                     }
44624                     else {
44625                         type = convertAutoToAny(declaredType);
44626                     }
44627                     if (flags & 4096) {
44628                         sharedFlowNodes[sharedFlowCount] = flow;
44629                         sharedFlowTypes[sharedFlowCount] = type;
44630                         sharedFlowCount++;
44631                     }
44632                     flowDepth--;
44633                     return type;
44634                 }
44635             }
44636             function getInitialOrAssignedType(flow) {
44637                 var node = flow.node;
44638                 return getConstraintForLocation(node.kind === 242 || node.kind === 191 ?
44639                     getInitialType(node) :
44640                     getAssignedType(node), reference);
44641             }
44642             function getTypeAtFlowAssignment(flow) {
44643                 var node = flow.node;
44644                 if (isMatchingReference(reference, node)) {
44645                     if (!isReachableFlowNode(flow)) {
44646                         return unreachableNeverType;
44647                     }
44648                     if (ts.getAssignmentTargetKind(node) === 2) {
44649                         var flowType = getTypeAtFlowNode(flow.antecedent);
44650                         return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType));
44651                     }
44652                     if (declaredType === autoType || declaredType === autoArrayType) {
44653                         if (isEmptyArrayAssignment(node)) {
44654                             return getEvolvingArrayType(neverType);
44655                         }
44656                         var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(flow));
44657                         return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType;
44658                     }
44659                     if (declaredType.flags & 1048576) {
44660                         return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow));
44661                     }
44662                     return declaredType;
44663                 }
44664                 if (containsMatchingReference(reference, node)) {
44665                     if (!isReachableFlowNode(flow)) {
44666                         return unreachableNeverType;
44667                     }
44668                     if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) {
44669                         var init = ts.getDeclaredExpandoInitializer(node);
44670                         if (init && (init.kind === 201 || init.kind === 202)) {
44671                             return getTypeAtFlowNode(flow.antecedent);
44672                         }
44673                     }
44674                     return declaredType;
44675                 }
44676                 if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 231 && isMatchingReference(reference, node.parent.parent.expression)) {
44677                     return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent)));
44678                 }
44679                 return undefined;
44680             }
44681             function narrowTypeByAssertion(type, expr) {
44682                 var node = ts.skipParentheses(expr);
44683                 if (node.kind === 91) {
44684                     return unreachableNeverType;
44685                 }
44686                 if (node.kind === 209) {
44687                     if (node.operatorToken.kind === 55) {
44688                         return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right);
44689                     }
44690                     if (node.operatorToken.kind === 56) {
44691                         return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]);
44692                     }
44693                 }
44694                 return narrowType(type, node, true);
44695             }
44696             function getTypeAtFlowCall(flow) {
44697                 var signature = getEffectsSignature(flow.node);
44698                 if (signature) {
44699                     var predicate = getTypePredicateOfSignature(signature);
44700                     if (predicate && (predicate.kind === 2 || predicate.kind === 3)) {
44701                         var flowType = getTypeAtFlowNode(flow.antecedent);
44702                         var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType));
44703                         var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, true) :
44704                             predicate.kind === 3 && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) :
44705                                 type;
44706                         return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType));
44707                     }
44708                     if (getReturnTypeOfSignature(signature).flags & 131072) {
44709                         return unreachableNeverType;
44710                     }
44711                 }
44712                 return undefined;
44713             }
44714             function getTypeAtFlowArrayMutation(flow) {
44715                 if (declaredType === autoType || declaredType === autoArrayType) {
44716                     var node = flow.node;
44717                     var expr = node.kind === 196 ?
44718                         node.expression.expression :
44719                         node.left.expression;
44720                     if (isMatchingReference(reference, getReferenceCandidate(expr))) {
44721                         var flowType = getTypeAtFlowNode(flow.antecedent);
44722                         var type = getTypeFromFlowType(flowType);
44723                         if (ts.getObjectFlags(type) & 256) {
44724                             var evolvedType_1 = type;
44725                             if (node.kind === 196) {
44726                                 for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) {
44727                                     var arg = _a[_i];
44728                                     evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg);
44729                                 }
44730                             }
44731                             else {
44732                                 var indexType = getContextFreeTypeOfExpression(node.left.argumentExpression);
44733                                 if (isTypeAssignableToKind(indexType, 296)) {
44734                                     evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right);
44735                                 }
44736                             }
44737                             return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType));
44738                         }
44739                         return flowType;
44740                     }
44741                 }
44742                 return undefined;
44743             }
44744             function getTypeAtFlowCondition(flow) {
44745                 var flowType = getTypeAtFlowNode(flow.antecedent);
44746                 var type = getTypeFromFlowType(flowType);
44747                 if (type.flags & 131072) {
44748                     return flowType;
44749                 }
44750                 var assumeTrue = (flow.flags & 32) !== 0;
44751                 var nonEvolvingType = finalizeEvolvingArrayType(type);
44752                 var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue);
44753                 if (narrowedType === nonEvolvingType) {
44754                     return flowType;
44755                 }
44756                 var incomplete = isIncomplete(flowType);
44757                 var resultType = incomplete && narrowedType.flags & 131072 ? silentNeverType : narrowedType;
44758                 return createFlowType(resultType, incomplete);
44759             }
44760             function getTypeAtSwitchClause(flow) {
44761                 var expr = flow.switchStatement.expression;
44762                 var flowType = getTypeAtFlowNode(flow.antecedent);
44763                 var type = getTypeFromFlowType(flowType);
44764                 if (isMatchingReference(reference, expr)) {
44765                     type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
44766                 }
44767                 else if (expr.kind === 204 && isMatchingReference(reference, expr.expression)) {
44768                     type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
44769                 }
44770                 else {
44771                     if (strictNullChecks) {
44772                         if (optionalChainContainsReference(expr, reference)) {
44773                             type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 | 131072)); });
44774                         }
44775                         else if (expr.kind === 204 && optionalChainContainsReference(expr.expression, reference)) {
44776                             type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 || t.flags & 128 && t.value === "undefined"); });
44777                         }
44778                     }
44779                     if (isMatchingReferenceDiscriminant(expr, type)) {
44780                         type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); });
44781                     }
44782                 }
44783                 return createFlowType(type, isIncomplete(flowType));
44784             }
44785             function getTypeAtFlowBranchLabel(flow) {
44786                 var antecedentTypes = [];
44787                 var subtypeReduction = false;
44788                 var seenIncomplete = false;
44789                 var bypassFlow;
44790                 for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) {
44791                     var antecedent = _a[_i];
44792                     if (!bypassFlow && antecedent.flags & 128 && antecedent.clauseStart === antecedent.clauseEnd) {
44793                         bypassFlow = antecedent;
44794                         continue;
44795                     }
44796                     var flowType = getTypeAtFlowNode(antecedent);
44797                     var type = getTypeFromFlowType(flowType);
44798                     if (type === declaredType && declaredType === initialType) {
44799                         return type;
44800                     }
44801                     ts.pushIfUnique(antecedentTypes, type);
44802                     if (!isTypeSubsetOf(type, declaredType)) {
44803                         subtypeReduction = true;
44804                     }
44805                     if (isIncomplete(flowType)) {
44806                         seenIncomplete = true;
44807                     }
44808                 }
44809                 if (bypassFlow) {
44810                     var flowType = getTypeAtFlowNode(bypassFlow);
44811                     var type = getTypeFromFlowType(flowType);
44812                     if (!ts.contains(antecedentTypes, type) && !isExhaustiveSwitchStatement(bypassFlow.switchStatement)) {
44813                         if (type === declaredType && declaredType === initialType) {
44814                             return type;
44815                         }
44816                         antecedentTypes.push(type);
44817                         if (!isTypeSubsetOf(type, declaredType)) {
44818                             subtypeReduction = true;
44819                         }
44820                         if (isIncomplete(flowType)) {
44821                             seenIncomplete = true;
44822                         }
44823                     }
44824                 }
44825                 return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 : 1), seenIncomplete);
44826             }
44827             function getTypeAtFlowLoopLabel(flow) {
44828                 var id = getFlowNodeId(flow);
44829                 var cache = flowLoopCaches[id] || (flowLoopCaches[id] = ts.createMap());
44830                 var key = getOrSetCacheKey();
44831                 if (!key) {
44832                     return declaredType;
44833                 }
44834                 var cached = cache.get(key);
44835                 if (cached) {
44836                     return cached;
44837                 }
44838                 for (var i = flowLoopStart; i < flowLoopCount; i++) {
44839                     if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) {
44840                         return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1), true);
44841                     }
44842                 }
44843                 var antecedentTypes = [];
44844                 var subtypeReduction = false;
44845                 var firstAntecedentType;
44846                 for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) {
44847                     var antecedent = _a[_i];
44848                     var flowType = void 0;
44849                     if (!firstAntecedentType) {
44850                         flowType = firstAntecedentType = getTypeAtFlowNode(antecedent);
44851                     }
44852                     else {
44853                         flowLoopNodes[flowLoopCount] = flow;
44854                         flowLoopKeys[flowLoopCount] = key;
44855                         flowLoopTypes[flowLoopCount] = antecedentTypes;
44856                         flowLoopCount++;
44857                         var saveFlowTypeCache = flowTypeCache;
44858                         flowTypeCache = undefined;
44859                         flowType = getTypeAtFlowNode(antecedent);
44860                         flowTypeCache = saveFlowTypeCache;
44861                         flowLoopCount--;
44862                         var cached_1 = cache.get(key);
44863                         if (cached_1) {
44864                             return cached_1;
44865                         }
44866                     }
44867                     var type = getTypeFromFlowType(flowType);
44868                     ts.pushIfUnique(antecedentTypes, type);
44869                     if (!isTypeSubsetOf(type, declaredType)) {
44870                         subtypeReduction = true;
44871                     }
44872                     if (type === declaredType) {
44873                         break;
44874                     }
44875                 }
44876                 var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 : 1);
44877                 if (isIncomplete(firstAntecedentType)) {
44878                     return createFlowType(result, true);
44879                 }
44880                 cache.set(key, result);
44881                 return result;
44882             }
44883             function isMatchingReferenceDiscriminant(expr, computedType) {
44884                 if (!(computedType.flags & 1048576) || !ts.isAccessExpression(expr)) {
44885                     return false;
44886                 }
44887                 var name = getAccessedPropertyName(expr);
44888                 if (name === undefined) {
44889                     return false;
44890                 }
44891                 return isMatchingReference(reference, expr.expression) && isDiscriminantProperty(computedType, name);
44892             }
44893             function narrowTypeByDiscriminant(type, access, narrowType) {
44894                 var propName = getAccessedPropertyName(access);
44895                 if (propName === undefined) {
44896                     return type;
44897                 }
44898                 var propType = getTypeOfPropertyOfType(type, propName);
44899                 if (!propType) {
44900                     return type;
44901                 }
44902                 var narrowedPropType = narrowType(propType);
44903                 return filterType(type, function (t) {
44904                     var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName);
44905                     return !(discriminantType.flags & 131072) && isTypeComparableTo(discriminantType, narrowedPropType);
44906                 });
44907             }
44908             function narrowTypeByTruthiness(type, expr, assumeTrue) {
44909                 if (isMatchingReference(reference, expr)) {
44910                     return getTypeWithFacts(type, assumeTrue ? 4194304 : 8388608);
44911                 }
44912                 if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) {
44913                     type = getTypeWithFacts(type, 2097152);
44914                 }
44915                 if (isMatchingReferenceDiscriminant(expr, declaredType)) {
44916                     return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 : 8388608); });
44917                 }
44918                 return type;
44919             }
44920             function isTypePresencePossible(type, propName, assumeTrue) {
44921                 if (getIndexInfoOfType(type, 0)) {
44922                     return true;
44923                 }
44924                 var prop = getPropertyOfType(type, propName);
44925                 if (prop) {
44926                     return prop.flags & 16777216 ? true : assumeTrue;
44927                 }
44928                 return !assumeTrue;
44929             }
44930             function narrowByInKeyword(type, literal, assumeTrue) {
44931                 if (type.flags & (1048576 | 524288) || isThisTypeParameter(type)) {
44932                     var propName_1 = ts.escapeLeadingUnderscores(literal.text);
44933                     return filterType(type, function (t) { return isTypePresencePossible(t, propName_1, assumeTrue); });
44934                 }
44935                 return type;
44936             }
44937             function narrowTypeByBinaryExpression(type, expr, assumeTrue) {
44938                 switch (expr.operatorToken.kind) {
44939                     case 62:
44940                         return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue);
44941                     case 34:
44942                     case 35:
44943                     case 36:
44944                     case 37:
44945                         var operator_1 = expr.operatorToken.kind;
44946                         var left_1 = getReferenceCandidate(expr.left);
44947                         var right_1 = getReferenceCandidate(expr.right);
44948                         if (left_1.kind === 204 && ts.isStringLiteralLike(right_1)) {
44949                             return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue);
44950                         }
44951                         if (right_1.kind === 204 && ts.isStringLiteralLike(left_1)) {
44952                             return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue);
44953                         }
44954                         if (isMatchingReference(reference, left_1)) {
44955                             return narrowTypeByEquality(type, operator_1, right_1, assumeTrue);
44956                         }
44957                         if (isMatchingReference(reference, right_1)) {
44958                             return narrowTypeByEquality(type, operator_1, left_1, assumeTrue);
44959                         }
44960                         if (strictNullChecks) {
44961                             if (optionalChainContainsReference(left_1, reference)) {
44962                                 type = narrowTypeByOptionalChainContainment(type, operator_1, right_1, assumeTrue);
44963                             }
44964                             else if (optionalChainContainsReference(right_1, reference)) {
44965                                 type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue);
44966                             }
44967                         }
44968                         if (isMatchingReferenceDiscriminant(left_1, declaredType)) {
44969                             return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); });
44970                         }
44971                         if (isMatchingReferenceDiscriminant(right_1, declaredType)) {
44972                             return narrowTypeByDiscriminant(type, right_1, function (t) { return narrowTypeByEquality(t, operator_1, left_1, assumeTrue); });
44973                         }
44974                         if (isMatchingConstructorReference(left_1)) {
44975                             return narrowTypeByConstructor(type, operator_1, right_1, assumeTrue);
44976                         }
44977                         if (isMatchingConstructorReference(right_1)) {
44978                             return narrowTypeByConstructor(type, operator_1, left_1, assumeTrue);
44979                         }
44980                         break;
44981                     case 98:
44982                         return narrowTypeByInstanceof(type, expr, assumeTrue);
44983                     case 97:
44984                         var target = getReferenceCandidate(expr.right);
44985                         if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) {
44986                             return narrowByInKeyword(type, expr.left, assumeTrue);
44987                         }
44988                         break;
44989                     case 27:
44990                         return narrowType(type, expr.right, assumeTrue);
44991                 }
44992                 return type;
44993             }
44994             function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) {
44995                 var equalsOperator = operator === 34 || operator === 36;
44996                 var nullableFlags = operator === 34 || operator === 35 ? 98304 : 32768;
44997                 var valueType = getTypeOfExpression(value);
44998                 var removeNullable = equalsOperator !== assumeTrue && everyType(valueType, function (t) { return !!(t.flags & nullableFlags); }) ||
44999                     equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 | nullableFlags)); });
45000                 return removeNullable ? getTypeWithFacts(type, 2097152) : type;
45001             }
45002             function narrowTypeByEquality(type, operator, value, assumeTrue) {
45003                 if (type.flags & 1) {
45004                     return type;
45005                 }
45006                 if (operator === 35 || operator === 37) {
45007                     assumeTrue = !assumeTrue;
45008                 }
45009                 var valueType = getTypeOfExpression(value);
45010                 if ((type.flags & 2) && assumeTrue && (operator === 36 || operator === 37)) {
45011                     if (valueType.flags & (131068 | 67108864)) {
45012                         return valueType;
45013                     }
45014                     if (valueType.flags & 524288) {
45015                         return nonPrimitiveType;
45016                     }
45017                     return type;
45018                 }
45019                 if (valueType.flags & 98304) {
45020                     if (!strictNullChecks) {
45021                         return type;
45022                     }
45023                     var doubleEquals = operator === 34 || operator === 35;
45024                     var facts = doubleEquals ?
45025                         assumeTrue ? 262144 : 2097152 :
45026                         valueType.flags & 65536 ?
45027                             assumeTrue ? 131072 : 1048576 :
45028                             assumeTrue ? 65536 : 524288;
45029                     return getTypeWithFacts(type, facts);
45030                 }
45031                 if (type.flags & 67637251) {
45032                     return type;
45033                 }
45034                 if (assumeTrue) {
45035                     var filterFn = operator === 34 ?
45036                         (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) :
45037                         function (t) { return areTypesComparable(t, valueType); };
45038                     var narrowedType = filterType(type, filterFn);
45039                     return narrowedType.flags & 131072 ? type : replacePrimitivesWithLiterals(narrowedType, valueType);
45040                 }
45041                 if (isUnitType(valueType)) {
45042                     var regularType_1 = getRegularTypeOfLiteralType(valueType);
45043                     return filterType(type, function (t) { return isUnitType(t) ? !areTypesComparable(t, valueType) : getRegularTypeOfLiteralType(t) !== regularType_1; });
45044                 }
45045                 return type;
45046             }
45047             function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) {
45048                 if (operator === 35 || operator === 37) {
45049                     assumeTrue = !assumeTrue;
45050                 }
45051                 var target = getReferenceCandidate(typeOfExpr.expression);
45052                 if (!isMatchingReference(reference, target)) {
45053                     if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) {
45054                         return getTypeWithFacts(type, 2097152);
45055                     }
45056                     return type;
45057                 }
45058                 if (type.flags & 1 && literal.text === "function") {
45059                     return type;
45060                 }
45061                 if (assumeTrue && type.flags & 2 && literal.text === "object") {
45062                     if (typeOfExpr.parent.parent.kind === 209) {
45063                         var expr = typeOfExpr.parent.parent;
45064                         if (expr.operatorToken.kind === 55 && expr.right === typeOfExpr.parent && containsTruthyCheck(reference, expr.left)) {
45065                             return nonPrimitiveType;
45066                         }
45067                     }
45068                     return getUnionType([nonPrimitiveType, nullType]);
45069                 }
45070                 var facts = assumeTrue ?
45071                     typeofEQFacts.get(literal.text) || 128 :
45072                     typeofNEFacts.get(literal.text) || 32768;
45073                 return getTypeWithFacts(assumeTrue ? mapType(type, narrowTypeForTypeof) : type, facts);
45074                 function narrowTypeForTypeof(type) {
45075                     var targetType = literal.text === "function" ? globalFunctionType : typeofTypesByName.get(literal.text);
45076                     if (targetType) {
45077                         if (isTypeSubtypeOf(type, targetType)) {
45078                             return type;
45079                         }
45080                         if (isTypeSubtypeOf(targetType, type)) {
45081                             return targetType;
45082                         }
45083                         if (type.flags & 63176704) {
45084                             var constraint = getBaseConstraintOfType(type) || anyType;
45085                             if (isTypeSubtypeOf(targetType, constraint)) {
45086                                 return getIntersectionType([type, targetType]);
45087                             }
45088                         }
45089                     }
45090                     return type;
45091                 }
45092             }
45093             function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
45094                 var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
45095                 return everyClauseChecks ? getTypeWithFacts(type, 2097152) : type;
45096             }
45097             function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) {
45098                 var switchTypes = getSwitchClauseTypes(switchStatement);
45099                 if (!switchTypes.length) {
45100                     return type;
45101                 }
45102                 var clauseTypes = switchTypes.slice(clauseStart, clauseEnd);
45103                 var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType);
45104                 if ((type.flags & 2) && !hasDefaultClause) {
45105                     var groundClauseTypes = void 0;
45106                     for (var i = 0; i < clauseTypes.length; i += 1) {
45107                         var t = clauseTypes[i];
45108                         if (t.flags & (131068 | 67108864)) {
45109                             if (groundClauseTypes !== undefined) {
45110                                 groundClauseTypes.push(t);
45111                             }
45112                         }
45113                         else if (t.flags & 524288) {
45114                             if (groundClauseTypes === undefined) {
45115                                 groundClauseTypes = clauseTypes.slice(0, i);
45116                             }
45117                             groundClauseTypes.push(nonPrimitiveType);
45118                         }
45119                         else {
45120                             return type;
45121                         }
45122                     }
45123                     return getUnionType(groundClauseTypes === undefined ? clauseTypes : groundClauseTypes);
45124                 }
45125                 var discriminantType = getUnionType(clauseTypes);
45126                 var caseType = discriminantType.flags & 131072 ? neverType :
45127                     replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType);
45128                 if (!hasDefaultClause) {
45129                     return caseType;
45130                 }
45131                 var defaultType = filterType(type, function (t) { return !(isUnitType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(t))); });
45132                 return caseType.flags & 131072 ? defaultType : getUnionType([caseType, defaultType]);
45133             }
45134             function getImpliedTypeFromTypeofCase(type, text) {
45135                 switch (text) {
45136                     case "function":
45137                         return type.flags & 1 ? type : globalFunctionType;
45138                     case "object":
45139                         return type.flags & 2 ? getUnionType([nonPrimitiveType, nullType]) : type;
45140                     default:
45141                         return typeofTypesByName.get(text) || type;
45142                 }
45143             }
45144             function narrowTypeForTypeofSwitch(candidate) {
45145                 return function (type) {
45146                     if (isTypeSubtypeOf(candidate, type)) {
45147                         return candidate;
45148                     }
45149                     if (type.flags & 63176704) {
45150                         var constraint = getBaseConstraintOfType(type) || anyType;
45151                         if (isTypeSubtypeOf(candidate, constraint)) {
45152                             return getIntersectionType([type, candidate]);
45153                         }
45154                     }
45155                     return type;
45156                 };
45157             }
45158             function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
45159                 var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, true);
45160                 if (!switchWitnesses.length) {
45161                     return type;
45162                 }
45163                 var defaultCaseLocation = ts.findIndex(switchWitnesses, function (elem) { return elem === undefined; });
45164                 var hasDefaultClause = clauseStart === clauseEnd || (defaultCaseLocation >= clauseStart && defaultCaseLocation < clauseEnd);
45165                 var clauseWitnesses;
45166                 var switchFacts;
45167                 if (defaultCaseLocation > -1) {
45168                     var witnesses = switchWitnesses.filter(function (witness) { return witness !== undefined; });
45169                     var fixedClauseStart = defaultCaseLocation < clauseStart ? clauseStart - 1 : clauseStart;
45170                     var fixedClauseEnd = defaultCaseLocation < clauseEnd ? clauseEnd - 1 : clauseEnd;
45171                     clauseWitnesses = witnesses.slice(fixedClauseStart, fixedClauseEnd);
45172                     switchFacts = getFactsFromTypeofSwitch(fixedClauseStart, fixedClauseEnd, witnesses, hasDefaultClause);
45173                 }
45174                 else {
45175                     clauseWitnesses = switchWitnesses.slice(clauseStart, clauseEnd);
45176                     switchFacts = getFactsFromTypeofSwitch(clauseStart, clauseEnd, switchWitnesses, hasDefaultClause);
45177                 }
45178                 if (hasDefaultClause) {
45179                     return filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; });
45180                 }
45181                 var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofCase(type, text); })), switchFacts);
45182                 if (impliedType.flags & 1048576) {
45183                     impliedType = getAssignmentReducedType(impliedType, getBaseConstraintOrType(type));
45184                 }
45185                 return getTypeWithFacts(mapType(type, narrowTypeForTypeofSwitch(impliedType)), switchFacts);
45186             }
45187             function isMatchingConstructorReference(expr) {
45188                 return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
45189                     ts.isElementAccessExpression(expr) && ts.isStringLiteralLike(expr.argumentExpression) && expr.argumentExpression.text === "constructor") &&
45190                     isMatchingReference(reference, expr.expression);
45191             }
45192             function narrowTypeByConstructor(type, operator, identifier, assumeTrue) {
45193                 if (assumeTrue ? (operator !== 34 && operator !== 36) : (operator !== 35 && operator !== 37)) {
45194                     return type;
45195                 }
45196                 var identifierType = getTypeOfExpression(identifier);
45197                 if (!isFunctionType(identifierType) && !isConstructorType(identifierType)) {
45198                     return type;
45199                 }
45200                 var prototypeProperty = getPropertyOfType(identifierType, "prototype");
45201                 if (!prototypeProperty) {
45202                     return type;
45203                 }
45204                 var prototypeType = getTypeOfSymbol(prototypeProperty);
45205                 var candidate = !isTypeAny(prototypeType) ? prototypeType : undefined;
45206                 if (!candidate || candidate === globalObjectType || candidate === globalFunctionType) {
45207                     return type;
45208                 }
45209                 if (isTypeAny(type)) {
45210                     return candidate;
45211                 }
45212                 return filterType(type, function (t) { return isConstructedBy(t, candidate); });
45213                 function isConstructedBy(source, target) {
45214                     if (source.flags & 524288 && ts.getObjectFlags(source) & 1 ||
45215                         target.flags & 524288 && ts.getObjectFlags(target) & 1) {
45216                         return source.symbol === target.symbol;
45217                     }
45218                     return isTypeSubtypeOf(source, target);
45219                 }
45220             }
45221             function narrowTypeByInstanceof(type, expr, assumeTrue) {
45222                 var left = getReferenceCandidate(expr.left);
45223                 if (!isMatchingReference(reference, left)) {
45224                     if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) {
45225                         return getTypeWithFacts(type, 2097152);
45226                     }
45227                     return type;
45228                 }
45229                 var rightType = getTypeOfExpression(expr.right);
45230                 if (!isTypeDerivedFrom(rightType, globalFunctionType)) {
45231                     return type;
45232                 }
45233                 var targetType;
45234                 var prototypeProperty = getPropertyOfType(rightType, "prototype");
45235                 if (prototypeProperty) {
45236                     var prototypePropertyType = getTypeOfSymbol(prototypeProperty);
45237                     if (!isTypeAny(prototypePropertyType)) {
45238                         targetType = prototypePropertyType;
45239                     }
45240                 }
45241                 if (isTypeAny(type) && (targetType === globalObjectType || targetType === globalFunctionType)) {
45242                     return type;
45243                 }
45244                 if (!targetType) {
45245                     var constructSignatures = getSignaturesOfType(rightType, 1);
45246                     targetType = constructSignatures.length ?
45247                         getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })) :
45248                         emptyObjectType;
45249                 }
45250                 return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom);
45251             }
45252             function getNarrowedType(type, candidate, assumeTrue, isRelated) {
45253                 if (!assumeTrue) {
45254                     return filterType(type, function (t) { return !isRelated(t, candidate); });
45255                 }
45256                 if (type.flags & 1048576) {
45257                     var assignableType = filterType(type, function (t) { return isRelated(t, candidate); });
45258                     if (!(assignableType.flags & 131072)) {
45259                         return assignableType;
45260                     }
45261                 }
45262                 return isTypeSubtypeOf(candidate, type) ? candidate :
45263                     isTypeAssignableTo(type, candidate) ? type :
45264                         isTypeAssignableTo(candidate, type) ? candidate :
45265                             getIntersectionType([type, candidate]);
45266             }
45267             function narrowTypeByCallExpression(type, callExpression, assumeTrue) {
45268                 if (hasMatchingArgument(callExpression, reference)) {
45269                     var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined;
45270                     var predicate = signature && getTypePredicateOfSignature(signature);
45271                     if (predicate && (predicate.kind === 0 || predicate.kind === 1)) {
45272                         return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue);
45273                     }
45274                 }
45275                 return type;
45276             }
45277             function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) {
45278                 if (predicate.type && !(isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType))) {
45279                     var predicateArgument = getTypePredicateArgument(predicate, callExpression);
45280                     if (predicateArgument) {
45281                         if (isMatchingReference(reference, predicateArgument)) {
45282                             return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf);
45283                         }
45284                         if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) &&
45285                             !(getTypeFacts(predicate.type) & 65536)) {
45286                             type = getTypeWithFacts(type, 2097152);
45287                         }
45288                         if (isMatchingReferenceDiscriminant(predicateArgument, declaredType)) {
45289                             return narrowTypeByDiscriminant(type, predicateArgument, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); });
45290                         }
45291                     }
45292                 }
45293                 return type;
45294             }
45295             function narrowType(type, expr, assumeTrue) {
45296                 if (ts.isExpressionOfOptionalChainRoot(expr) ||
45297                     ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 && expr.parent.left === expr) {
45298                     return narrowTypeByOptionality(type, expr, assumeTrue);
45299                 }
45300                 switch (expr.kind) {
45301                     case 75:
45302                     case 104:
45303                     case 102:
45304                     case 194:
45305                     case 195:
45306                         return narrowTypeByTruthiness(type, expr, assumeTrue);
45307                     case 196:
45308                         return narrowTypeByCallExpression(type, expr, assumeTrue);
45309                     case 200:
45310                         return narrowType(type, expr.expression, assumeTrue);
45311                     case 209:
45312                         return narrowTypeByBinaryExpression(type, expr, assumeTrue);
45313                     case 207:
45314                         if (expr.operator === 53) {
45315                             return narrowType(type, expr.operand, !assumeTrue);
45316                         }
45317                         break;
45318                 }
45319                 return type;
45320             }
45321             function narrowTypeByOptionality(type, expr, assumePresent) {
45322                 if (isMatchingReference(reference, expr)) {
45323                     return getTypeWithFacts(type, assumePresent ? 2097152 : 262144);
45324                 }
45325                 if (isMatchingReferenceDiscriminant(expr, declaredType)) {
45326                     return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 : 262144); });
45327                 }
45328                 return type;
45329             }
45330         }
45331         function getTypeOfSymbolAtLocation(symbol, location) {
45332             symbol = symbol.exportSymbol || symbol;
45333             if (location.kind === 75) {
45334                 if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) {
45335                     location = location.parent;
45336                 }
45337                 if (ts.isExpressionNode(location) && !ts.isAssignmentTarget(location)) {
45338                     var type = getTypeOfExpression(location);
45339                     if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) {
45340                         return type;
45341                     }
45342                 }
45343             }
45344             return getTypeOfSymbol(symbol);
45345         }
45346         function getControlFlowContainer(node) {
45347             return ts.findAncestor(node.parent, function (node) {
45348                 return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) ||
45349                     node.kind === 250 ||
45350                     node.kind === 290 ||
45351                     node.kind === 159;
45352             });
45353         }
45354         function isParameterAssigned(symbol) {
45355             var func = ts.getRootDeclaration(symbol.valueDeclaration).parent;
45356             var links = getNodeLinks(func);
45357             if (!(links.flags & 8388608)) {
45358                 links.flags |= 8388608;
45359                 if (!hasParentWithAssignmentsMarked(func)) {
45360                     markParameterAssignments(func);
45361                 }
45362             }
45363             return symbol.isAssigned || false;
45364         }
45365         function hasParentWithAssignmentsMarked(node) {
45366             return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608); });
45367         }
45368         function markParameterAssignments(node) {
45369             if (node.kind === 75) {
45370                 if (ts.isAssignmentTarget(node)) {
45371                     var symbol = getResolvedSymbol(node);
45372                     if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 156) {
45373                         symbol.isAssigned = true;
45374                     }
45375                 }
45376             }
45377             else {
45378                 ts.forEachChild(node, markParameterAssignments);
45379             }
45380         }
45381         function isConstVariable(symbol) {
45382             return symbol.flags & 3 && (getDeclarationNodeFlagsFromSymbol(symbol) & 2) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType;
45383         }
45384         function removeOptionalityFromDeclaredType(declaredType, declaration) {
45385             if (pushTypeResolution(declaration.symbol, 2)) {
45386                 var annotationIncludesUndefined = strictNullChecks &&
45387                     declaration.kind === 156 &&
45388                     declaration.initializer &&
45389                     getFalsyFlags(declaredType) & 32768 &&
45390                     !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768);
45391                 popTypeResolution();
45392                 return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288) : declaredType;
45393             }
45394             else {
45395                 reportCircularityError(declaration.symbol);
45396                 return declaredType;
45397             }
45398         }
45399         function isConstraintPosition(node) {
45400             var parent = node.parent;
45401             return parent.kind === 194 ||
45402                 parent.kind === 196 && parent.expression === node ||
45403                 parent.kind === 195 && parent.expression === node ||
45404                 parent.kind === 191 && parent.name === node && !!parent.initializer;
45405         }
45406         function typeHasNullableConstraint(type) {
45407             return type.flags & 58982400 && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304);
45408         }
45409         function getConstraintForLocation(type, node) {
45410             if (type && isConstraintPosition(node) && forEachType(type, typeHasNullableConstraint)) {
45411                 return mapType(getWidenedType(type), getBaseConstraintOrType);
45412             }
45413             return type;
45414         }
45415         function isExportOrExportExpression(location) {
45416             return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); });
45417         }
45418         function markAliasReferenced(symbol, location) {
45419             if (isNonLocalAlias(symbol, 111551) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) {
45420                 if (compilerOptions.preserveConstEnums && isExportOrExportExpression(location) || !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) {
45421                     markAliasSymbolAsReferenced(symbol);
45422                 }
45423                 else {
45424                     markConstEnumAliasAsReferenced(symbol);
45425                 }
45426             }
45427         }
45428         function checkIdentifier(node) {
45429             var symbol = getResolvedSymbol(node);
45430             if (symbol === unknownSymbol) {
45431                 return errorType;
45432             }
45433             if (symbol === argumentsSymbol) {
45434                 var container = ts.getContainingFunction(node);
45435                 if (languageVersion < 2) {
45436                     if (container.kind === 202) {
45437                         error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression);
45438                     }
45439                     else if (ts.hasModifier(container, 256)) {
45440                         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);
45441                     }
45442                 }
45443                 getNodeLinks(container).flags |= 8192;
45444                 return getTypeOfSymbol(symbol);
45445             }
45446             if (!(node.parent && ts.isPropertyAccessExpression(node.parent) && node.parent.expression === node)) {
45447                 markAliasReferenced(symbol, node);
45448             }
45449             var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
45450             var declaration = localOrExportSymbol.valueDeclaration;
45451             if (localOrExportSymbol.flags & 32) {
45452                 if (declaration.kind === 245
45453                     && ts.nodeIsDecorated(declaration)) {
45454                     var container = ts.getContainingClass(node);
45455                     while (container !== undefined) {
45456                         if (container === declaration && container.name !== node) {
45457                             getNodeLinks(declaration).flags |= 16777216;
45458                             getNodeLinks(node).flags |= 33554432;
45459                             break;
45460                         }
45461                         container = ts.getContainingClass(container);
45462                     }
45463                 }
45464                 else if (declaration.kind === 214) {
45465                     var container = ts.getThisContainer(node, false);
45466                     while (container.kind !== 290) {
45467                         if (container.parent === declaration) {
45468                             if (container.kind === 159 && ts.hasModifier(container, 32)) {
45469                                 getNodeLinks(declaration).flags |= 16777216;
45470                                 getNodeLinks(node).flags |= 33554432;
45471                             }
45472                             break;
45473                         }
45474                         container = ts.getThisContainer(container, false);
45475                     }
45476                 }
45477             }
45478             checkNestedBlockScopedBinding(node, symbol);
45479             var type = getConstraintForLocation(getTypeOfSymbol(localOrExportSymbol), node);
45480             var assignmentKind = ts.getAssignmentTargetKind(node);
45481             if (assignmentKind) {
45482                 if (!(localOrExportSymbol.flags & 3) &&
45483                     !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512)) {
45484                     error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable, symbolToString(symbol));
45485                     return errorType;
45486                 }
45487                 if (isReadonlySymbol(localOrExportSymbol)) {
45488                     if (localOrExportSymbol.flags & 3) {
45489                         error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant, symbolToString(symbol));
45490                     }
45491                     else {
45492                         error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(symbol));
45493                     }
45494                     return errorType;
45495                 }
45496             }
45497             var isAlias = localOrExportSymbol.flags & 2097152;
45498             if (localOrExportSymbol.flags & 3) {
45499                 if (assignmentKind === 1) {
45500                     return type;
45501                 }
45502             }
45503             else if (isAlias) {
45504                 declaration = ts.find(symbol.declarations, isSomeImportDeclaration);
45505             }
45506             else {
45507                 return type;
45508             }
45509             if (!declaration) {
45510                 return type;
45511             }
45512             var isParameter = ts.getRootDeclaration(declaration).kind === 156;
45513             var declarationContainer = getControlFlowContainer(declaration);
45514             var flowContainer = getControlFlowContainer(node);
45515             var isOuterVariable = flowContainer !== declarationContainer;
45516             var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent);
45517             var isModuleExports = symbol.flags & 134217728;
45518             while (flowContainer !== declarationContainer && (flowContainer.kind === 201 ||
45519                 flowContainer.kind === 202 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) &&
45520                 (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) {
45521                 flowContainer = getControlFlowContainer(flowContainer);
45522             }
45523             var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) ||
45524                 type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 | 16384)) !== 0 ||
45525                     isInTypeQuery(node) || node.parent.kind === 263) ||
45526                 node.parent.kind === 218 ||
45527                 declaration.kind === 242 && declaration.exclamationToken ||
45528                 declaration.flags & 8388608;
45529             var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) :
45530                 type === autoType || type === autoArrayType ? undefinedType :
45531                     getOptionalType(type);
45532             var flowType = getFlowTypeOfReference(node, type, initialType, flowContainer, !assumeInitialized);
45533             if (!isEvolvingArrayOperationTarget(node) && (type === autoType || type === autoArrayType)) {
45534                 if (flowType === autoType || flowType === autoArrayType) {
45535                     if (noImplicitAny) {
45536                         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));
45537                         error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType));
45538                     }
45539                     return convertAutoToAny(flowType);
45540                 }
45541             }
45542             else if (!assumeInitialized && !(getFalsyFlags(type) & 32768) && getFalsyFlags(flowType) & 32768) {
45543                 error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol));
45544                 return type;
45545             }
45546             return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
45547         }
45548         function isInsideFunction(node, threshold) {
45549             return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n); });
45550         }
45551         function getPartOfForStatementContainingNode(node, container) {
45552             return ts.findAncestor(node, function (n) { return n === container ? "quit" : n === container.initializer || n === container.condition || n === container.incrementor || n === container.statement; });
45553         }
45554         function checkNestedBlockScopedBinding(node, symbol) {
45555             if (languageVersion >= 2 ||
45556                 (symbol.flags & (2 | 32)) === 0 ||
45557                 ts.isSourceFile(symbol.valueDeclaration) ||
45558                 symbol.valueDeclaration.parent.kind === 280) {
45559                 return;
45560             }
45561             var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration);
45562             var usedInFunction = isInsideFunction(node.parent, container);
45563             var current = container;
45564             var containedInIterationStatement = false;
45565             while (current && !ts.nodeStartsNewLexicalEnvironment(current)) {
45566                 if (ts.isIterationStatement(current, false)) {
45567                     containedInIterationStatement = true;
45568                     break;
45569                 }
45570                 current = current.parent;
45571             }
45572             if (containedInIterationStatement) {
45573                 if (usedInFunction) {
45574                     var capturesBlockScopeBindingInLoopBody = true;
45575                     if (ts.isForStatement(container)) {
45576                         var varDeclList = ts.getAncestor(symbol.valueDeclaration, 243);
45577                         if (varDeclList && varDeclList.parent === container) {
45578                             var part = getPartOfForStatementContainingNode(node.parent, container);
45579                             if (part) {
45580                                 var links = getNodeLinks(part);
45581                                 links.flags |= 131072;
45582                                 var capturedBindings = links.capturedBlockScopeBindings || (links.capturedBlockScopeBindings = []);
45583                                 ts.pushIfUnique(capturedBindings, symbol);
45584                                 if (part === container.initializer) {
45585                                     capturesBlockScopeBindingInLoopBody = false;
45586                                 }
45587                             }
45588                         }
45589                     }
45590                     if (capturesBlockScopeBindingInLoopBody) {
45591                         getNodeLinks(current).flags |= 65536;
45592                     }
45593                 }
45594                 if (ts.isForStatement(container)) {
45595                     var varDeclList = ts.getAncestor(symbol.valueDeclaration, 243);
45596                     if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) {
45597                         getNodeLinks(symbol.valueDeclaration).flags |= 4194304;
45598                     }
45599                 }
45600                 getNodeLinks(symbol.valueDeclaration).flags |= 524288;
45601             }
45602             if (usedInFunction) {
45603                 getNodeLinks(symbol.valueDeclaration).flags |= 262144;
45604             }
45605         }
45606         function isBindingCapturedByNode(node, decl) {
45607             var links = getNodeLinks(node);
45608             return !!links && ts.contains(links.capturedBlockScopeBindings, getSymbolOfNode(decl));
45609         }
45610         function isAssignedInBodyOfForStatement(node, container) {
45611             var current = node;
45612             while (current.parent.kind === 200) {
45613                 current = current.parent;
45614             }
45615             var isAssigned = false;
45616             if (ts.isAssignmentTarget(current)) {
45617                 isAssigned = true;
45618             }
45619             else if ((current.parent.kind === 207 || current.parent.kind === 208)) {
45620                 var expr = current.parent;
45621                 isAssigned = expr.operator === 45 || expr.operator === 46;
45622             }
45623             if (!isAssigned) {
45624                 return false;
45625             }
45626             return !!ts.findAncestor(current, function (n) { return n === container ? "quit" : n === container.statement; });
45627         }
45628         function captureLexicalThis(node, container) {
45629             getNodeLinks(node).flags |= 2;
45630             if (container.kind === 159 || container.kind === 162) {
45631                 var classNode = container.parent;
45632                 getNodeLinks(classNode).flags |= 4;
45633             }
45634             else {
45635                 getNodeLinks(container).flags |= 4;
45636             }
45637         }
45638         function findFirstSuperCall(n) {
45639             if (ts.isSuperCall(n)) {
45640                 return n;
45641             }
45642             else if (ts.isFunctionLike(n)) {
45643                 return undefined;
45644             }
45645             return ts.forEachChild(n, findFirstSuperCall);
45646         }
45647         function getSuperCallInConstructor(constructor) {
45648             var links = getNodeLinks(constructor);
45649             if (links.hasSuperCall === undefined) {
45650                 links.superCall = findFirstSuperCall(constructor.body);
45651                 links.hasSuperCall = links.superCall ? true : false;
45652             }
45653             return links.superCall;
45654         }
45655         function classDeclarationExtendsNull(classDecl) {
45656             var classSymbol = getSymbolOfNode(classDecl);
45657             var classInstanceType = getDeclaredTypeOfSymbol(classSymbol);
45658             var baseConstructorType = getBaseConstructorTypeOfClass(classInstanceType);
45659             return baseConstructorType === nullWideningType;
45660         }
45661         function checkThisBeforeSuper(node, container, diagnosticMessage) {
45662             var containingClassDecl = container.parent;
45663             var baseTypeNode = ts.getClassExtendsHeritageElement(containingClassDecl);
45664             if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) {
45665                 var superCall = getSuperCallInConstructor(container);
45666                 if (!superCall || superCall.end > node.pos) {
45667                     error(node, diagnosticMessage);
45668                 }
45669             }
45670         }
45671         function checkThisExpression(node) {
45672             var container = ts.getThisContainer(node, true);
45673             var capturedByArrowFunction = false;
45674             if (container.kind === 162) {
45675                 checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class);
45676             }
45677             if (container.kind === 202) {
45678                 container = ts.getThisContainer(container, false);
45679                 capturedByArrowFunction = true;
45680             }
45681             switch (container.kind) {
45682                 case 249:
45683                     error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body);
45684                     break;
45685                 case 248:
45686                     error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location);
45687                     break;
45688                 case 162:
45689                     if (isInConstructorArgumentInitializer(node, container)) {
45690                         error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments);
45691                     }
45692                     break;
45693                 case 159:
45694                 case 158:
45695                     if (ts.hasModifier(container, 32) && !(compilerOptions.target === 99 && compilerOptions.useDefineForClassFields)) {
45696                         error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer);
45697                     }
45698                     break;
45699                 case 154:
45700                     error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name);
45701                     break;
45702             }
45703             if (capturedByArrowFunction && languageVersion < 2) {
45704                 captureLexicalThis(node, container);
45705             }
45706             var type = tryGetThisTypeAt(node, true, container);
45707             if (noImplicitThis) {
45708                 var globalThisType_1 = getTypeOfSymbol(globalThisSymbol);
45709                 if (type === globalThisType_1 && capturedByArrowFunction) {
45710                     error(node, ts.Diagnostics.The_containing_arrow_function_captures_the_global_value_of_this);
45711                 }
45712                 else if (!type) {
45713                     var diag = error(node, ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation);
45714                     if (!ts.isSourceFile(container)) {
45715                         var outsideThis = tryGetThisTypeAt(container);
45716                         if (outsideThis && outsideThis !== globalThisType_1) {
45717                             ts.addRelatedInfo(diag, ts.createDiagnosticForNode(container, ts.Diagnostics.An_outer_value_of_this_is_shadowed_by_this_container));
45718                         }
45719                     }
45720                 }
45721             }
45722             return type || anyType;
45723         }
45724         function tryGetThisTypeAt(node, includeGlobalThis, container) {
45725             if (includeGlobalThis === void 0) { includeGlobalThis = true; }
45726             if (container === void 0) { container = ts.getThisContainer(node, false); }
45727             var isInJS = ts.isInJSFile(node);
45728             if (ts.isFunctionLike(container) &&
45729                 (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) {
45730                 var className = getClassNameFromPrototypeMethod(container);
45731                 if (isInJS && className) {
45732                     var classSymbol = checkExpression(className).symbol;
45733                     if (classSymbol && classSymbol.members && (classSymbol.flags & 16)) {
45734                         var classType = getDeclaredTypeOfSymbol(classSymbol).thisType;
45735                         if (classType) {
45736                             return getFlowTypeOfReference(node, classType);
45737                         }
45738                     }
45739                 }
45740                 else if (isInJS &&
45741                     (container.kind === 201 || container.kind === 244) &&
45742                     ts.getJSDocClassTag(container)) {
45743                     var classType = getDeclaredTypeOfSymbol(getMergedSymbol(container.symbol)).thisType;
45744                     return getFlowTypeOfReference(node, classType);
45745                 }
45746                 var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container);
45747                 if (thisType) {
45748                     return getFlowTypeOfReference(node, thisType);
45749                 }
45750             }
45751             if (ts.isClassLike(container.parent)) {
45752                 var symbol = getSymbolOfNode(container.parent);
45753                 var type = ts.hasModifier(container, 32) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType;
45754                 return getFlowTypeOfReference(node, type);
45755             }
45756             if (isInJS) {
45757                 var type = getTypeForThisExpressionFromJSDoc(container);
45758                 if (type && type !== errorType) {
45759                     return getFlowTypeOfReference(node, type);
45760                 }
45761             }
45762             if (ts.isSourceFile(container)) {
45763                 if (container.commonJsModuleIndicator) {
45764                     var fileSymbol = getSymbolOfNode(container);
45765                     return fileSymbol && getTypeOfSymbol(fileSymbol);
45766                 }
45767                 else if (includeGlobalThis) {
45768                     return getTypeOfSymbol(globalThisSymbol);
45769                 }
45770             }
45771         }
45772         function getExplicitThisType(node) {
45773             var container = ts.getThisContainer(node, false);
45774             if (ts.isFunctionLike(container)) {
45775                 var signature = getSignatureFromDeclaration(container);
45776                 if (signature.thisParameter) {
45777                     return getExplicitTypeOfSymbol(signature.thisParameter);
45778                 }
45779             }
45780             if (ts.isClassLike(container.parent)) {
45781                 var symbol = getSymbolOfNode(container.parent);
45782                 return ts.hasModifier(container, 32) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType;
45783             }
45784         }
45785         function getClassNameFromPrototypeMethod(container) {
45786             if (container.kind === 201 &&
45787                 ts.isBinaryExpression(container.parent) &&
45788                 ts.getAssignmentDeclarationKind(container.parent) === 3) {
45789                 return container.parent
45790                     .left
45791                     .expression
45792                     .expression;
45793             }
45794             else if (container.kind === 161 &&
45795                 container.parent.kind === 193 &&
45796                 ts.isBinaryExpression(container.parent.parent) &&
45797                 ts.getAssignmentDeclarationKind(container.parent.parent) === 6) {
45798                 return container.parent.parent.left.expression;
45799             }
45800             else if (container.kind === 201 &&
45801                 container.parent.kind === 281 &&
45802                 container.parent.parent.kind === 193 &&
45803                 ts.isBinaryExpression(container.parent.parent.parent) &&
45804                 ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6) {
45805                 return container.parent.parent.parent.left.expression;
45806             }
45807             else if (container.kind === 201 &&
45808                 ts.isPropertyAssignment(container.parent) &&
45809                 ts.isIdentifier(container.parent.name) &&
45810                 (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") &&
45811                 ts.isObjectLiteralExpression(container.parent.parent) &&
45812                 ts.isCallExpression(container.parent.parent.parent) &&
45813                 container.parent.parent.parent.arguments[2] === container.parent.parent &&
45814                 ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9) {
45815                 return container.parent.parent.parent.arguments[0].expression;
45816             }
45817             else if (ts.isMethodDeclaration(container) &&
45818                 ts.isIdentifier(container.name) &&
45819                 (container.name.escapedText === "value" || container.name.escapedText === "get" || container.name.escapedText === "set") &&
45820                 ts.isObjectLiteralExpression(container.parent) &&
45821                 ts.isCallExpression(container.parent.parent) &&
45822                 container.parent.parent.arguments[2] === container.parent &&
45823                 ts.getAssignmentDeclarationKind(container.parent.parent) === 9) {
45824                 return container.parent.parent.arguments[0].expression;
45825             }
45826         }
45827         function getTypeForThisExpressionFromJSDoc(node) {
45828             var jsdocType = ts.getJSDocType(node);
45829             if (jsdocType && jsdocType.kind === 300) {
45830                 var jsDocFunctionType = jsdocType;
45831                 if (jsDocFunctionType.parameters.length > 0 &&
45832                     jsDocFunctionType.parameters[0].name &&
45833                     jsDocFunctionType.parameters[0].name.escapedText === "this") {
45834                     return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type);
45835                 }
45836             }
45837             var thisTag = ts.getJSDocThisTag(node);
45838             if (thisTag && thisTag.typeExpression) {
45839                 return getTypeFromTypeNode(thisTag.typeExpression);
45840             }
45841         }
45842         function isInConstructorArgumentInitializer(node, constructorDecl) {
45843             return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 156 && n.parent === constructorDecl; });
45844         }
45845         function checkSuperExpression(node) {
45846             var isCallExpression = node.parent.kind === 196 && node.parent.expression === node;
45847             var container = ts.getSuperContainer(node, true);
45848             var needToCaptureLexicalThis = false;
45849             if (!isCallExpression) {
45850                 while (container && container.kind === 202) {
45851                     container = ts.getSuperContainer(container, true);
45852                     needToCaptureLexicalThis = languageVersion < 2;
45853                 }
45854             }
45855             var canUseSuperExpression = isLegalUsageOfSuperExpression(container);
45856             var nodeCheckFlag = 0;
45857             if (!canUseSuperExpression) {
45858                 var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 154; });
45859                 if (current && current.kind === 154) {
45860                     error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name);
45861                 }
45862                 else if (isCallExpression) {
45863                     error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors);
45864                 }
45865                 else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 193)) {
45866                     error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions);
45867                 }
45868                 else {
45869                     error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class);
45870                 }
45871                 return errorType;
45872             }
45873             if (!isCallExpression && container.kind === 162) {
45874                 checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class);
45875             }
45876             if (ts.hasModifier(container, 32) || isCallExpression) {
45877                 nodeCheckFlag = 512;
45878             }
45879             else {
45880                 nodeCheckFlag = 256;
45881             }
45882             getNodeLinks(node).flags |= nodeCheckFlag;
45883             if (container.kind === 161 && ts.hasModifier(container, 256)) {
45884                 if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) {
45885                     getNodeLinks(container).flags |= 4096;
45886                 }
45887                 else {
45888                     getNodeLinks(container).flags |= 2048;
45889                 }
45890             }
45891             if (needToCaptureLexicalThis) {
45892                 captureLexicalThis(node.parent, container);
45893             }
45894             if (container.parent.kind === 193) {
45895                 if (languageVersion < 2) {
45896                     error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher);
45897                     return errorType;
45898                 }
45899                 else {
45900                     return anyType;
45901                 }
45902             }
45903             var classLikeDeclaration = container.parent;
45904             if (!ts.getClassExtendsHeritageElement(classLikeDeclaration)) {
45905                 error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class);
45906                 return errorType;
45907             }
45908             var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classLikeDeclaration));
45909             var baseClassType = classType && getBaseTypes(classType)[0];
45910             if (!baseClassType) {
45911                 return errorType;
45912             }
45913             if (container.kind === 162 && isInConstructorArgumentInitializer(node, container)) {
45914                 error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments);
45915                 return errorType;
45916             }
45917             return nodeCheckFlag === 512
45918                 ? getBaseConstructorTypeOfClass(classType)
45919                 : getTypeWithThisArgument(baseClassType, classType.thisType);
45920             function isLegalUsageOfSuperExpression(container) {
45921                 if (!container) {
45922                     return false;
45923                 }
45924                 if (isCallExpression) {
45925                     return container.kind === 162;
45926                 }
45927                 else {
45928                     if (ts.isClassLike(container.parent) || container.parent.kind === 193) {
45929                         if (ts.hasModifier(container, 32)) {
45930                             return container.kind === 161 ||
45931                                 container.kind === 160 ||
45932                                 container.kind === 163 ||
45933                                 container.kind === 164;
45934                         }
45935                         else {
45936                             return container.kind === 161 ||
45937                                 container.kind === 160 ||
45938                                 container.kind === 163 ||
45939                                 container.kind === 164 ||
45940                                 container.kind === 159 ||
45941                                 container.kind === 158 ||
45942                                 container.kind === 162;
45943                         }
45944                     }
45945                 }
45946                 return false;
45947             }
45948         }
45949         function getContainingObjectLiteral(func) {
45950             return (func.kind === 161 ||
45951                 func.kind === 163 ||
45952                 func.kind === 164) && func.parent.kind === 193 ? func.parent :
45953                 func.kind === 201 && func.parent.kind === 281 ? func.parent.parent :
45954                     undefined;
45955         }
45956         function getThisTypeArgument(type) {
45957             return ts.getObjectFlags(type) & 4 && type.target === globalThisType ? getTypeArguments(type)[0] : undefined;
45958         }
45959         function getThisTypeFromContextualType(type) {
45960             return mapType(type, function (t) {
45961                 return t.flags & 2097152 ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t);
45962             });
45963         }
45964         function getContextualThisParameterType(func) {
45965             if (func.kind === 202) {
45966                 return undefined;
45967             }
45968             if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
45969                 var contextualSignature = getContextualSignature(func);
45970                 if (contextualSignature) {
45971                     var thisParameter = contextualSignature.thisParameter;
45972                     if (thisParameter) {
45973                         return getTypeOfSymbol(thisParameter);
45974                     }
45975                 }
45976             }
45977             var inJs = ts.isInJSFile(func);
45978             if (noImplicitThis || inJs) {
45979                 var containingLiteral = getContainingObjectLiteral(func);
45980                 if (containingLiteral) {
45981                     var contextualType = getApparentTypeOfContextualType(containingLiteral);
45982                     var literal = containingLiteral;
45983                     var type = contextualType;
45984                     while (type) {
45985                         var thisType = getThisTypeFromContextualType(type);
45986                         if (thisType) {
45987                             return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral)));
45988                         }
45989                         if (literal.parent.kind !== 281) {
45990                             break;
45991                         }
45992                         literal = literal.parent.parent;
45993                         type = getApparentTypeOfContextualType(literal);
45994                     }
45995                     return getWidenedType(contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral));
45996                 }
45997                 var parent = ts.walkUpParenthesizedExpressions(func.parent);
45998                 if (parent.kind === 209 && parent.operatorToken.kind === 62) {
45999                     var target = parent.left;
46000                     if (ts.isAccessExpression(target)) {
46001                         var expression = target.expression;
46002                         if (inJs && ts.isIdentifier(expression)) {
46003                             var sourceFile = ts.getSourceFileOfNode(parent);
46004                             if (sourceFile.commonJsModuleIndicator && getResolvedSymbol(expression) === sourceFile.symbol) {
46005                                 return undefined;
46006                             }
46007                         }
46008                         return getWidenedType(checkExpressionCached(expression));
46009                     }
46010                 }
46011             }
46012             return undefined;
46013         }
46014         function getContextuallyTypedParameterType(parameter) {
46015             var func = parameter.parent;
46016             if (!isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
46017                 return undefined;
46018             }
46019             var iife = ts.getImmediatelyInvokedFunctionExpression(func);
46020             if (iife && iife.arguments) {
46021                 var args = getEffectiveCallArguments(iife);
46022                 var indexOfParameter = func.parameters.indexOf(parameter);
46023                 if (parameter.dotDotDotToken) {
46024                     return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, undefined);
46025                 }
46026                 var links = getNodeLinks(iife);
46027                 var cached = links.resolvedSignature;
46028                 links.resolvedSignature = anySignature;
46029                 var type = indexOfParameter < args.length ?
46030                     getWidenedLiteralType(checkExpression(args[indexOfParameter])) :
46031                     parameter.initializer ? undefined : undefinedWideningType;
46032                 links.resolvedSignature = cached;
46033                 return type;
46034             }
46035             var contextualSignature = getContextualSignature(func);
46036             if (contextualSignature) {
46037                 var index = func.parameters.indexOf(parameter) - (ts.getThisParameter(func) ? 1 : 0);
46038                 return parameter.dotDotDotToken && ts.lastOrUndefined(func.parameters) === parameter ?
46039                     getRestTypeAtPosition(contextualSignature, index) :
46040                     tryGetTypeAtPosition(contextualSignature, index);
46041             }
46042         }
46043         function getContextualTypeForVariableLikeDeclaration(declaration) {
46044             var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
46045             if (typeNode) {
46046                 return getTypeFromTypeNode(typeNode);
46047             }
46048             switch (declaration.kind) {
46049                 case 156:
46050                     return getContextuallyTypedParameterType(declaration);
46051                 case 191:
46052                     return getContextualTypeForBindingElement(declaration);
46053             }
46054         }
46055         function getContextualTypeForBindingElement(declaration) {
46056             var parent = declaration.parent.parent;
46057             var name = declaration.propertyName || declaration.name;
46058             var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
46059                 parent.kind !== 191 && parent.initializer && checkDeclarationInitializer(parent);
46060             if (parentType && !ts.isBindingPattern(name) && !ts.isComputedNonLiteralName(name)) {
46061                 var nameType = getLiteralTypeFromPropertyName(name);
46062                 if (isTypeUsableAsPropertyName(nameType)) {
46063                     var text = getPropertyNameFromType(nameType);
46064                     return getTypeOfPropertyOfType(parentType, text);
46065                 }
46066             }
46067         }
46068         function getContextualTypeForInitializerExpression(node) {
46069             var declaration = node.parent;
46070             if (ts.hasInitializer(declaration) && node === declaration.initializer) {
46071                 var result = getContextualTypeForVariableLikeDeclaration(declaration);
46072                 if (result) {
46073                     return result;
46074                 }
46075                 if (ts.isBindingPattern(declaration.name)) {
46076                     return getTypeFromBindingPattern(declaration.name, true, false);
46077                 }
46078             }
46079             return undefined;
46080         }
46081         function getContextualTypeForReturnExpression(node) {
46082             var func = ts.getContainingFunction(node);
46083             if (func) {
46084                 var functionFlags = ts.getFunctionFlags(func);
46085                 if (functionFlags & 1) {
46086                     return undefined;
46087                 }
46088                 var contextualReturnType = getContextualReturnType(func);
46089                 if (contextualReturnType) {
46090                     if (functionFlags & 2) {
46091                         var contextualAwaitedType = mapType(contextualReturnType, getAwaitedTypeOfPromise);
46092                         return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]);
46093                     }
46094                     return contextualReturnType;
46095                 }
46096             }
46097             return undefined;
46098         }
46099         function getContextualTypeForAwaitOperand(node) {
46100             var contextualType = getContextualType(node);
46101             if (contextualType) {
46102                 var contextualAwaitedType = getAwaitedType(contextualType);
46103                 return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]);
46104             }
46105             return undefined;
46106         }
46107         function getContextualTypeForYieldOperand(node) {
46108             var func = ts.getContainingFunction(node);
46109             if (func) {
46110                 var functionFlags = ts.getFunctionFlags(func);
46111                 var contextualReturnType = getContextualReturnType(func);
46112                 if (contextualReturnType) {
46113                     return node.asteriskToken
46114                         ? contextualReturnType
46115                         : getIterationTypeOfGeneratorFunctionReturnType(0, contextualReturnType, (functionFlags & 2) !== 0);
46116                 }
46117             }
46118             return undefined;
46119         }
46120         function isInParameterInitializerBeforeContainingFunction(node) {
46121             var inBindingInitializer = false;
46122             while (node.parent && !ts.isFunctionLike(node.parent)) {
46123                 if (ts.isParameter(node.parent) && (inBindingInitializer || node.parent.initializer === node)) {
46124                     return true;
46125                 }
46126                 if (ts.isBindingElement(node.parent) && node.parent.initializer === node) {
46127                     inBindingInitializer = true;
46128                 }
46129                 node = node.parent;
46130             }
46131             return false;
46132         }
46133         function getContextualIterationType(kind, functionDecl) {
46134             var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2);
46135             var contextualReturnType = getContextualReturnType(functionDecl);
46136             if (contextualReturnType) {
46137                 return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync)
46138                     || undefined;
46139             }
46140             return undefined;
46141         }
46142         function getContextualReturnType(functionDecl) {
46143             var returnType = getReturnTypeFromAnnotation(functionDecl);
46144             if (returnType) {
46145                 return returnType;
46146             }
46147             var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl);
46148             if (signature && !isResolvingReturnTypeOfSignature(signature)) {
46149                 return getReturnTypeOfSignature(signature);
46150             }
46151             return undefined;
46152         }
46153         function getContextualTypeForArgument(callTarget, arg) {
46154             var args = getEffectiveCallArguments(callTarget);
46155             var argIndex = args.indexOf(arg);
46156             return argIndex === -1 ? undefined : getContextualTypeForArgumentAtIndex(callTarget, argIndex);
46157         }
46158         function getContextualTypeForArgumentAtIndex(callTarget, argIndex) {
46159             var signature = getNodeLinks(callTarget).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(callTarget);
46160             if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) {
46161                 return getEffectiveFirstArgumentForJsxSignature(signature, callTarget);
46162             }
46163             return getTypeAtPosition(signature, argIndex);
46164         }
46165         function getContextualTypeForSubstitutionExpression(template, substitutionExpression) {
46166             if (template.parent.kind === 198) {
46167                 return getContextualTypeForArgument(template.parent, substitutionExpression);
46168             }
46169             return undefined;
46170         }
46171         function getContextualTypeForBinaryOperand(node, contextFlags) {
46172             var binaryExpression = node.parent;
46173             var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right;
46174             switch (operatorToken.kind) {
46175                 case 62:
46176                     if (node !== right) {
46177                         return undefined;
46178                     }
46179                     var contextSensitive = getIsContextSensitiveAssignmentOrContextType(binaryExpression);
46180                     if (!contextSensitive) {
46181                         return undefined;
46182                     }
46183                     return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive;
46184                 case 56:
46185                 case 60:
46186                     var type = getContextualType(binaryExpression, contextFlags);
46187                     return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ?
46188                         getTypeOfExpression(left) : type;
46189                 case 55:
46190                 case 27:
46191                     return node === right ? getContextualType(binaryExpression, contextFlags) : undefined;
46192                 default:
46193                     return undefined;
46194             }
46195         }
46196         function getIsContextSensitiveAssignmentOrContextType(binaryExpression) {
46197             var kind = ts.getAssignmentDeclarationKind(binaryExpression);
46198             switch (kind) {
46199                 case 0:
46200                     return true;
46201                 case 5:
46202                 case 1:
46203                 case 6:
46204                 case 3:
46205                     if (!binaryExpression.left.symbol) {
46206                         return true;
46207                     }
46208                     else {
46209                         var decl = binaryExpression.left.symbol.valueDeclaration;
46210                         if (!decl) {
46211                             return false;
46212                         }
46213                         var lhs = ts.cast(binaryExpression.left, ts.isAccessExpression);
46214                         var overallAnnotation = ts.getEffectiveTypeAnnotationNode(decl);
46215                         if (overallAnnotation) {
46216                             return getTypeFromTypeNode(overallAnnotation);
46217                         }
46218                         else if (ts.isIdentifier(lhs.expression)) {
46219                             var id = lhs.expression;
46220                             var parentSymbol = resolveName(id, id.escapedText, 111551, undefined, id.escapedText, true);
46221                             if (parentSymbol) {
46222                                 var annotated = ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration);
46223                                 if (annotated) {
46224                                     var nameStr_1 = ts.getElementOrPropertyAccessName(lhs);
46225                                     if (nameStr_1 !== undefined) {
46226                                         var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr_1);
46227                                         return type || false;
46228                                     }
46229                                 }
46230                                 return false;
46231                             }
46232                         }
46233                         return !ts.isInJSFile(decl);
46234                     }
46235                 case 2:
46236                 case 4:
46237                     if (!binaryExpression.symbol)
46238                         return true;
46239                     if (binaryExpression.symbol.valueDeclaration) {
46240                         var annotated = ts.getEffectiveTypeAnnotationNode(binaryExpression.symbol.valueDeclaration);
46241                         if (annotated) {
46242                             var type = getTypeFromTypeNode(annotated);
46243                             if (type) {
46244                                 return type;
46245                             }
46246                         }
46247                     }
46248                     if (kind === 2)
46249                         return false;
46250                     var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression);
46251                     if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, false))) {
46252                         return false;
46253                     }
46254                     var thisType = checkThisExpression(thisAccess.expression);
46255                     var nameStr = ts.getElementOrPropertyAccessName(thisAccess);
46256                     return nameStr !== undefined && thisType && getTypeOfPropertyOfContextualType(thisType, nameStr) || false;
46257                 case 7:
46258                 case 8:
46259                 case 9:
46260                     return ts.Debug.fail("Does not apply");
46261                 default:
46262                     return ts.Debug.assertNever(kind);
46263             }
46264         }
46265         function isCircularMappedProperty(symbol) {
46266             return !!(ts.getCheckFlags(symbol) & 262144 && !symbol.type && findResolutionCycleStartIndex(symbol, 0) >= 0);
46267         }
46268         function getTypeOfPropertyOfContextualType(type, name) {
46269             return mapType(type, function (t) {
46270                 if (isGenericMappedType(t)) {
46271                     var constraint = getConstraintTypeFromMappedType(t);
46272                     var constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
46273                     var propertyNameType = getLiteralType(ts.unescapeLeadingUnderscores(name));
46274                     if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
46275                         return substituteIndexedMappedType(t, propertyNameType);
46276                     }
46277                 }
46278                 else if (t.flags & 3670016) {
46279                     var prop = getPropertyOfType(t, name);
46280                     if (prop) {
46281                         return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop);
46282                     }
46283                     if (isTupleType(t)) {
46284                         var restType = getRestTypeOfTupleType(t);
46285                         if (restType && isNumericLiteralName(name) && +name >= 0) {
46286                             return restType;
46287                         }
46288                     }
46289                     return isNumericLiteralName(name) && getIndexTypeOfContextualType(t, 1) ||
46290                         getIndexTypeOfContextualType(t, 0);
46291                 }
46292                 return undefined;
46293             }, true);
46294         }
46295         function getIndexTypeOfContextualType(type, kind) {
46296             return mapType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }, true);
46297         }
46298         function getContextualTypeForObjectLiteralMethod(node, contextFlags) {
46299             ts.Debug.assert(ts.isObjectLiteralMethod(node));
46300             if (node.flags & 16777216) {
46301                 return undefined;
46302             }
46303             return getContextualTypeForObjectLiteralElement(node, contextFlags);
46304         }
46305         function getContextualTypeForObjectLiteralElement(element, contextFlags) {
46306             var objectLiteral = element.parent;
46307             var type = getApparentTypeOfContextualType(objectLiteral, contextFlags);
46308             if (type) {
46309                 if (!hasNonBindableDynamicName(element)) {
46310                     var symbolName_3 = getSymbolOfNode(element).escapedName;
46311                     var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_3);
46312                     if (propertyType) {
46313                         return propertyType;
46314                     }
46315                 }
46316                 return isNumericName(element.name) && getIndexTypeOfContextualType(type, 1) ||
46317                     getIndexTypeOfContextualType(type, 0);
46318             }
46319             return undefined;
46320         }
46321         function getContextualTypeForElementExpression(arrayContextualType, index) {
46322             return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index)
46323                 || getIteratedTypeOrElementType(1, arrayContextualType, undefinedType, undefined, false));
46324         }
46325         function getContextualTypeForConditionalOperand(node, contextFlags) {
46326             var conditional = node.parent;
46327             return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional, contextFlags) : undefined;
46328         }
46329         function getContextualTypeForChildJsxExpression(node, child) {
46330             var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName);
46331             var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
46332             if (!(attributesType && !isTypeAny(attributesType) && jsxChildrenPropertyName && jsxChildrenPropertyName !== "")) {
46333                 return undefined;
46334             }
46335             var realChildren = getSemanticJsxChildren(node.children);
46336             var childIndex = realChildren.indexOf(child);
46337             var childFieldType = getTypeOfPropertyOfContextualType(attributesType, jsxChildrenPropertyName);
46338             return childFieldType && (realChildren.length === 1 ? childFieldType : mapType(childFieldType, function (t) {
46339                 if (isArrayLikeType(t)) {
46340                     return getIndexedAccessType(t, getLiteralType(childIndex));
46341                 }
46342                 else {
46343                     return t;
46344                 }
46345             }, true));
46346         }
46347         function getContextualTypeForJsxExpression(node) {
46348             var exprParent = node.parent;
46349             return ts.isJsxAttributeLike(exprParent)
46350                 ? getContextualType(node)
46351                 : ts.isJsxElement(exprParent)
46352                     ? getContextualTypeForChildJsxExpression(exprParent, node)
46353                     : undefined;
46354         }
46355         function getContextualTypeForJsxAttribute(attribute) {
46356             if (ts.isJsxAttribute(attribute)) {
46357                 var attributesType = getApparentTypeOfContextualType(attribute.parent);
46358                 if (!attributesType || isTypeAny(attributesType)) {
46359                     return undefined;
46360                 }
46361                 return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText);
46362             }
46363             else {
46364                 return getContextualType(attribute.parent);
46365             }
46366         }
46367         function isPossiblyDiscriminantValue(node) {
46368             switch (node.kind) {
46369                 case 10:
46370                 case 8:
46371                 case 9:
46372                 case 14:
46373                 case 106:
46374                 case 91:
46375                 case 100:
46376                 case 75:
46377                 case 146:
46378                     return true;
46379                 case 194:
46380                 case 200:
46381                     return isPossiblyDiscriminantValue(node.expression);
46382                 case 276:
46383                     return !node.expression || isPossiblyDiscriminantValue(node.expression);
46384             }
46385             return false;
46386         }
46387         function discriminateContextualTypeByObjectMembers(node, contextualType) {
46388             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);
46389         }
46390         function discriminateContextualTypeByJSXAttributes(node, contextualType) {
46391             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);
46392         }
46393         function getApparentTypeOfContextualType(node, contextFlags) {
46394             var contextualType = ts.isObjectLiteralMethod(node) ?
46395                 getContextualTypeForObjectLiteralMethod(node, contextFlags) :
46396                 getContextualType(node, contextFlags);
46397             var instantiatedType = instantiateContextualType(contextualType, node, contextFlags);
46398             if (instantiatedType && !(contextFlags && contextFlags & 2 && instantiatedType.flags & 8650752)) {
46399                 var apparentType = mapType(instantiatedType, getApparentType, true);
46400                 if (apparentType.flags & 1048576) {
46401                     if (ts.isObjectLiteralExpression(node)) {
46402                         return discriminateContextualTypeByObjectMembers(node, apparentType);
46403                     }
46404                     else if (ts.isJsxAttributes(node)) {
46405                         return discriminateContextualTypeByJSXAttributes(node, apparentType);
46406                     }
46407                 }
46408                 return apparentType;
46409             }
46410         }
46411         function instantiateContextualType(contextualType, node, contextFlags) {
46412             if (contextualType && maybeTypeOfKind(contextualType, 63176704)) {
46413                 var inferenceContext = getInferenceContext(node);
46414                 if (inferenceContext && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
46415                     if (contextFlags && contextFlags & 1) {
46416                         return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
46417                     }
46418                     if (inferenceContext.returnMapper) {
46419                         return instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
46420                     }
46421                 }
46422             }
46423             return contextualType;
46424         }
46425         function instantiateInstantiableTypes(type, mapper) {
46426             if (type.flags & 63176704) {
46427                 return instantiateType(type, mapper);
46428             }
46429             if (type.flags & 1048576) {
46430                 return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0);
46431             }
46432             if (type.flags & 2097152) {
46433                 return getIntersectionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }));
46434             }
46435             return type;
46436         }
46437         function getContextualType(node, contextFlags) {
46438             if (node.flags & 16777216) {
46439                 return undefined;
46440             }
46441             if (node.contextualType) {
46442                 return node.contextualType;
46443             }
46444             var parent = node.parent;
46445             switch (parent.kind) {
46446                 case 242:
46447                 case 156:
46448                 case 159:
46449                 case 158:
46450                 case 191:
46451                     return getContextualTypeForInitializerExpression(node);
46452                 case 202:
46453                 case 235:
46454                     return getContextualTypeForReturnExpression(node);
46455                 case 212:
46456                     return getContextualTypeForYieldOperand(parent);
46457                 case 206:
46458                     return getContextualTypeForAwaitOperand(parent);
46459                 case 196:
46460                     if (parent.expression.kind === 96) {
46461                         return stringType;
46462                     }
46463                 case 197:
46464                     return getContextualTypeForArgument(parent, node);
46465                 case 199:
46466                 case 217:
46467                     return ts.isConstTypeReference(parent.type) ? undefined : getTypeFromTypeNode(parent.type);
46468                 case 209:
46469                     return getContextualTypeForBinaryOperand(node, contextFlags);
46470                 case 281:
46471                 case 282:
46472                     return getContextualTypeForObjectLiteralElement(parent, contextFlags);
46473                 case 283:
46474                     return getApparentTypeOfContextualType(parent.parent, contextFlags);
46475                 case 192: {
46476                     var arrayLiteral = parent;
46477                     var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags);
46478                     return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node));
46479                 }
46480                 case 210:
46481                     return getContextualTypeForConditionalOperand(node, contextFlags);
46482                 case 221:
46483                     ts.Debug.assert(parent.parent.kind === 211);
46484                     return getContextualTypeForSubstitutionExpression(parent.parent, node);
46485                 case 200: {
46486                     var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined;
46487                     return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags);
46488                 }
46489                 case 276:
46490                     return getContextualTypeForJsxExpression(parent);
46491                 case 273:
46492                 case 275:
46493                     return getContextualTypeForJsxAttribute(parent);
46494                 case 268:
46495                 case 267:
46496                     return getContextualJsxElementAttributesType(parent, contextFlags);
46497             }
46498             return undefined;
46499         }
46500         function getInferenceContext(node) {
46501             var ancestor = ts.findAncestor(node, function (n) { return !!n.inferenceContext; });
46502             return ancestor && ancestor.inferenceContext;
46503         }
46504         function getContextualJsxElementAttributesType(node, contextFlags) {
46505             if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4) {
46506                 return node.parent.contextualType;
46507             }
46508             return getContextualTypeForArgumentAtIndex(node, 0);
46509         }
46510         function getEffectiveFirstArgumentForJsxSignature(signature, node) {
46511             return getJsxReferenceKind(node) !== 0
46512                 ? getJsxPropsTypeFromCallSignature(signature, node)
46513                 : getJsxPropsTypeFromClassType(signature, node);
46514         }
46515         function getJsxPropsTypeFromCallSignature(sig, context) {
46516             var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType);
46517             propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType);
46518             var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
46519             if (intrinsicAttribs !== errorType) {
46520                 propsType = intersectTypes(intrinsicAttribs, propsType);
46521             }
46522             return propsType;
46523         }
46524         function getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation) {
46525             if (sig.unionSignatures) {
46526                 var results = [];
46527                 for (var _i = 0, _a = sig.unionSignatures; _i < _a.length; _i++) {
46528                     var signature = _a[_i];
46529                     var instance = getReturnTypeOfSignature(signature);
46530                     if (isTypeAny(instance)) {
46531                         return instance;
46532                     }
46533                     var propType = getTypeOfPropertyOfType(instance, forcedLookupLocation);
46534                     if (!propType) {
46535                         return;
46536                     }
46537                     results.push(propType);
46538                 }
46539                 return getIntersectionType(results);
46540             }
46541             var instanceType = getReturnTypeOfSignature(sig);
46542             return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation);
46543         }
46544         function getStaticTypeOfReferencedJsxConstructor(context) {
46545             if (isJsxIntrinsicIdentifier(context.tagName)) {
46546                 var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(context);
46547                 var fakeSignature = createSignatureForJSXIntrinsic(context, result);
46548                 return getOrCreateTypeFromSignature(fakeSignature);
46549             }
46550             var tagType = checkExpressionCached(context.tagName);
46551             if (tagType.flags & 128) {
46552                 var result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context);
46553                 if (!result) {
46554                     return errorType;
46555                 }
46556                 var fakeSignature = createSignatureForJSXIntrinsic(context, result);
46557                 return getOrCreateTypeFromSignature(fakeSignature);
46558             }
46559             return tagType;
46560         }
46561         function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) {
46562             var managedSym = getJsxLibraryManagedAttributes(ns);
46563             if (managedSym) {
46564                 var declaredManagedType = getDeclaredTypeOfSymbol(managedSym);
46565                 var ctorType = getStaticTypeOfReferencedJsxConstructor(context);
46566                 if (ts.length(declaredManagedType.typeParameters) >= 2) {
46567                     var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.typeParameters, 2, ts.isInJSFile(context));
46568                     return createTypeReference(declaredManagedType, args);
46569                 }
46570                 else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) {
46571                     var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJSFile(context));
46572                     return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args);
46573                 }
46574             }
46575             return attributesType;
46576         }
46577         function getJsxPropsTypeFromClassType(sig, context) {
46578             var ns = getJsxNamespaceAt(context);
46579             var forcedLookupLocation = getJsxElementPropertiesName(ns);
46580             var attributesType = forcedLookupLocation === undefined
46581                 ? getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType)
46582                 : forcedLookupLocation === ""
46583                     ? getReturnTypeOfSignature(sig)
46584                     : getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation);
46585             if (!attributesType) {
46586                 if (!!forcedLookupLocation && !!ts.length(context.attributes.properties)) {
46587                     error(context, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, ts.unescapeLeadingUnderscores(forcedLookupLocation));
46588                 }
46589                 return unknownType;
46590             }
46591             attributesType = getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType);
46592             if (isTypeAny(attributesType)) {
46593                 return attributesType;
46594             }
46595             else {
46596                 var apparentAttributesType = attributesType;
46597                 var intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes, context);
46598                 if (intrinsicClassAttribs !== errorType) {
46599                     var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol);
46600                     var hostClassType = getReturnTypeOfSignature(sig);
46601                     apparentAttributesType = intersectTypes(typeParams
46602                         ? createTypeReference(intrinsicClassAttribs, fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), ts.isInJSFile(context)))
46603                         : intrinsicClassAttribs, apparentAttributesType);
46604                 }
46605                 var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
46606                 if (intrinsicAttribs !== errorType) {
46607                     apparentAttributesType = intersectTypes(intrinsicAttribs, apparentAttributesType);
46608                 }
46609                 return apparentAttributesType;
46610             }
46611         }
46612         function getContextualCallSignature(type, node) {
46613             var signatures = getSignaturesOfType(type, 0);
46614             if (signatures.length === 1) {
46615                 var signature = signatures[0];
46616                 if (!isAritySmaller(signature, node)) {
46617                     return signature;
46618                 }
46619             }
46620         }
46621         function isAritySmaller(signature, target) {
46622             var targetParameterCount = 0;
46623             for (; targetParameterCount < target.parameters.length; targetParameterCount++) {
46624                 var param = target.parameters[targetParameterCount];
46625                 if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) {
46626                     break;
46627                 }
46628             }
46629             if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) {
46630                 targetParameterCount--;
46631             }
46632             return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount;
46633         }
46634         function isFunctionExpressionOrArrowFunction(node) {
46635             return node.kind === 201 || node.kind === 202;
46636         }
46637         function getContextualSignatureForFunctionLikeDeclaration(node) {
46638             return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node)
46639                 ? getContextualSignature(node)
46640                 : undefined;
46641         }
46642         function getContextualSignature(node) {
46643             ts.Debug.assert(node.kind !== 161 || ts.isObjectLiteralMethod(node));
46644             var typeTagSignature = getSignatureOfTypeTag(node);
46645             if (typeTagSignature) {
46646                 return typeTagSignature;
46647             }
46648             var type = getApparentTypeOfContextualType(node, 1);
46649             if (!type) {
46650                 return undefined;
46651             }
46652             if (!(type.flags & 1048576)) {
46653                 return getContextualCallSignature(type, node);
46654             }
46655             var signatureList;
46656             var types = type.types;
46657             for (var _i = 0, types_17 = types; _i < types_17.length; _i++) {
46658                 var current = types_17[_i];
46659                 var signature = getContextualCallSignature(current, node);
46660                 if (signature) {
46661                     if (!signatureList) {
46662                         signatureList = [signature];
46663                     }
46664                     else if (!compareSignaturesIdentical(signatureList[0], signature, false, true, true, compareTypesIdentical)) {
46665                         return undefined;
46666                     }
46667                     else {
46668                         signatureList.push(signature);
46669                     }
46670                 }
46671             }
46672             if (signatureList) {
46673                 return signatureList.length === 1 ? signatureList[0] : createUnionSignature(signatureList[0], signatureList);
46674             }
46675         }
46676         function checkSpreadExpression(node, checkMode) {
46677             if (languageVersion < 2) {
46678                 checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 : 2048);
46679             }
46680             var arrayOrIterableType = checkExpression(node.expression, checkMode);
46681             return checkIteratedTypeOrElementType(33, arrayOrIterableType, undefinedType, node.expression);
46682         }
46683         function hasDefaultValue(node) {
46684             return (node.kind === 191 && !!node.initializer) ||
46685                 (node.kind === 209 && node.operatorToken.kind === 62);
46686         }
46687         function checkArrayLiteral(node, checkMode, forceTuple) {
46688             var elements = node.elements;
46689             var elementCount = elements.length;
46690             var elementTypes = [];
46691             var hasEndingSpreadElement = false;
46692             var hasNonEndingSpreadElement = false;
46693             var contextualType = getApparentTypeOfContextualType(node);
46694             var inDestructuringPattern = ts.isAssignmentTarget(node);
46695             var inConstContext = isConstContext(node);
46696             for (var i = 0; i < elementCount; i++) {
46697                 var e = elements[i];
46698                 var spread = e.kind === 213 && e.expression;
46699                 var spreadType = spread && checkExpression(spread, checkMode, forceTuple);
46700                 if (spreadType && isTupleType(spreadType)) {
46701                     elementTypes.push.apply(elementTypes, getTypeArguments(spreadType));
46702                     if (spreadType.target.hasRestElement) {
46703                         if (i === elementCount - 1)
46704                             hasEndingSpreadElement = true;
46705                         else
46706                             hasNonEndingSpreadElement = true;
46707                     }
46708                 }
46709                 else {
46710                     if (inDestructuringPattern && spreadType) {
46711                         var restElementType = getIndexTypeOfType(spreadType, 1) ||
46712                             getIteratedTypeOrElementType(65, spreadType, undefinedType, undefined, false);
46713                         if (restElementType) {
46714                             elementTypes.push(restElementType);
46715                         }
46716                     }
46717                     else {
46718                         var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length);
46719                         var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple);
46720                         elementTypes.push(type);
46721                     }
46722                     if (spread) {
46723                         if (i === elementCount - 1)
46724                             hasEndingSpreadElement = true;
46725                         else
46726                             hasNonEndingSpreadElement = true;
46727                     }
46728                 }
46729             }
46730             if (!hasNonEndingSpreadElement) {
46731                 var minLength = elementTypes.length - (hasEndingSpreadElement ? 1 : 0);
46732                 var tupleResult = void 0;
46733                 if (inDestructuringPattern && minLength > 0) {
46734                     var type = cloneTypeReference(createTupleType(elementTypes, minLength, hasEndingSpreadElement));
46735                     type.pattern = node;
46736                     return type;
46737                 }
46738                 else if (tupleResult = getArrayLiteralTupleTypeIfApplicable(elementTypes, contextualType, hasEndingSpreadElement, elementTypes.length, inConstContext)) {
46739                     return createArrayLiteralType(tupleResult);
46740                 }
46741                 else if (forceTuple) {
46742                     return createArrayLiteralType(createTupleType(elementTypes, minLength, hasEndingSpreadElement));
46743                 }
46744             }
46745             return createArrayLiteralType(createArrayType(elementTypes.length ?
46746                 getUnionType(elementTypes, 2) :
46747                 strictNullChecks ? implicitNeverType : undefinedWideningType, inConstContext));
46748         }
46749         function createArrayLiteralType(type) {
46750             if (!(ts.getObjectFlags(type) & 4)) {
46751                 return type;
46752             }
46753             var literalType = type.literalType;
46754             if (!literalType) {
46755                 literalType = type.literalType = cloneTypeReference(type);
46756                 literalType.objectFlags |= 65536 | 1048576;
46757             }
46758             return literalType;
46759         }
46760         function getArrayLiteralTupleTypeIfApplicable(elementTypes, contextualType, hasRestElement, elementCount, readonly) {
46761             if (elementCount === void 0) { elementCount = elementTypes.length; }
46762             if (readonly === void 0) { readonly = false; }
46763             if (readonly || (contextualType && forEachType(contextualType, isTupleLikeType))) {
46764                 return createTupleType(elementTypes, elementCount - (hasRestElement ? 1 : 0), hasRestElement, readonly);
46765             }
46766         }
46767         function isNumericName(name) {
46768             switch (name.kind) {
46769                 case 154:
46770                     return isNumericComputedName(name);
46771                 case 75:
46772                     return isNumericLiteralName(name.escapedText);
46773                 case 8:
46774                 case 10:
46775                     return isNumericLiteralName(name.text);
46776                 default:
46777                     return false;
46778             }
46779         }
46780         function isNumericComputedName(name) {
46781             return isTypeAssignableToKind(checkComputedPropertyName(name), 296);
46782         }
46783         function isInfinityOrNaNString(name) {
46784             return name === "Infinity" || name === "-Infinity" || name === "NaN";
46785         }
46786         function isNumericLiteralName(name) {
46787             return (+name).toString() === name;
46788         }
46789         function checkComputedPropertyName(node) {
46790             var links = getNodeLinks(node.expression);
46791             if (!links.resolvedType) {
46792                 links.resolvedType = checkExpression(node.expression);
46793                 if (links.resolvedType.flags & 98304 ||
46794                     !isTypeAssignableToKind(links.resolvedType, 132 | 296 | 12288) &&
46795                         !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) {
46796                     error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any);
46797                 }
46798                 else {
46799                     checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, true);
46800                 }
46801             }
46802             return links.resolvedType;
46803         }
46804         function getObjectLiteralIndexInfo(node, offset, properties, kind) {
46805             var propTypes = [];
46806             for (var i = 0; i < properties.length; i++) {
46807                 if (kind === 0 || isNumericName(node.properties[i + offset].name)) {
46808                     propTypes.push(getTypeOfSymbol(properties[i]));
46809                 }
46810             }
46811             var unionType = propTypes.length ? getUnionType(propTypes, 2) : undefinedType;
46812             return createIndexInfo(unionType, isConstContext(node));
46813         }
46814         function getImmediateAliasedSymbol(symbol) {
46815             ts.Debug.assert((symbol.flags & 2097152) !== 0, "Should only get Alias here.");
46816             var links = getSymbolLinks(symbol);
46817             if (!links.immediateTarget) {
46818                 var node = getDeclarationOfAliasSymbol(symbol);
46819                 if (!node)
46820                     return ts.Debug.fail();
46821                 links.immediateTarget = getTargetOfAliasDeclaration(node, true);
46822             }
46823             return links.immediateTarget;
46824         }
46825         function checkObjectLiteral(node, checkMode) {
46826             var inDestructuringPattern = ts.isAssignmentTarget(node);
46827             checkGrammarObjectLiteralExpression(node, inDestructuringPattern);
46828             var allPropertiesTable = strictNullChecks ? ts.createSymbolTable() : undefined;
46829             var propertiesTable = ts.createSymbolTable();
46830             var propertiesArray = [];
46831             var spread = emptyObjectType;
46832             var contextualType = getApparentTypeOfContextualType(node);
46833             var contextualTypeHasPattern = contextualType && contextualType.pattern &&
46834                 (contextualType.pattern.kind === 189 || contextualType.pattern.kind === 193);
46835             var inConstContext = isConstContext(node);
46836             var checkFlags = inConstContext ? 8 : 0;
46837             var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node);
46838             var enumTag = ts.getJSDocEnumTag(node);
46839             var isJSObjectLiteral = !contextualType && isInJavascript && !enumTag;
46840             var objectFlags = freshObjectLiteralFlag;
46841             var patternWithComputedProperties = false;
46842             var hasComputedStringProperty = false;
46843             var hasComputedNumberProperty = false;
46844             for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
46845                 var elem = _a[_i];
46846                 if (elem.name && ts.isComputedPropertyName(elem.name) && !ts.isWellKnownSymbolSyntactically(elem.name)) {
46847                     checkComputedPropertyName(elem.name);
46848                 }
46849             }
46850             var offset = 0;
46851             for (var i = 0; i < node.properties.length; i++) {
46852                 var memberDecl = node.properties[i];
46853                 var member = getSymbolOfNode(memberDecl);
46854                 var computedNameType = memberDecl.name && memberDecl.name.kind === 154 && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ?
46855                     checkComputedPropertyName(memberDecl.name) : undefined;
46856                 if (memberDecl.kind === 281 ||
46857                     memberDecl.kind === 282 ||
46858                     ts.isObjectLiteralMethod(memberDecl)) {
46859                     var type = memberDecl.kind === 281 ? checkPropertyAssignment(memberDecl, checkMode) :
46860                         memberDecl.kind === 282 ? checkExpressionForMutableLocation(memberDecl.name, checkMode) :
46861                             checkObjectLiteralMethod(memberDecl, checkMode);
46862                     if (isInJavascript) {
46863                         var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
46864                         if (jsDocType) {
46865                             checkTypeAssignableTo(type, jsDocType, memberDecl);
46866                             type = jsDocType;
46867                         }
46868                         else if (enumTag && enumTag.typeExpression) {
46869                             checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl);
46870                         }
46871                     }
46872                     objectFlags |= ts.getObjectFlags(type) & 3670016;
46873                     var nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined;
46874                     var prop = nameType ?
46875                         createSymbol(4 | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096) :
46876                         createSymbol(4 | member.flags, member.escapedName, checkFlags);
46877                     if (nameType) {
46878                         prop.nameType = nameType;
46879                     }
46880                     if (inDestructuringPattern) {
46881                         var isOptional = (memberDecl.kind === 281 && hasDefaultValue(memberDecl.initializer)) ||
46882                             (memberDecl.kind === 282 && memberDecl.objectAssignmentInitializer);
46883                         if (isOptional) {
46884                             prop.flags |= 16777216;
46885                         }
46886                     }
46887                     else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512)) {
46888                         var impliedProp = getPropertyOfType(contextualType, member.escapedName);
46889                         if (impliedProp) {
46890                             prop.flags |= impliedProp.flags & 16777216;
46891                         }
46892                         else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, 0)) {
46893                             error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType));
46894                         }
46895                     }
46896                     prop.declarations = member.declarations;
46897                     prop.parent = member.parent;
46898                     if (member.valueDeclaration) {
46899                         prop.valueDeclaration = member.valueDeclaration;
46900                     }
46901                     prop.type = type;
46902                     prop.target = member;
46903                     member = prop;
46904                     allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
46905                 }
46906                 else if (memberDecl.kind === 283) {
46907                     if (languageVersion < 2) {
46908                         checkExternalEmitHelpers(memberDecl, 2);
46909                     }
46910                     if (propertiesArray.length > 0) {
46911                         spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext);
46912                         propertiesArray = [];
46913                         propertiesTable = ts.createSymbolTable();
46914                         hasComputedStringProperty = false;
46915                         hasComputedNumberProperty = false;
46916                     }
46917                     var type = getReducedType(checkExpression(memberDecl.expression));
46918                     if (!isValidSpreadType(type)) {
46919                         error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types);
46920                         return errorType;
46921                     }
46922                     if (allPropertiesTable) {
46923                         checkSpreadPropOverrides(type, allPropertiesTable, memberDecl);
46924                     }
46925                     spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext);
46926                     offset = i + 1;
46927                     continue;
46928                 }
46929                 else {
46930                     ts.Debug.assert(memberDecl.kind === 163 || memberDecl.kind === 164);
46931                     checkNodeDeferred(memberDecl);
46932                 }
46933                 if (computedNameType && !(computedNameType.flags & 8576)) {
46934                     if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) {
46935                         if (isTypeAssignableTo(computedNameType, numberType)) {
46936                             hasComputedNumberProperty = true;
46937                         }
46938                         else {
46939                             hasComputedStringProperty = true;
46940                         }
46941                         if (inDestructuringPattern) {
46942                             patternWithComputedProperties = true;
46943                         }
46944                     }
46945                 }
46946                 else {
46947                     propertiesTable.set(member.escapedName, member);
46948                 }
46949                 propertiesArray.push(member);
46950             }
46951             if (contextualTypeHasPattern && node.parent.kind !== 283) {
46952                 for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) {
46953                     var prop = _c[_b];
46954                     if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) {
46955                         if (!(prop.flags & 16777216)) {
46956                             error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
46957                         }
46958                         propertiesTable.set(prop.escapedName, prop);
46959                         propertiesArray.push(prop);
46960                     }
46961                 }
46962             }
46963             if (spread !== emptyObjectType) {
46964                 if (propertiesArray.length > 0) {
46965                     spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext);
46966                     propertiesArray = [];
46967                     propertiesTable = ts.createSymbolTable();
46968                     hasComputedStringProperty = false;
46969                     hasComputedNumberProperty = false;
46970                 }
46971                 return mapType(spread, function (t) { return t === emptyObjectType ? createObjectLiteralType() : t; });
46972             }
46973             return createObjectLiteralType();
46974             function createObjectLiteralType() {
46975                 var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 0) : undefined;
46976                 var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 1) : undefined;
46977                 var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo);
46978                 result.objectFlags |= objectFlags | 128 | 1048576;
46979                 if (isJSObjectLiteral) {
46980                     result.objectFlags |= 16384;
46981                 }
46982                 if (patternWithComputedProperties) {
46983                     result.objectFlags |= 512;
46984                 }
46985                 if (inDestructuringPattern) {
46986                     result.pattern = node;
46987                 }
46988                 return result;
46989             }
46990         }
46991         function isValidSpreadType(type) {
46992             if (type.flags & 63176704) {
46993                 var constraint = getBaseConstraintOfType(type);
46994                 if (constraint !== undefined) {
46995                     return isValidSpreadType(constraint);
46996                 }
46997             }
46998             return !!(type.flags & (1 | 67108864 | 524288 | 58982400) ||
46999                 getFalsyFlags(type) & 117632 && isValidSpreadType(removeDefinitelyFalsyTypes(type)) ||
47000                 type.flags & 3145728 && ts.every(type.types, isValidSpreadType));
47001         }
47002         function checkJsxSelfClosingElementDeferred(node) {
47003             checkJsxOpeningLikeElementOrOpeningFragment(node);
47004             resolveUntypedCall(node);
47005         }
47006         function checkJsxSelfClosingElement(node, _checkMode) {
47007             checkNodeDeferred(node);
47008             return getJsxElementTypeAt(node) || anyType;
47009         }
47010         function checkJsxElementDeferred(node) {
47011             checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement);
47012             if (isJsxIntrinsicIdentifier(node.closingElement.tagName)) {
47013                 getIntrinsicTagSymbol(node.closingElement);
47014             }
47015             else {
47016                 checkExpression(node.closingElement.tagName);
47017             }
47018             checkJsxChildren(node);
47019         }
47020         function checkJsxElement(node, _checkMode) {
47021             checkNodeDeferred(node);
47022             return getJsxElementTypeAt(node) || anyType;
47023         }
47024         function checkJsxFragment(node) {
47025             checkJsxOpeningLikeElementOrOpeningFragment(node.openingFragment);
47026             if (compilerOptions.jsx === 2 && (compilerOptions.jsxFactory || ts.getSourceFileOfNode(node).pragmas.has("jsx"))) {
47027                 error(node, compilerOptions.jsxFactory
47028                     ? ts.Diagnostics.JSX_fragment_is_not_supported_when_using_jsxFactory
47029                     : ts.Diagnostics.JSX_fragment_is_not_supported_when_using_an_inline_JSX_factory_pragma);
47030             }
47031             checkJsxChildren(node);
47032             return getJsxElementTypeAt(node) || anyType;
47033         }
47034         function isUnhyphenatedJsxName(name) {
47035             return !ts.stringContains(name, "-");
47036         }
47037         function isJsxIntrinsicIdentifier(tagName) {
47038             return tagName.kind === 75 && ts.isIntrinsicJsxName(tagName.escapedText);
47039         }
47040         function checkJsxAttribute(node, checkMode) {
47041             return node.initializer
47042                 ? checkExpressionForMutableLocation(node.initializer, checkMode)
47043                 : trueType;
47044         }
47045         function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, checkMode) {
47046             var attributes = openingLikeElement.attributes;
47047             var allAttributesTable = strictNullChecks ? ts.createSymbolTable() : undefined;
47048             var attributesTable = ts.createSymbolTable();
47049             var spread = emptyJsxObjectType;
47050             var hasSpreadAnyType = false;
47051             var typeToIntersect;
47052             var explicitlySpecifyChildrenAttribute = false;
47053             var objectFlags = 4096;
47054             var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(openingLikeElement));
47055             for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) {
47056                 var attributeDecl = _a[_i];
47057                 var member = attributeDecl.symbol;
47058                 if (ts.isJsxAttribute(attributeDecl)) {
47059                     var exprType = checkJsxAttribute(attributeDecl, checkMode);
47060                     objectFlags |= ts.getObjectFlags(exprType) & 3670016;
47061                     var attributeSymbol = createSymbol(4 | 33554432 | member.flags, member.escapedName);
47062                     attributeSymbol.declarations = member.declarations;
47063                     attributeSymbol.parent = member.parent;
47064                     if (member.valueDeclaration) {
47065                         attributeSymbol.valueDeclaration = member.valueDeclaration;
47066                     }
47067                     attributeSymbol.type = exprType;
47068                     attributeSymbol.target = member;
47069                     attributesTable.set(attributeSymbol.escapedName, attributeSymbol);
47070                     allAttributesTable === null || allAttributesTable === void 0 ? void 0 : allAttributesTable.set(attributeSymbol.escapedName, attributeSymbol);
47071                     if (attributeDecl.name.escapedText === jsxChildrenPropertyName) {
47072                         explicitlySpecifyChildrenAttribute = true;
47073                     }
47074                 }
47075                 else {
47076                     ts.Debug.assert(attributeDecl.kind === 275);
47077                     if (attributesTable.size > 0) {
47078                         spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, false);
47079                         attributesTable = ts.createSymbolTable();
47080                     }
47081                     var exprType = getReducedType(checkExpressionCached(attributeDecl.expression, checkMode));
47082                     if (isTypeAny(exprType)) {
47083                         hasSpreadAnyType = true;
47084                     }
47085                     if (isValidSpreadType(exprType)) {
47086                         spread = getSpreadType(spread, exprType, attributes.symbol, objectFlags, false);
47087                         if (allAttributesTable) {
47088                             checkSpreadPropOverrides(exprType, allAttributesTable, attributeDecl);
47089                         }
47090                     }
47091                     else {
47092                         typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType;
47093                     }
47094                 }
47095             }
47096             if (!hasSpreadAnyType) {
47097                 if (attributesTable.size > 0) {
47098                     spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, false);
47099                 }
47100             }
47101             var parent = openingLikeElement.parent.kind === 266 ? openingLikeElement.parent : undefined;
47102             if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) {
47103                 var childrenTypes = checkJsxChildren(parent, checkMode);
47104                 if (!hasSpreadAnyType && jsxChildrenPropertyName && jsxChildrenPropertyName !== "") {
47105                     if (explicitlySpecifyChildrenAttribute) {
47106                         error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName));
47107                     }
47108                     var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes);
47109                     var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName);
47110                     var childrenPropSymbol = createSymbol(4 | 33554432, jsxChildrenPropertyName);
47111                     childrenPropSymbol.type = childrenTypes.length === 1 ?
47112                         childrenTypes[0] :
47113                         (getArrayLiteralTupleTypeIfApplicable(childrenTypes, childrenContextualType, false) || createArrayType(getUnionType(childrenTypes)));
47114                     childrenPropSymbol.valueDeclaration = ts.createPropertySignature(undefined, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName), undefined, undefined, undefined);
47115                     childrenPropSymbol.valueDeclaration.parent = attributes;
47116                     childrenPropSymbol.valueDeclaration.symbol = childrenPropSymbol;
47117                     var childPropMap = ts.createSymbolTable();
47118                     childPropMap.set(jsxChildrenPropertyName, childrenPropSymbol);
47119                     spread = getSpreadType(spread, createAnonymousType(attributes.symbol, childPropMap, ts.emptyArray, ts.emptyArray, undefined, undefined), attributes.symbol, objectFlags, false);
47120                 }
47121             }
47122             if (hasSpreadAnyType) {
47123                 return anyType;
47124             }
47125             if (typeToIntersect && spread !== emptyJsxObjectType) {
47126                 return getIntersectionType([typeToIntersect, spread]);
47127             }
47128             return typeToIntersect || (spread === emptyJsxObjectType ? createJsxAttributesType() : spread);
47129             function createJsxAttributesType() {
47130                 objectFlags |= freshObjectLiteralFlag;
47131                 var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, undefined, undefined);
47132                 result.objectFlags |= objectFlags | 128 | 1048576;
47133                 return result;
47134             }
47135         }
47136         function checkJsxChildren(node, checkMode) {
47137             var childrenTypes = [];
47138             for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
47139                 var child = _a[_i];
47140                 if (child.kind === 11) {
47141                     if (!child.containsOnlyTriviaWhiteSpaces) {
47142                         childrenTypes.push(stringType);
47143                     }
47144                 }
47145                 else {
47146                     childrenTypes.push(checkExpressionForMutableLocation(child, checkMode));
47147                 }
47148             }
47149             return childrenTypes;
47150         }
47151         function checkSpreadPropOverrides(type, props, spread) {
47152             for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) {
47153                 var right = _a[_i];
47154                 var left = props.get(right.escapedName);
47155                 var rightType = getTypeOfSymbol(right);
47156                 if (left && !maybeTypeOfKind(rightType, 98304) && !(maybeTypeOfKind(rightType, 3) && right.flags & 16777216)) {
47157                     var diagnostic = error(left.valueDeclaration, ts.Diagnostics._0_is_specified_more_than_once_so_this_usage_will_be_overwritten, ts.unescapeLeadingUnderscores(left.escapedName));
47158                     ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(spread, ts.Diagnostics.This_spread_always_overwrites_this_property));
47159                 }
47160             }
47161         }
47162         function checkJsxAttributes(node, checkMode) {
47163             return createJsxAttributesTypeFromAttributesProperty(node.parent, checkMode);
47164         }
47165         function getJsxType(name, location) {
47166             var namespace = getJsxNamespaceAt(location);
47167             var exports = namespace && getExportsOfSymbol(namespace);
47168             var typeSymbol = exports && getSymbol(exports, name, 788968);
47169             return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType;
47170         }
47171         function getIntrinsicTagSymbol(node) {
47172             var links = getNodeLinks(node);
47173             if (!links.resolvedSymbol) {
47174                 var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, node);
47175                 if (intrinsicElementsType !== errorType) {
47176                     if (!ts.isIdentifier(node.tagName))
47177                         return ts.Debug.fail();
47178                     var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.escapedText);
47179                     if (intrinsicProp) {
47180                         links.jsxFlags |= 1;
47181                         return links.resolvedSymbol = intrinsicProp;
47182                     }
47183                     var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0);
47184                     if (indexSignatureType) {
47185                         links.jsxFlags |= 2;
47186                         return links.resolvedSymbol = intrinsicElementsType.symbol;
47187                     }
47188                     error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.idText(node.tagName), "JSX." + JsxNames.IntrinsicElements);
47189                     return links.resolvedSymbol = unknownSymbol;
47190                 }
47191                 else {
47192                     if (noImplicitAny) {
47193                         error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, ts.unescapeLeadingUnderscores(JsxNames.IntrinsicElements));
47194                     }
47195                     return links.resolvedSymbol = unknownSymbol;
47196                 }
47197             }
47198             return links.resolvedSymbol;
47199         }
47200         function getJsxNamespaceAt(location) {
47201             var links = location && getNodeLinks(location);
47202             if (links && links.jsxNamespace) {
47203                 return links.jsxNamespace;
47204             }
47205             if (!links || links.jsxNamespace !== false) {
47206                 var namespaceName = getJsxNamespace(location);
47207                 var resolvedNamespace = resolveName(location, namespaceName, 1920, undefined, namespaceName, false);
47208                 if (resolvedNamespace) {
47209                     var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920));
47210                     if (candidate) {
47211                         if (links) {
47212                             links.jsxNamespace = candidate;
47213                         }
47214                         return candidate;
47215                     }
47216                     if (links) {
47217                         links.jsxNamespace = false;
47218                     }
47219                 }
47220             }
47221             return getGlobalSymbol(JsxNames.JSX, 1920, undefined);
47222         }
47223         function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) {
47224             var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968);
47225             var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym);
47226             var propertiesOfJsxElementAttribPropInterface = jsxElementAttribPropInterfaceType && getPropertiesOfType(jsxElementAttribPropInterfaceType);
47227             if (propertiesOfJsxElementAttribPropInterface) {
47228                 if (propertiesOfJsxElementAttribPropInterface.length === 0) {
47229                     return "";
47230                 }
47231                 else if (propertiesOfJsxElementAttribPropInterface.length === 1) {
47232                     return propertiesOfJsxElementAttribPropInterface[0].escapedName;
47233                 }
47234                 else if (propertiesOfJsxElementAttribPropInterface.length > 1) {
47235                     error(jsxElementAttribPropInterfaceSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, ts.unescapeLeadingUnderscores(nameOfAttribPropContainer));
47236                 }
47237             }
47238             return undefined;
47239         }
47240         function getJsxLibraryManagedAttributes(jsxNamespace) {
47241             return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968);
47242         }
47243         function getJsxElementPropertiesName(jsxNamespace) {
47244             return getNameFromJsxElementAttributesContainer(JsxNames.ElementAttributesPropertyNameContainer, jsxNamespace);
47245         }
47246         function getJsxElementChildrenPropertyName(jsxNamespace) {
47247             return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace);
47248         }
47249         function getUninstantiatedJsxSignaturesOfType(elementType, caller) {
47250             if (elementType.flags & 4) {
47251                 return [anySignature];
47252             }
47253             else if (elementType.flags & 128) {
47254                 var intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(elementType, caller);
47255                 if (!intrinsicType) {
47256                     error(caller, ts.Diagnostics.Property_0_does_not_exist_on_type_1, elementType.value, "JSX." + JsxNames.IntrinsicElements);
47257                     return ts.emptyArray;
47258                 }
47259                 else {
47260                     var fakeSignature = createSignatureForJSXIntrinsic(caller, intrinsicType);
47261                     return [fakeSignature];
47262                 }
47263             }
47264             var apparentElemType = getApparentType(elementType);
47265             var signatures = getSignaturesOfType(apparentElemType, 1);
47266             if (signatures.length === 0) {
47267                 signatures = getSignaturesOfType(apparentElemType, 0);
47268             }
47269             if (signatures.length === 0 && apparentElemType.flags & 1048576) {
47270                 signatures = getUnionSignatures(ts.map(apparentElemType.types, function (t) { return getUninstantiatedJsxSignaturesOfType(t, caller); }));
47271             }
47272             return signatures;
47273         }
47274         function getIntrinsicAttributesTypeFromStringLiteralType(type, location) {
47275             var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, location);
47276             if (intrinsicElementsType !== errorType) {
47277                 var stringLiteralTypeName = type.value;
47278                 var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName));
47279                 if (intrinsicProp) {
47280                     return getTypeOfSymbol(intrinsicProp);
47281                 }
47282                 var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0);
47283                 if (indexSignatureType) {
47284                     return indexSignatureType;
47285                 }
47286                 return undefined;
47287             }
47288             return anyType;
47289         }
47290         function checkJsxReturnAssignableToAppropriateBound(refKind, elemInstanceType, openingLikeElement) {
47291             if (refKind === 1) {
47292                 var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement);
47293                 if (sfcReturnConstraint) {
47294                     checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_return_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain);
47295                 }
47296             }
47297             else if (refKind === 0) {
47298                 var classConstraint = getJsxElementClassTypeAt(openingLikeElement);
47299                 if (classConstraint) {
47300                     checkTypeRelatedTo(elemInstanceType, classConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_instance_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain);
47301                 }
47302             }
47303             else {
47304                 var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement);
47305                 var classConstraint = getJsxElementClassTypeAt(openingLikeElement);
47306                 if (!sfcReturnConstraint || !classConstraint) {
47307                     return;
47308                 }
47309                 var combined = getUnionType([sfcReturnConstraint, classConstraint]);
47310                 checkTypeRelatedTo(elemInstanceType, combined, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_element_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain);
47311             }
47312             function generateInitialErrorChain() {
47313                 var componentName = ts.getTextOfNode(openingLikeElement.tagName);
47314                 return ts.chainDiagnosticMessages(undefined, ts.Diagnostics._0_cannot_be_used_as_a_JSX_component, componentName);
47315             }
47316         }
47317         function getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node) {
47318             ts.Debug.assert(isJsxIntrinsicIdentifier(node.tagName));
47319             var links = getNodeLinks(node);
47320             if (!links.resolvedJsxElementAttributesType) {
47321                 var symbol = getIntrinsicTagSymbol(node);
47322                 if (links.jsxFlags & 1) {
47323                     return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol);
47324                 }
47325                 else if (links.jsxFlags & 2) {
47326                     return links.resolvedJsxElementAttributesType =
47327                         getIndexTypeOfType(getDeclaredTypeOfSymbol(symbol), 0);
47328                 }
47329                 else {
47330                     return links.resolvedJsxElementAttributesType = errorType;
47331                 }
47332             }
47333             return links.resolvedJsxElementAttributesType;
47334         }
47335         function getJsxElementClassTypeAt(location) {
47336             var type = getJsxType(JsxNames.ElementClass, location);
47337             if (type === errorType)
47338                 return undefined;
47339             return type;
47340         }
47341         function getJsxElementTypeAt(location) {
47342             return getJsxType(JsxNames.Element, location);
47343         }
47344         function getJsxStatelessElementTypeAt(location) {
47345             var jsxElementType = getJsxElementTypeAt(location);
47346             if (jsxElementType) {
47347                 return getUnionType([jsxElementType, nullType]);
47348             }
47349         }
47350         function getJsxIntrinsicTagNamesAt(location) {
47351             var intrinsics = getJsxType(JsxNames.IntrinsicElements, location);
47352             return intrinsics ? getPropertiesOfType(intrinsics) : ts.emptyArray;
47353         }
47354         function checkJsxPreconditions(errorNode) {
47355             if ((compilerOptions.jsx || 0) === 0) {
47356                 error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided);
47357             }
47358             if (getJsxElementTypeAt(errorNode) === undefined) {
47359                 if (noImplicitAny) {
47360                     error(errorNode, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist);
47361                 }
47362             }
47363         }
47364         function checkJsxOpeningLikeElementOrOpeningFragment(node) {
47365             var isNodeOpeningLikeElement = ts.isJsxOpeningLikeElement(node);
47366             if (isNodeOpeningLikeElement) {
47367                 checkGrammarJsxElement(node);
47368             }
47369             checkJsxPreconditions(node);
47370             var reactRefErr = diagnostics && compilerOptions.jsx === 2 ? ts.Diagnostics.Cannot_find_name_0 : undefined;
47371             var reactNamespace = getJsxNamespace(node);
47372             var reactLocation = isNodeOpeningLikeElement ? node.tagName : node;
47373             var reactSym = resolveName(reactLocation, reactNamespace, 111551, reactRefErr, reactNamespace, true);
47374             if (reactSym) {
47375                 reactSym.isReferenced = 67108863;
47376                 if (reactSym.flags & 2097152 && !getTypeOnlyAliasDeclaration(reactSym)) {
47377                     markAliasSymbolAsReferenced(reactSym);
47378                 }
47379             }
47380             if (isNodeOpeningLikeElement) {
47381                 var jsxOpeningLikeNode = node;
47382                 var sig = getResolvedSignature(jsxOpeningLikeNode);
47383                 checkJsxReturnAssignableToAppropriateBound(getJsxReferenceKind(jsxOpeningLikeNode), getReturnTypeOfSignature(sig), jsxOpeningLikeNode);
47384             }
47385         }
47386         function isKnownProperty(targetType, name, isComparingJsxAttributes) {
47387             if (targetType.flags & 524288) {
47388                 var resolved = resolveStructuredTypeMembers(targetType);
47389                 if (resolved.stringIndexInfo ||
47390                     resolved.numberIndexInfo && isNumericLiteralName(name) ||
47391                     getPropertyOfObjectType(targetType, name) ||
47392                     isComparingJsxAttributes && !isUnhyphenatedJsxName(name)) {
47393                     return true;
47394                 }
47395             }
47396             else if (targetType.flags & 3145728 && isExcessPropertyCheckTarget(targetType)) {
47397                 for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) {
47398                     var t = _a[_i];
47399                     if (isKnownProperty(t, name, isComparingJsxAttributes)) {
47400                         return true;
47401                     }
47402                 }
47403             }
47404             return false;
47405         }
47406         function isExcessPropertyCheckTarget(type) {
47407             return !!(type.flags & 524288 && !(ts.getObjectFlags(type) & 512) ||
47408                 type.flags & 67108864 ||
47409                 type.flags & 1048576 && ts.some(type.types, isExcessPropertyCheckTarget) ||
47410                 type.flags & 2097152 && ts.every(type.types, isExcessPropertyCheckTarget));
47411         }
47412         function checkJsxExpression(node, checkMode) {
47413             checkGrammarJsxExpression(node);
47414             if (node.expression) {
47415                 var type = checkExpression(node.expression, checkMode);
47416                 if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) {
47417                     error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type);
47418                 }
47419                 return type;
47420             }
47421             else {
47422                 return errorType;
47423             }
47424         }
47425         function getDeclarationNodeFlagsFromSymbol(s) {
47426             return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0;
47427         }
47428         function isPrototypeProperty(symbol) {
47429             if (symbol.flags & 8192 || ts.getCheckFlags(symbol) & 4) {
47430                 return true;
47431             }
47432             if (ts.isInJSFile(symbol.valueDeclaration)) {
47433                 var parent = symbol.valueDeclaration.parent;
47434                 return parent && ts.isBinaryExpression(parent) &&
47435                     ts.getAssignmentDeclarationKind(parent) === 3;
47436             }
47437         }
47438         function checkPropertyAccessibility(node, isSuper, type, prop) {
47439             var flags = ts.getDeclarationModifierFlagsFromSymbol(prop);
47440             var errorNode = node.kind === 153 ? node.right : node.kind === 188 ? node : node.name;
47441             if (isSuper) {
47442                 if (languageVersion < 2) {
47443                     if (symbolHasNonMethodDeclaration(prop)) {
47444                         error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword);
47445                         return false;
47446                     }
47447                 }
47448                 if (flags & 128) {
47449                     error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop)));
47450                     return false;
47451                 }
47452             }
47453             if ((flags & 128) && ts.isThisProperty(node) && symbolHasNonMethodDeclaration(prop)) {
47454                 var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop));
47455                 if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(node)) {
47456                     error(errorNode, ts.Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor, symbolToString(prop), ts.getTextOfIdentifierOrLiteral(declaringClassDeclaration.name));
47457                     return false;
47458                 }
47459             }
47460             if (ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name)) {
47461                 if (!ts.getContainingClass(node)) {
47462                     error(errorNode, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
47463                     return false;
47464                 }
47465                 return true;
47466             }
47467             if (!(flags & 24)) {
47468                 return true;
47469             }
47470             if (flags & 8) {
47471                 var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop));
47472                 if (!isNodeWithinClass(node, declaringClassDeclaration)) {
47473                     error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop)));
47474                     return false;
47475                 }
47476                 return true;
47477             }
47478             if (isSuper) {
47479                 return true;
47480             }
47481             var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) {
47482                 var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration));
47483                 return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined;
47484             });
47485             if (!enclosingClass) {
47486                 var thisParameter = void 0;
47487                 if (flags & 32 || !(thisParameter = getThisParameterFromNodeContext(node)) || !thisParameter.type) {
47488                     error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type));
47489                     return false;
47490                 }
47491                 var thisType = getTypeFromTypeNode(thisParameter.type);
47492                 enclosingClass = ((thisType.flags & 262144) ? getConstraintOfTypeParameter(thisType) : thisType).target;
47493             }
47494             if (flags & 32) {
47495                 return true;
47496             }
47497             if (type.flags & 262144) {
47498                 type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type);
47499             }
47500             if (!type || !hasBaseType(type, enclosingClass)) {
47501                 error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass));
47502                 return false;
47503             }
47504             return true;
47505         }
47506         function getThisParameterFromNodeContext(node) {
47507             var thisContainer = ts.getThisContainer(node, false);
47508             return thisContainer && ts.isFunctionLike(thisContainer) ? ts.getThisParameter(thisContainer) : undefined;
47509         }
47510         function symbolHasNonMethodDeclaration(symbol) {
47511             return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192); });
47512         }
47513         function checkNonNullExpression(node) {
47514             return checkNonNullType(checkExpression(node), node);
47515         }
47516         function isNullableType(type) {
47517             return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304);
47518         }
47519         function getNonNullableTypeIfNeeded(type) {
47520             return isNullableType(type) ? getNonNullableType(type) : type;
47521         }
47522         function reportObjectPossiblyNullOrUndefinedError(node, flags) {
47523             error(node, flags & 32768 ? flags & 65536 ?
47524                 ts.Diagnostics.Object_is_possibly_null_or_undefined :
47525                 ts.Diagnostics.Object_is_possibly_undefined :
47526                 ts.Diagnostics.Object_is_possibly_null);
47527         }
47528         function reportCannotInvokePossiblyNullOrUndefinedError(node, flags) {
47529             error(node, flags & 32768 ? flags & 65536 ?
47530                 ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined :
47531                 ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined :
47532                 ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null);
47533         }
47534         function checkNonNullTypeWithReporter(type, node, reportError) {
47535             if (strictNullChecks && type.flags & 2) {
47536                 error(node, ts.Diagnostics.Object_is_of_type_unknown);
47537                 return errorType;
47538             }
47539             var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304;
47540             if (kind) {
47541                 reportError(node, kind);
47542                 var t = getNonNullableType(type);
47543                 return t.flags & (98304 | 131072) ? errorType : t;
47544             }
47545             return type;
47546         }
47547         function checkNonNullType(type, node) {
47548             return checkNonNullTypeWithReporter(type, node, reportObjectPossiblyNullOrUndefinedError);
47549         }
47550         function checkNonNullNonVoidType(type, node) {
47551             var nonNullType = checkNonNullType(type, node);
47552             if (nonNullType !== errorType && nonNullType.flags & 16384) {
47553                 error(node, ts.Diagnostics.Object_is_possibly_undefined);
47554             }
47555             return nonNullType;
47556         }
47557         function checkPropertyAccessExpression(node) {
47558             return node.flags & 32 ? checkPropertyAccessChain(node) :
47559                 checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name);
47560         }
47561         function checkPropertyAccessChain(node) {
47562             var leftType = checkExpression(node.expression);
47563             var nonOptionalType = getOptionalExpressionType(leftType, node.expression);
47564             return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), node, nonOptionalType !== leftType);
47565         }
47566         function checkQualifiedName(node) {
47567             return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right);
47568         }
47569         function isMethodAccessForCall(node) {
47570             while (node.parent.kind === 200) {
47571                 node = node.parent;
47572             }
47573             return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node;
47574         }
47575         function lookupSymbolForPrivateIdentifierDeclaration(propName, location) {
47576             for (var containingClass = ts.getContainingClass(location); !!containingClass; containingClass = ts.getContainingClass(containingClass)) {
47577                 var symbol = containingClass.symbol;
47578                 var name = ts.getSymbolNameForPrivateIdentifier(symbol, propName);
47579                 var prop = (symbol.members && symbol.members.get(name)) || (symbol.exports && symbol.exports.get(name));
47580                 if (prop) {
47581                     return prop;
47582                 }
47583             }
47584         }
47585         function getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) {
47586             return getPropertyOfType(leftType, lexicallyScopedIdentifier.escapedName);
47587         }
47588         function checkPrivateIdentifierPropertyAccess(leftType, right, lexicallyScopedIdentifier) {
47589             var propertyOnType;
47590             var properties = getPropertiesOfType(leftType);
47591             if (properties) {
47592                 ts.forEach(properties, function (symbol) {
47593                     var decl = symbol.valueDeclaration;
47594                     if (decl && ts.isNamedDeclaration(decl) && ts.isPrivateIdentifier(decl.name) && decl.name.escapedText === right.escapedText) {
47595                         propertyOnType = symbol;
47596                         return true;
47597                     }
47598                 });
47599             }
47600             var diagName = diagnosticName(right);
47601             if (propertyOnType) {
47602                 var typeValueDecl = propertyOnType.valueDeclaration;
47603                 var typeClass_1 = ts.getContainingClass(typeValueDecl);
47604                 ts.Debug.assert(!!typeClass_1);
47605                 if (lexicallyScopedIdentifier) {
47606                     var lexicalValueDecl = lexicallyScopedIdentifier.valueDeclaration;
47607                     var lexicalClass = ts.getContainingClass(lexicalValueDecl);
47608                     ts.Debug.assert(!!lexicalClass);
47609                     if (ts.findAncestor(lexicalClass, function (n) { return typeClass_1 === n; })) {
47610                         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));
47611                         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));
47612                         return true;
47613                     }
47614                 }
47615                 error(right, ts.Diagnostics.Property_0_is_not_accessible_outside_class_1_because_it_has_a_private_identifier, diagName, diagnosticName(typeClass_1.name || anon));
47616                 return true;
47617             }
47618             return false;
47619         }
47620         function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) {
47621             var parentSymbol = getNodeLinks(left).resolvedSymbol;
47622             var assignmentKind = ts.getAssignmentTargetKind(node);
47623             var apparentType = getApparentType(assignmentKind !== 0 || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType);
47624             if (ts.isPrivateIdentifier(right)) {
47625                 checkExternalEmitHelpers(node, 262144);
47626             }
47627             var isAnyLike = isTypeAny(apparentType) || apparentType === silentNeverType;
47628             var prop;
47629             if (ts.isPrivateIdentifier(right)) {
47630                 var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right);
47631                 if (isAnyLike) {
47632                     if (lexicallyScopedSymbol) {
47633                         return apparentType;
47634                     }
47635                     if (!ts.getContainingClass(right)) {
47636                         grammarErrorOnNode(right, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
47637                         return anyType;
47638                     }
47639                 }
47640                 prop = lexicallyScopedSymbol ? getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedSymbol) : undefined;
47641                 if (!prop && checkPrivateIdentifierPropertyAccess(leftType, right, lexicallyScopedSymbol)) {
47642                     return errorType;
47643                 }
47644             }
47645             else {
47646                 if (isAnyLike) {
47647                     if (ts.isIdentifier(left) && parentSymbol) {
47648                         markAliasReferenced(parentSymbol, node);
47649                     }
47650                     return apparentType;
47651                 }
47652                 prop = getPropertyOfType(apparentType, right.escapedText);
47653             }
47654             if (ts.isIdentifier(left) && parentSymbol && !(prop && isConstEnumOrConstEnumOnlyModule(prop))) {
47655                 markAliasReferenced(parentSymbol, node);
47656             }
47657             var propType;
47658             if (!prop) {
47659                 var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 || !isGenericObjectType(leftType) || isThisTypeParameter(leftType)) ? getIndexInfoOfType(apparentType, 0) : undefined;
47660                 if (!(indexInfo && indexInfo.type)) {
47661                     if (isJSLiteralType(leftType)) {
47662                         return anyType;
47663                     }
47664                     if (leftType.symbol === globalThisSymbol) {
47665                         if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418)) {
47666                             error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(right.escapedText), typeToString(leftType));
47667                         }
47668                         else if (noImplicitAny) {
47669                             error(right, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(leftType));
47670                         }
47671                         return anyType;
47672                     }
47673                     if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) {
47674                         reportNonexistentProperty(right, isThisTypeParameter(leftType) ? apparentType : leftType);
47675                     }
47676                     return errorType;
47677                 }
47678                 if (indexInfo.isReadonly && (ts.isAssignmentTarget(node) || ts.isDeleteTarget(node))) {
47679                     error(node, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(apparentType));
47680                 }
47681                 propType = indexInfo.type;
47682             }
47683             else {
47684                 checkPropertyNotUsedBeforeDeclaration(prop, node, right);
47685                 markPropertyAsReferenced(prop, node, left.kind === 104);
47686                 getNodeLinks(node).resolvedSymbol = prop;
47687                 checkPropertyAccessibility(node, left.kind === 102, apparentType, prop);
47688                 if (isAssignmentToReadonlyEntity(node, prop, assignmentKind)) {
47689                     error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right));
47690                     return errorType;
47691                 }
47692                 propType = getConstraintForLocation(getTypeOfSymbol(prop), node);
47693             }
47694             return getFlowTypeOfAccessExpression(node, prop, propType, right);
47695         }
47696         function getFlowTypeOfAccessExpression(node, prop, propType, errorNode) {
47697             var assignmentKind = ts.getAssignmentTargetKind(node);
47698             if (!ts.isAccessExpression(node) ||
47699                 assignmentKind === 1 ||
47700                 prop && !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 1048576)) {
47701                 return propType;
47702             }
47703             var assumeUninitialized = false;
47704             if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 104) {
47705                 var declaration = prop && prop.valueDeclaration;
47706                 if (declaration && isInstancePropertyWithoutInitializer(declaration)) {
47707                     var flowContainer = getControlFlowContainer(node);
47708                     if (flowContainer.kind === 162 && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608)) {
47709                         assumeUninitialized = true;
47710                     }
47711                 }
47712             }
47713             else if (strictNullChecks && prop && prop.valueDeclaration &&
47714                 ts.isPropertyAccessExpression(prop.valueDeclaration) &&
47715                 ts.getAssignmentDeclarationPropertyAccessKind(prop.valueDeclaration) &&
47716                 getControlFlowContainer(node) === getControlFlowContainer(prop.valueDeclaration)) {
47717                 assumeUninitialized = true;
47718             }
47719             var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType);
47720             if (assumeUninitialized && !(getFalsyFlags(propType) & 32768) && getFalsyFlags(flowType) & 32768) {
47721                 error(errorNode, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop));
47722                 return propType;
47723             }
47724             return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
47725         }
47726         function checkPropertyNotUsedBeforeDeclaration(prop, node, right) {
47727             var valueDeclaration = prop.valueDeclaration;
47728             if (!valueDeclaration || ts.getSourceFileOfNode(node).isDeclarationFile) {
47729                 return;
47730             }
47731             var diagnosticMessage;
47732             var declarationName = ts.idText(right);
47733             if (isInPropertyInitializer(node)
47734                 && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression))
47735                 && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)
47736                 && !isPropertyDeclaredInAncestorClass(prop)) {
47737                 diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName);
47738             }
47739             else if (valueDeclaration.kind === 245 &&
47740                 node.parent.kind !== 169 &&
47741                 !(valueDeclaration.flags & 8388608) &&
47742                 !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) {
47743                 diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
47744             }
47745             if (diagnosticMessage) {
47746                 ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(valueDeclaration, ts.Diagnostics._0_is_declared_here, declarationName));
47747             }
47748         }
47749         function isInPropertyInitializer(node) {
47750             return !!ts.findAncestor(node, function (node) {
47751                 switch (node.kind) {
47752                     case 159:
47753                         return true;
47754                     case 281:
47755                     case 161:
47756                     case 163:
47757                     case 164:
47758                     case 283:
47759                     case 154:
47760                     case 221:
47761                     case 276:
47762                     case 273:
47763                     case 274:
47764                     case 275:
47765                     case 268:
47766                     case 216:
47767                     case 279:
47768                         return false;
47769                     default:
47770                         return ts.isExpressionNode(node) ? false : "quit";
47771                 }
47772             });
47773         }
47774         function isPropertyDeclaredInAncestorClass(prop) {
47775             if (!(prop.parent.flags & 32)) {
47776                 return false;
47777             }
47778             var classType = getTypeOfSymbol(prop.parent);
47779             while (true) {
47780                 classType = classType.symbol && getSuperClass(classType);
47781                 if (!classType) {
47782                     return false;
47783                 }
47784                 var superProperty = getPropertyOfType(classType, prop.escapedName);
47785                 if (superProperty && superProperty.valueDeclaration) {
47786                     return true;
47787                 }
47788             }
47789         }
47790         function getSuperClass(classType) {
47791             var x = getBaseTypes(classType);
47792             if (x.length === 0) {
47793                 return undefined;
47794             }
47795             return getIntersectionType(x);
47796         }
47797         function reportNonexistentProperty(propNode, containingType) {
47798             var errorInfo;
47799             var relatedInfo;
47800             if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 && !(containingType.flags & 131068)) {
47801                 for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) {
47802                     var subtype = _a[_i];
47803                     if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0)) {
47804                         errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype));
47805                         break;
47806                     }
47807                 }
47808             }
47809             if (typeHasStaticProperty(propNode.escapedText, containingType)) {
47810                 errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_is_a_static_member_of_type_1, ts.declarationNameToString(propNode), typeToString(containingType));
47811             }
47812             else {
47813                 var promisedType = getPromisedTypeOfPromise(containingType);
47814                 if (promisedType && getPropertyOfType(promisedType, propNode.escapedText)) {
47815                     errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType));
47816                     relatedInfo = ts.createDiagnosticForNode(propNode, ts.Diagnostics.Did_you_forget_to_use_await);
47817                 }
47818                 else {
47819                     var suggestion = getSuggestedSymbolForNonexistentProperty(propNode, containingType);
47820                     if (suggestion !== undefined) {
47821                         var suggestedName = ts.symbolName(suggestion);
47822                         errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestedName);
47823                         relatedInfo = suggestion.valueDeclaration && ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestedName);
47824                     }
47825                     else {
47826                         errorInfo = ts.chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType));
47827                     }
47828                 }
47829             }
47830             var resultDiagnostic = ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo);
47831             if (relatedInfo) {
47832                 ts.addRelatedInfo(resultDiagnostic, relatedInfo);
47833             }
47834             diagnostics.add(resultDiagnostic);
47835         }
47836         function typeHasStaticProperty(propName, containingType) {
47837             var prop = containingType.symbol && getPropertyOfType(getTypeOfSymbol(containingType.symbol), propName);
47838             return prop !== undefined && prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 32);
47839         }
47840         function getSuggestedSymbolForNonexistentProperty(name, containingType) {
47841             return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551);
47842         }
47843         function getSuggestionForNonexistentProperty(name, containingType) {
47844             var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType);
47845             return suggestion && ts.symbolName(suggestion);
47846         }
47847         function getSuggestedSymbolForNonexistentSymbol(location, outerName, meaning) {
47848             ts.Debug.assert(outerName !== undefined, "outername should always be defined");
47849             var result = resolveNameHelper(location, outerName, meaning, undefined, outerName, false, false, function (symbols, name, meaning) {
47850                 ts.Debug.assertEqual(outerName, name, "name should equal outerName");
47851                 var symbol = getSymbol(symbols, name, meaning);
47852                 return symbol || getSpellingSuggestionForName(ts.unescapeLeadingUnderscores(name), ts.arrayFrom(symbols.values()), meaning);
47853             });
47854             return result;
47855         }
47856         function getSuggestionForNonexistentSymbol(location, outerName, meaning) {
47857             var symbolResult = getSuggestedSymbolForNonexistentSymbol(location, outerName, meaning);
47858             return symbolResult && ts.symbolName(symbolResult);
47859         }
47860         function getSuggestedSymbolForNonexistentModule(name, targetModule) {
47861             return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475);
47862         }
47863         function getSuggestionForNonexistentExport(name, targetModule) {
47864             var suggestion = getSuggestedSymbolForNonexistentModule(name, targetModule);
47865             return suggestion && ts.symbolName(suggestion);
47866         }
47867         function getSuggestionForNonexistentIndexSignature(objectType, expr, keyedType) {
47868             function hasProp(name) {
47869                 var prop = getPropertyOfObjectType(objectType, name);
47870                 if (prop) {
47871                     var s = getSingleCallSignature(getTypeOfSymbol(prop));
47872                     return !!s && getMinArgumentCount(s) >= 1 && isTypeAssignableTo(keyedType, getTypeAtPosition(s, 0));
47873                 }
47874                 return false;
47875             }
47876             ;
47877             var suggestedMethod = ts.isAssignmentTarget(expr) ? "set" : "get";
47878             if (!hasProp(suggestedMethod)) {
47879                 return undefined;
47880             }
47881             var suggestion = ts.tryGetPropertyAccessOrIdentifierToString(expr.expression);
47882             if (suggestion === undefined) {
47883                 suggestion = suggestedMethod;
47884             }
47885             else {
47886                 suggestion += "." + suggestedMethod;
47887             }
47888             return suggestion;
47889         }
47890         function getSpellingSuggestionForName(name, symbols, meaning) {
47891             return ts.getSpellingSuggestion(name, symbols, getCandidateName);
47892             function getCandidateName(candidate) {
47893                 var candidateName = ts.symbolName(candidate);
47894                 if (ts.startsWith(candidateName, "\"")) {
47895                     return undefined;
47896                 }
47897                 if (candidate.flags & meaning) {
47898                     return candidateName;
47899                 }
47900                 if (candidate.flags & 2097152) {
47901                     var alias = tryResolveAlias(candidate);
47902                     if (alias && alias.flags & meaning) {
47903                         return candidateName;
47904                     }
47905                 }
47906                 return undefined;
47907             }
47908         }
47909         function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isThisAccess) {
47910             var valueDeclaration = prop && (prop.flags & 106500) && prop.valueDeclaration;
47911             if (!valueDeclaration) {
47912                 return;
47913             }
47914             var hasPrivateModifier = ts.hasModifier(valueDeclaration, 8);
47915             var hasPrivateIdentifier = ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name);
47916             if (!hasPrivateModifier && !hasPrivateIdentifier) {
47917                 return;
47918             }
47919             if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536)) {
47920                 return;
47921             }
47922             if (isThisAccess) {
47923                 var containingMethod = ts.findAncestor(nodeForCheckWriteOnly, ts.isFunctionLikeDeclaration);
47924                 if (containingMethod && containingMethod.symbol === prop) {
47925                     return;
47926                 }
47927             }
47928             (ts.getCheckFlags(prop) & 1 ? getSymbolLinks(prop).target : prop).isReferenced = 67108863;
47929         }
47930         function isValidPropertyAccess(node, propertyName) {
47931             switch (node.kind) {
47932                 case 194:
47933                     return isValidPropertyAccessWithType(node, node.expression.kind === 102, propertyName, getWidenedType(checkExpression(node.expression)));
47934                 case 153:
47935                     return isValidPropertyAccessWithType(node, false, propertyName, getWidenedType(checkExpression(node.left)));
47936                 case 188:
47937                     return isValidPropertyAccessWithType(node, false, propertyName, getTypeFromTypeNode(node));
47938             }
47939         }
47940         function isValidPropertyAccessForCompletions(node, type, property) {
47941             return isValidPropertyAccessWithType(node, node.kind === 194 && node.expression.kind === 102, property.escapedName, type);
47942         }
47943         function isValidPropertyAccessWithType(node, isSuper, propertyName, type) {
47944             if (type === errorType || isTypeAny(type)) {
47945                 return true;
47946             }
47947             var prop = getPropertyOfType(type, propertyName);
47948             if (prop) {
47949                 if (ts.isPropertyAccessExpression(node) && prop.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(prop.valueDeclaration)) {
47950                     var declClass_1 = ts.getContainingClass(prop.valueDeclaration);
47951                     return !ts.isOptionalChain(node) && !!ts.findAncestor(node, function (parent) { return parent === declClass_1; });
47952                 }
47953                 return checkPropertyAccessibility(node, isSuper, type, prop);
47954             }
47955             return ts.isInJSFile(node) && (type.flags & 1048576) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); });
47956         }
47957         function getForInVariableSymbol(node) {
47958             var initializer = node.initializer;
47959             if (initializer.kind === 243) {
47960                 var variable = initializer.declarations[0];
47961                 if (variable && !ts.isBindingPattern(variable.name)) {
47962                     return getSymbolOfNode(variable);
47963                 }
47964             }
47965             else if (initializer.kind === 75) {
47966                 return getResolvedSymbol(initializer);
47967             }
47968             return undefined;
47969         }
47970         function hasNumericPropertyNames(type) {
47971             return getIndexTypeOfType(type, 1) && !getIndexTypeOfType(type, 0);
47972         }
47973         function isForInVariableForNumericPropertyNames(expr) {
47974             var e = ts.skipParentheses(expr);
47975             if (e.kind === 75) {
47976                 var symbol = getResolvedSymbol(e);
47977                 if (symbol.flags & 3) {
47978                     var child = expr;
47979                     var node = expr.parent;
47980                     while (node) {
47981                         if (node.kind === 231 &&
47982                             child === node.statement &&
47983                             getForInVariableSymbol(node) === symbol &&
47984                             hasNumericPropertyNames(getTypeOfExpression(node.expression))) {
47985                             return true;
47986                         }
47987                         child = node;
47988                         node = node.parent;
47989                     }
47990                 }
47991             }
47992             return false;
47993         }
47994         function checkIndexedAccess(node) {
47995             return node.flags & 32 ? checkElementAccessChain(node) :
47996                 checkElementAccessExpression(node, checkNonNullExpression(node.expression));
47997         }
47998         function checkElementAccessChain(node) {
47999             var exprType = checkExpression(node.expression);
48000             var nonOptionalType = getOptionalExpressionType(exprType, node.expression);
48001             return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), node, nonOptionalType !== exprType);
48002         }
48003         function checkElementAccessExpression(node, exprType) {
48004             var objectType = ts.getAssignmentTargetKind(node) !== 0 || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType;
48005             var indexExpression = node.argumentExpression;
48006             var indexType = checkExpression(indexExpression);
48007             if (objectType === errorType || objectType === silentNeverType) {
48008                 return objectType;
48009             }
48010             if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) {
48011                 error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal);
48012                 return errorType;
48013             }
48014             var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType;
48015             var accessFlags = ts.isAssignmentTarget(node) ?
48016                 2 | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 : 0) :
48017                 0;
48018             var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, node, accessFlags) || errorType;
48019             return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node);
48020         }
48021         function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) {
48022             if (expressionType === errorType) {
48023                 return false;
48024             }
48025             if (!ts.isWellKnownSymbolSyntactically(expression)) {
48026                 return false;
48027             }
48028             if ((expressionType.flags & 12288) === 0) {
48029                 if (reportError) {
48030                     error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression));
48031                 }
48032                 return false;
48033             }
48034             var leftHandSide = expression.expression;
48035             var leftHandSideSymbol = getResolvedSymbol(leftHandSide);
48036             if (!leftHandSideSymbol) {
48037                 return false;
48038             }
48039             var globalESSymbol = getGlobalESSymbolConstructorSymbol(true);
48040             if (!globalESSymbol) {
48041                 return false;
48042             }
48043             if (leftHandSideSymbol !== globalESSymbol) {
48044                 if (reportError) {
48045                     error(leftHandSide, ts.Diagnostics.Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object);
48046                 }
48047                 return false;
48048             }
48049             return true;
48050         }
48051         function callLikeExpressionMayHaveTypeArguments(node) {
48052             return ts.isCallOrNewExpression(node) || ts.isTaggedTemplateExpression(node) || ts.isJsxOpeningLikeElement(node);
48053         }
48054         function resolveUntypedCall(node) {
48055             if (callLikeExpressionMayHaveTypeArguments(node)) {
48056                 ts.forEach(node.typeArguments, checkSourceElement);
48057             }
48058             if (node.kind === 198) {
48059                 checkExpression(node.template);
48060             }
48061             else if (ts.isJsxOpeningLikeElement(node)) {
48062                 checkExpression(node.attributes);
48063             }
48064             else if (node.kind !== 157) {
48065                 ts.forEach(node.arguments, function (argument) {
48066                     checkExpression(argument);
48067                 });
48068             }
48069             return anySignature;
48070         }
48071         function resolveErrorCall(node) {
48072             resolveUntypedCall(node);
48073             return unknownSignature;
48074         }
48075         function reorderCandidates(signatures, result, callChainFlags) {
48076             var lastParent;
48077             var lastSymbol;
48078             var cutoffIndex = 0;
48079             var index;
48080             var specializedIndex = -1;
48081             var spliceIndex;
48082             ts.Debug.assert(!result.length);
48083             for (var _i = 0, signatures_7 = signatures; _i < signatures_7.length; _i++) {
48084                 var signature = signatures_7[_i];
48085                 var symbol = signature.declaration && getSymbolOfNode(signature.declaration);
48086                 var parent = signature.declaration && signature.declaration.parent;
48087                 if (!lastSymbol || symbol === lastSymbol) {
48088                     if (lastParent && parent === lastParent) {
48089                         index = index + 1;
48090                     }
48091                     else {
48092                         lastParent = parent;
48093                         index = cutoffIndex;
48094                     }
48095                 }
48096                 else {
48097                     index = cutoffIndex = result.length;
48098                     lastParent = parent;
48099                 }
48100                 lastSymbol = symbol;
48101                 if (signatureHasLiteralTypes(signature)) {
48102                     specializedIndex++;
48103                     spliceIndex = specializedIndex;
48104                     cutoffIndex++;
48105                 }
48106                 else {
48107                     spliceIndex = index;
48108                 }
48109                 result.splice(spliceIndex, 0, callChainFlags ? getOptionalCallSignature(signature, callChainFlags) : signature);
48110             }
48111         }
48112         function isSpreadArgument(arg) {
48113             return !!arg && (arg.kind === 213 || arg.kind === 220 && arg.isSpread);
48114         }
48115         function getSpreadArgumentIndex(args) {
48116             return ts.findIndex(args, isSpreadArgument);
48117         }
48118         function acceptsVoid(t) {
48119             return !!(t.flags & 16384);
48120         }
48121         function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) {
48122             if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; }
48123             var argCount;
48124             var callIsIncomplete = false;
48125             var effectiveParameterCount = getParameterCount(signature);
48126             var effectiveMinimumArguments = getMinArgumentCount(signature);
48127             if (node.kind === 198) {
48128                 argCount = args.length;
48129                 if (node.template.kind === 211) {
48130                     var lastSpan = ts.last(node.template.templateSpans);
48131                     callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated;
48132                 }
48133                 else {
48134                     var templateLiteral = node.template;
48135                     ts.Debug.assert(templateLiteral.kind === 14);
48136                     callIsIncomplete = !!templateLiteral.isUnterminated;
48137                 }
48138             }
48139             else if (node.kind === 157) {
48140                 argCount = getDecoratorArgumentCount(node, signature);
48141             }
48142             else if (ts.isJsxOpeningLikeElement(node)) {
48143                 callIsIncomplete = node.attributes.end === node.end;
48144                 if (callIsIncomplete) {
48145                     return true;
48146                 }
48147                 argCount = effectiveMinimumArguments === 0 ? args.length : 1;
48148                 effectiveParameterCount = args.length === 0 ? effectiveParameterCount : 1;
48149                 effectiveMinimumArguments = Math.min(effectiveMinimumArguments, 1);
48150             }
48151             else {
48152                 if (!node.arguments) {
48153                     ts.Debug.assert(node.kind === 197);
48154                     return getMinArgumentCount(signature) === 0;
48155                 }
48156                 argCount = signatureHelpTrailingComma ? args.length + 1 : args.length;
48157                 callIsIncomplete = node.arguments.end === node.end;
48158                 var spreadArgIndex = getSpreadArgumentIndex(args);
48159                 if (spreadArgIndex >= 0) {
48160                     return spreadArgIndex >= getMinArgumentCount(signature) && (hasEffectiveRestParameter(signature) || spreadArgIndex < getParameterCount(signature));
48161                 }
48162             }
48163             if (!hasEffectiveRestParameter(signature) && argCount > effectiveParameterCount) {
48164                 return false;
48165             }
48166             if (callIsIncomplete || argCount >= effectiveMinimumArguments) {
48167                 return true;
48168             }
48169             for (var i = argCount; i < effectiveMinimumArguments; i++) {
48170                 var type = getTypeAtPosition(signature, i);
48171                 if (filterType(type, acceptsVoid).flags & 131072) {
48172                     return false;
48173                 }
48174             }
48175             return true;
48176         }
48177         function hasCorrectTypeArgumentArity(signature, typeArguments) {
48178             var numTypeParameters = ts.length(signature.typeParameters);
48179             var minTypeArgumentCount = getMinTypeArgumentCount(signature.typeParameters);
48180             return !ts.some(typeArguments) ||
48181                 (typeArguments.length >= minTypeArgumentCount && typeArguments.length <= numTypeParameters);
48182         }
48183         function getSingleCallSignature(type) {
48184             return getSingleSignature(type, 0, false);
48185         }
48186         function getSingleCallOrConstructSignature(type) {
48187             return getSingleSignature(type, 0, false) ||
48188                 getSingleSignature(type, 1, false);
48189         }
48190         function getSingleSignature(type, kind, allowMembers) {
48191             if (type.flags & 524288) {
48192                 var resolved = resolveStructuredTypeMembers(type);
48193                 if (allowMembers || resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) {
48194                     if (kind === 0 && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) {
48195                         return resolved.callSignatures[0];
48196                     }
48197                     if (kind === 1 && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) {
48198                         return resolved.constructSignatures[0];
48199                     }
48200                 }
48201             }
48202             return undefined;
48203         }
48204         function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext, compareTypes) {
48205             var context = createInferenceContext(signature.typeParameters, signature, 0, compareTypes);
48206             var restType = getEffectiveRestType(contextualSignature);
48207             var mapper = inferenceContext && (restType && restType.flags & 262144 ? inferenceContext.nonFixingMapper : inferenceContext.mapper);
48208             var sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature;
48209             applyToParameterTypes(sourceSignature, signature, function (source, target) {
48210                 inferTypes(context.inferences, source, target);
48211             });
48212             if (!inferenceContext) {
48213                 applyToReturnTypes(contextualSignature, signature, function (source, target) {
48214                     inferTypes(context.inferences, source, target, 32);
48215                 });
48216             }
48217             return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration));
48218         }
48219         function inferJsxTypeArguments(node, signature, checkMode, context) {
48220             var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node);
48221             var checkAttrType = checkExpressionWithContextualType(node.attributes, paramType, context, checkMode);
48222             inferTypes(context.inferences, checkAttrType, paramType);
48223             return getInferredTypes(context);
48224         }
48225         function inferTypeArguments(node, signature, args, checkMode, context) {
48226             if (ts.isJsxOpeningLikeElement(node)) {
48227                 return inferJsxTypeArguments(node, signature, checkMode, context);
48228             }
48229             if (node.kind !== 157) {
48230                 var contextualType = getContextualType(node);
48231                 if (contextualType) {
48232                     var outerContext = getInferenceContext(node);
48233                     var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1));
48234                     var instantiatedType = instantiateType(contextualType, outerMapper);
48235                     var contextualSignature = getSingleCallSignature(instantiatedType);
48236                     var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
48237                         getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
48238                         instantiatedType;
48239                     var inferenceTargetType = getReturnTypeOfSignature(signature);
48240                     inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 32);
48241                     var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
48242                     var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
48243                     inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
48244                     context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined;
48245                 }
48246             }
48247             var thisType = getThisTypeOfSignature(signature);
48248             if (thisType) {
48249                 var thisArgumentNode = getThisArgumentOfCall(node);
48250                 var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType;
48251                 inferTypes(context.inferences, thisArgumentType, thisType);
48252             }
48253             var restType = getNonArrayRestType(signature);
48254             var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length;
48255             for (var i = 0; i < argCount; i++) {
48256                 var arg = args[i];
48257                 if (arg.kind !== 215) {
48258                     var paramType = getTypeAtPosition(signature, i);
48259                     var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
48260                     inferTypes(context.inferences, argType, paramType);
48261                 }
48262             }
48263             if (restType) {
48264                 var spreadType = getSpreadArgumentType(args, argCount, args.length, restType, context);
48265                 inferTypes(context.inferences, spreadType, restType);
48266             }
48267             return getInferredTypes(context);
48268         }
48269         function getArrayifiedType(type) {
48270             return type.flags & 1048576 ? mapType(type, getArrayifiedType) :
48271                 type.flags & (1 | 63176704) || isMutableArrayOrTuple(type) ? type :
48272                     isTupleType(type) ? createTupleType(getTypeArguments(type), type.target.minLength, type.target.hasRestElement, false, type.target.associatedNames) :
48273                         createArrayType(getIndexedAccessType(type, numberType));
48274         }
48275         function getSpreadArgumentType(args, index, argCount, restType, context) {
48276             if (index >= argCount - 1) {
48277                 var arg = args[argCount - 1];
48278                 if (isSpreadArgument(arg)) {
48279                     return arg.kind === 220 ?
48280                         createArrayType(arg.type) :
48281                         getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context, 0));
48282                 }
48283             }
48284             var types = [];
48285             var spreadIndex = -1;
48286             for (var i = index; i < argCount; i++) {
48287                 var contextualType = getIndexedAccessType(restType, getLiteralType(i - index));
48288                 var argType = checkExpressionWithContextualType(args[i], contextualType, context, 0);
48289                 if (spreadIndex < 0 && isSpreadArgument(args[i])) {
48290                     spreadIndex = i - index;
48291                 }
48292                 var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 | 4194304);
48293                 types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType));
48294             }
48295             return spreadIndex < 0 ?
48296                 createTupleType(types) :
48297                 createTupleType(ts.append(types.slice(0, spreadIndex), getUnionType(types.slice(spreadIndex))), spreadIndex, true);
48298         }
48299         function checkTypeArguments(signature, typeArgumentNodes, reportErrors, headMessage) {
48300             var isJavascript = ts.isInJSFile(signature.declaration);
48301             var typeParameters = signature.typeParameters;
48302             var typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), isJavascript);
48303             var mapper;
48304             for (var i = 0; i < typeArgumentNodes.length; i++) {
48305                 ts.Debug.assert(typeParameters[i] !== undefined, "Should not call checkTypeArguments with too many type arguments");
48306                 var constraint = getConstraintOfTypeParameter(typeParameters[i]);
48307                 if (constraint) {
48308                     var errorInfo = reportErrors && headMessage ? (function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); }) : undefined;
48309                     var typeArgumentHeadMessage = headMessage || ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1;
48310                     if (!mapper) {
48311                         mapper = createTypeMapper(typeParameters, typeArgumentTypes);
48312                     }
48313                     var typeArgument = typeArgumentTypes[i];
48314                     if (!checkTypeAssignableTo(typeArgument, getTypeWithThisArgument(instantiateType(constraint, mapper), typeArgument), reportErrors ? typeArgumentNodes[i] : undefined, typeArgumentHeadMessage, errorInfo)) {
48315                         return undefined;
48316                     }
48317                 }
48318             }
48319             return typeArgumentTypes;
48320         }
48321         function getJsxReferenceKind(node) {
48322             if (isJsxIntrinsicIdentifier(node.tagName)) {
48323                 return 2;
48324             }
48325             var tagType = getApparentType(checkExpression(node.tagName));
48326             if (ts.length(getSignaturesOfType(tagType, 1))) {
48327                 return 0;
48328             }
48329             if (ts.length(getSignaturesOfType(tagType, 0))) {
48330                 return 1;
48331             }
48332             return 2;
48333         }
48334         function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer) {
48335             var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node);
48336             var attributesType = checkExpressionWithContextualType(node.attributes, paramType, undefined, checkMode);
48337             return checkTagNameDoesNotExpectTooManyArguments() && checkTypeRelatedToAndOptionallyElaborate(attributesType, paramType, relation, reportErrors ? node.tagName : undefined, node.attributes, undefined, containingMessageChain, errorOutputContainer);
48338             function checkTagNameDoesNotExpectTooManyArguments() {
48339                 var _a;
48340                 var tagType = ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node) && !isJsxIntrinsicIdentifier(node.tagName) ? checkExpression(node.tagName) : undefined;
48341                 if (!tagType) {
48342                     return true;
48343                 }
48344                 var tagCallSignatures = getSignaturesOfType(tagType, 0);
48345                 if (!ts.length(tagCallSignatures)) {
48346                     return true;
48347                 }
48348                 var factory = getJsxFactoryEntity(node);
48349                 if (!factory) {
48350                     return true;
48351                 }
48352                 var factorySymbol = resolveEntityName(factory, 111551, true, false, node);
48353                 if (!factorySymbol) {
48354                     return true;
48355                 }
48356                 var factoryType = getTypeOfSymbol(factorySymbol);
48357                 var callSignatures = getSignaturesOfType(factoryType, 0);
48358                 if (!ts.length(callSignatures)) {
48359                     return true;
48360                 }
48361                 var hasFirstParamSignatures = false;
48362                 var maxParamCount = 0;
48363                 for (var _i = 0, callSignatures_1 = callSignatures; _i < callSignatures_1.length; _i++) {
48364                     var sig = callSignatures_1[_i];
48365                     var firstparam = getTypeAtPosition(sig, 0);
48366                     var signaturesOfParam = getSignaturesOfType(firstparam, 0);
48367                     if (!ts.length(signaturesOfParam))
48368                         continue;
48369                     for (var _b = 0, signaturesOfParam_1 = signaturesOfParam; _b < signaturesOfParam_1.length; _b++) {
48370                         var paramSig = signaturesOfParam_1[_b];
48371                         hasFirstParamSignatures = true;
48372                         if (hasEffectiveRestParameter(paramSig)) {
48373                             return true;
48374                         }
48375                         var paramCount = getParameterCount(paramSig);
48376                         if (paramCount > maxParamCount) {
48377                             maxParamCount = paramCount;
48378                         }
48379                     }
48380                 }
48381                 if (!hasFirstParamSignatures) {
48382                     return true;
48383                 }
48384                 var absoluteMinArgCount = Infinity;
48385                 for (var _c = 0, tagCallSignatures_1 = tagCallSignatures; _c < tagCallSignatures_1.length; _c++) {
48386                     var tagSig = tagCallSignatures_1[_c];
48387                     var tagRequiredArgCount = getMinArgumentCount(tagSig);
48388                     if (tagRequiredArgCount < absoluteMinArgCount) {
48389                         absoluteMinArgCount = tagRequiredArgCount;
48390                     }
48391                 }
48392                 if (absoluteMinArgCount <= maxParamCount) {
48393                     return true;
48394                 }
48395                 if (reportErrors) {
48396                     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);
48397                     var tagNameDeclaration = (_a = getSymbolAtLocation(node.tagName)) === null || _a === void 0 ? void 0 : _a.valueDeclaration;
48398                     if (tagNameDeclaration) {
48399                         ts.addRelatedInfo(diag, ts.createDiagnosticForNode(tagNameDeclaration, ts.Diagnostics._0_is_declared_here, ts.entityNameToString(node.tagName)));
48400                     }
48401                     if (errorOutputContainer && errorOutputContainer.skipLogging) {
48402                         (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
48403                     }
48404                     if (!errorOutputContainer.skipLogging) {
48405                         diagnostics.add(diag);
48406                     }
48407                 }
48408                 return false;
48409             }
48410         }
48411         function getSignatureApplicabilityError(node, args, signature, relation, checkMode, reportErrors, containingMessageChain) {
48412             var errorOutputContainer = { errors: undefined, skipLogging: true };
48413             if (ts.isJsxOpeningLikeElement(node)) {
48414                 if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer)) {
48415                     ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "jsx should have errors when reporting errors");
48416                     return errorOutputContainer.errors || ts.emptyArray;
48417                 }
48418                 return undefined;
48419             }
48420             var thisType = getThisTypeOfSignature(signature);
48421             if (thisType && thisType !== voidType && node.kind !== 197) {
48422                 var thisArgumentNode = getThisArgumentOfCall(node);
48423                 var thisArgumentType = void 0;
48424                 if (thisArgumentNode) {
48425                     thisArgumentType = checkExpression(thisArgumentNode);
48426                     if (ts.isOptionalChainRoot(thisArgumentNode.parent)) {
48427                         thisArgumentType = getNonNullableType(thisArgumentType);
48428                     }
48429                     else if (ts.isOptionalChain(thisArgumentNode.parent)) {
48430                         thisArgumentType = removeOptionalTypeMarker(thisArgumentType);
48431                     }
48432                 }
48433                 else {
48434                     thisArgumentType = voidType;
48435                 }
48436                 var errorNode = reportErrors ? (thisArgumentNode || node) : undefined;
48437                 var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1;
48438                 if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) {
48439                     ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "this parameter should have errors when reporting errors");
48440                     return errorOutputContainer.errors || ts.emptyArray;
48441                 }
48442             }
48443             var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1;
48444             var restType = getNonArrayRestType(signature);
48445             var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length;
48446             for (var i = 0; i < argCount; i++) {
48447                 var arg = args[i];
48448                 if (arg.kind !== 215) {
48449                     var paramType = getTypeAtPosition(signature, i);
48450                     var argType = checkExpressionWithContextualType(arg, paramType, undefined, checkMode);
48451                     var checkArgType = checkMode & 4 ? getRegularTypeOfObjectLiteral(argType) : argType;
48452                     if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) {
48453                         ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors");
48454                         maybeAddMissingAwaitInfo(arg, checkArgType, paramType);
48455                         return errorOutputContainer.errors || ts.emptyArray;
48456                     }
48457                 }
48458             }
48459             if (restType) {
48460                 var spreadType = getSpreadArgumentType(args, argCount, args.length, restType, undefined);
48461                 var errorNode = reportErrors ? argCount < args.length ? args[argCount] : node : undefined;
48462                 if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, undefined, errorOutputContainer)) {
48463                     ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors");
48464                     maybeAddMissingAwaitInfo(errorNode, spreadType, restType);
48465                     return errorOutputContainer.errors || ts.emptyArray;
48466                 }
48467             }
48468             return undefined;
48469             function maybeAddMissingAwaitInfo(errorNode, source, target) {
48470                 if (errorNode && reportErrors && errorOutputContainer.errors && errorOutputContainer.errors.length) {
48471                     if (getAwaitedTypeOfPromise(target)) {
48472                         return;
48473                     }
48474                     var awaitedTypeOfSource = getAwaitedTypeOfPromise(source);
48475                     if (awaitedTypeOfSource && isTypeRelatedTo(awaitedTypeOfSource, target, relation)) {
48476                         ts.addRelatedInfo(errorOutputContainer.errors[0], ts.createDiagnosticForNode(errorNode, ts.Diagnostics.Did_you_forget_to_use_await));
48477                     }
48478                 }
48479             }
48480         }
48481         function getThisArgumentOfCall(node) {
48482             if (node.kind === 196) {
48483                 var callee = ts.skipOuterExpressions(node.expression);
48484                 if (ts.isAccessExpression(callee)) {
48485                     return callee.expression;
48486                 }
48487             }
48488         }
48489         function createSyntheticExpression(parent, type, isSpread) {
48490             var result = ts.createNode(220, parent.pos, parent.end);
48491             result.parent = parent;
48492             result.type = type;
48493             result.isSpread = isSpread || false;
48494             return result;
48495         }
48496         function getEffectiveCallArguments(node) {
48497             if (node.kind === 198) {
48498                 var template = node.template;
48499                 var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())];
48500                 if (template.kind === 211) {
48501                     ts.forEach(template.templateSpans, function (span) {
48502                         args_3.push(span.expression);
48503                     });
48504                 }
48505                 return args_3;
48506             }
48507             if (node.kind === 157) {
48508                 return getEffectiveDecoratorArguments(node);
48509             }
48510             if (ts.isJsxOpeningLikeElement(node)) {
48511                 return node.attributes.properties.length > 0 || (ts.isJsxOpeningElement(node) && node.parent.children.length > 0) ? [node.attributes] : ts.emptyArray;
48512             }
48513             var args = node.arguments || ts.emptyArray;
48514             var length = args.length;
48515             if (length && isSpreadArgument(args[length - 1]) && getSpreadArgumentIndex(args) === length - 1) {
48516                 var spreadArgument_1 = args[length - 1];
48517                 var type = flowLoopCount ? checkExpression(spreadArgument_1.expression) : checkExpressionCached(spreadArgument_1.expression);
48518                 if (isTupleType(type)) {
48519                     var typeArguments = getTypeArguments(type);
48520                     var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1;
48521                     var syntheticArgs = ts.map(typeArguments, function (t, i) { return createSyntheticExpression(spreadArgument_1, t, i === restIndex_2); });
48522                     return ts.concatenate(args.slice(0, length - 1), syntheticArgs);
48523                 }
48524             }
48525             return args;
48526         }
48527         function getEffectiveDecoratorArguments(node) {
48528             var parent = node.parent;
48529             var expr = node.expression;
48530             switch (parent.kind) {
48531                 case 245:
48532                 case 214:
48533                     return [
48534                         createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent)))
48535                     ];
48536                 case 156:
48537                     var func = parent.parent;
48538                     return [
48539                         createSyntheticExpression(expr, parent.parent.kind === 162 ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType),
48540                         createSyntheticExpression(expr, anyType),
48541                         createSyntheticExpression(expr, numberType)
48542                     ];
48543                 case 159:
48544                 case 161:
48545                 case 163:
48546                 case 164:
48547                     var hasPropDesc = parent.kind !== 159 && languageVersion !== 0;
48548                     return [
48549                         createSyntheticExpression(expr, getParentTypeOfClassElement(parent)),
48550                         createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)),
48551                         createSyntheticExpression(expr, hasPropDesc ? createTypedPropertyDescriptorType(getTypeOfNode(parent)) : anyType)
48552                     ];
48553             }
48554             return ts.Debug.fail();
48555         }
48556         function getDecoratorArgumentCount(node, signature) {
48557             switch (node.parent.kind) {
48558                 case 245:
48559                 case 214:
48560                     return 1;
48561                 case 159:
48562                     return 2;
48563                 case 161:
48564                 case 163:
48565                 case 164:
48566                     return languageVersion === 0 || signature.parameters.length <= 2 ? 2 : 3;
48567                 case 156:
48568                     return 3;
48569                 default:
48570                     return ts.Debug.fail();
48571             }
48572         }
48573         function getDiagnosticSpanForCallNode(node, doNotIncludeArguments) {
48574             var start;
48575             var length;
48576             var sourceFile = ts.getSourceFileOfNode(node);
48577             if (ts.isPropertyAccessExpression(node.expression)) {
48578                 var nameSpan = ts.getErrorSpanForNode(sourceFile, node.expression.name);
48579                 start = nameSpan.start;
48580                 length = doNotIncludeArguments ? nameSpan.length : node.end - start;
48581             }
48582             else {
48583                 var expressionSpan = ts.getErrorSpanForNode(sourceFile, node.expression);
48584                 start = expressionSpan.start;
48585                 length = doNotIncludeArguments ? expressionSpan.length : node.end - start;
48586             }
48587             return { start: start, length: length, sourceFile: sourceFile };
48588         }
48589         function getDiagnosticForCallNode(node, message, arg0, arg1, arg2, arg3) {
48590             if (ts.isCallExpression(node)) {
48591                 var _a = getDiagnosticSpanForCallNode(node), sourceFile = _a.sourceFile, start = _a.start, length_5 = _a.length;
48592                 return ts.createFileDiagnostic(sourceFile, start, length_5, message, arg0, arg1, arg2, arg3);
48593             }
48594             else {
48595                 return ts.createDiagnosticForNode(node, message, arg0, arg1, arg2, arg3);
48596             }
48597         }
48598         function getArgumentArityError(node, signatures, args) {
48599             var min = Number.POSITIVE_INFINITY;
48600             var max = Number.NEGATIVE_INFINITY;
48601             var belowArgCount = Number.NEGATIVE_INFINITY;
48602             var aboveArgCount = Number.POSITIVE_INFINITY;
48603             var argCount = args.length;
48604             var closestSignature;
48605             for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) {
48606                 var sig = signatures_8[_i];
48607                 var minCount = getMinArgumentCount(sig);
48608                 var maxCount = getParameterCount(sig);
48609                 if (minCount < argCount && minCount > belowArgCount)
48610                     belowArgCount = minCount;
48611                 if (argCount < maxCount && maxCount < aboveArgCount)
48612                     aboveArgCount = maxCount;
48613                 if (minCount < min) {
48614                     min = minCount;
48615                     closestSignature = sig;
48616                 }
48617                 max = Math.max(max, maxCount);
48618             }
48619             var hasRestParameter = ts.some(signatures, hasEffectiveRestParameter);
48620             var paramRange = hasRestParameter ? min :
48621                 min < max ? min + "-" + max :
48622                     min;
48623             var hasSpreadArgument = getSpreadArgumentIndex(args) > -1;
48624             if (argCount <= max && hasSpreadArgument) {
48625                 argCount--;
48626             }
48627             var spanArray;
48628             var related;
48629             var error = hasRestParameter || hasSpreadArgument ? hasRestParameter && hasSpreadArgument ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1_or_more :
48630                 hasRestParameter ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 :
48631                     ts.Diagnostics.Expected_0_arguments_but_got_1_or_more : ts.Diagnostics.Expected_0_arguments_but_got_1;
48632             if (closestSignature && getMinArgumentCount(closestSignature) > argCount && closestSignature.declaration) {
48633                 var paramDecl = closestSignature.declaration.parameters[closestSignature.thisParameter ? argCount + 1 : argCount];
48634                 if (paramDecl) {
48635                     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);
48636                 }
48637             }
48638             if (min < argCount && argCount < max) {
48639                 return getDiagnosticForCallNode(node, ts.Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, argCount, belowArgCount, aboveArgCount);
48640             }
48641             if (!hasSpreadArgument && argCount < min) {
48642                 var diagnostic_1 = getDiagnosticForCallNode(node, error, paramRange, argCount);
48643                 return related ? ts.addRelatedInfo(diagnostic_1, related) : diagnostic_1;
48644             }
48645             if (hasRestParameter || hasSpreadArgument) {
48646                 spanArray = ts.createNodeArray(args);
48647                 if (hasSpreadArgument && argCount) {
48648                     var nextArg = ts.elementAt(args, getSpreadArgumentIndex(args) + 1) || undefined;
48649                     spanArray = ts.createNodeArray(args.slice(max > argCount && nextArg ? args.indexOf(nextArg) : Math.min(max, args.length - 1)));
48650                 }
48651             }
48652             else {
48653                 spanArray = ts.createNodeArray(args.slice(max));
48654             }
48655             spanArray.pos = ts.first(spanArray).pos;
48656             spanArray.end = ts.last(spanArray).end;
48657             if (spanArray.end === spanArray.pos) {
48658                 spanArray.end++;
48659             }
48660             var diagnostic = ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), spanArray, error, paramRange, argCount);
48661             return related ? ts.addRelatedInfo(diagnostic, related) : diagnostic;
48662         }
48663         function getTypeArgumentArityError(node, signatures, typeArguments) {
48664             var argCount = typeArguments.length;
48665             if (signatures.length === 1) {
48666                 var sig = signatures[0];
48667                 var min_1 = getMinTypeArgumentCount(sig.typeParameters);
48668                 var max = ts.length(sig.typeParameters);
48669                 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);
48670             }
48671             var belowArgCount = -Infinity;
48672             var aboveArgCount = Infinity;
48673             for (var _i = 0, signatures_9 = signatures; _i < signatures_9.length; _i++) {
48674                 var sig = signatures_9[_i];
48675                 var min_2 = getMinTypeArgumentCount(sig.typeParameters);
48676                 var max = ts.length(sig.typeParameters);
48677                 if (min_2 > argCount) {
48678                     aboveArgCount = Math.min(aboveArgCount, min_2);
48679                 }
48680                 else if (max < argCount) {
48681                     belowArgCount = Math.max(belowArgCount, max);
48682                 }
48683             }
48684             if (belowArgCount !== -Infinity && aboveArgCount !== Infinity) {
48685                 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);
48686             }
48687             return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
48688         }
48689         function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) {
48690             var isTaggedTemplate = node.kind === 198;
48691             var isDecorator = node.kind === 157;
48692             var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
48693             var reportErrors = !candidatesOutArray;
48694             var typeArguments;
48695             if (!isDecorator) {
48696                 typeArguments = node.typeArguments;
48697                 if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 102) {
48698                     ts.forEach(typeArguments, checkSourceElement);
48699                 }
48700             }
48701             var candidates = candidatesOutArray || [];
48702             reorderCandidates(signatures, candidates, callChainFlags);
48703             if (!candidates.length) {
48704                 if (reportErrors) {
48705                     diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures));
48706                 }
48707                 return resolveErrorCall(node);
48708             }
48709             var args = getEffectiveCallArguments(node);
48710             var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
48711             var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 : 0;
48712             var candidatesForArgumentError;
48713             var candidateForArgumentArityError;
48714             var candidateForTypeArgumentError;
48715             var result;
48716             var signatureHelpTrailingComma = !!(checkMode & 16) && node.kind === 196 && node.arguments.hasTrailingComma;
48717             if (candidates.length > 1) {
48718                 result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma);
48719             }
48720             if (!result) {
48721                 result = chooseOverload(candidates, assignableRelation, signatureHelpTrailingComma);
48722             }
48723             if (result) {
48724                 return result;
48725             }
48726             if (reportErrors) {
48727                 if (candidatesForArgumentError) {
48728                     if (candidatesForArgumentError.length === 1 || candidatesForArgumentError.length > 3) {
48729                         var last_2 = candidatesForArgumentError[candidatesForArgumentError.length - 1];
48730                         var chain_1;
48731                         if (candidatesForArgumentError.length > 3) {
48732                             chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.The_last_overload_gave_the_following_error);
48733                             chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.No_overload_matches_this_call);
48734                         }
48735                         var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0, true, function () { return chain_1; });
48736                         if (diags) {
48737                             for (var _i = 0, diags_1 = diags; _i < diags_1.length; _i++) {
48738                                 var d = diags_1[_i];
48739                                 if (last_2.declaration && candidatesForArgumentError.length > 3) {
48740                                     ts.addRelatedInfo(d, ts.createDiagnosticForNode(last_2.declaration, ts.Diagnostics.The_last_overload_is_declared_here));
48741                                 }
48742                                 diagnostics.add(d);
48743                             }
48744                         }
48745                         else {
48746                             ts.Debug.fail("No error for last overload signature");
48747                         }
48748                     }
48749                     else {
48750                         var allDiagnostics = [];
48751                         var max = 0;
48752                         var min_3 = Number.MAX_VALUE;
48753                         var minIndex = 0;
48754                         var i_1 = 0;
48755                         var _loop_17 = function (c) {
48756                             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)); };
48757                             var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0, true, chain_2);
48758                             if (diags_2) {
48759                                 if (diags_2.length <= min_3) {
48760                                     min_3 = diags_2.length;
48761                                     minIndex = i_1;
48762                                 }
48763                                 max = Math.max(max, diags_2.length);
48764                                 allDiagnostics.push(diags_2);
48765                             }
48766                             else {
48767                                 ts.Debug.fail("No error for 3 or fewer overload signatures");
48768                             }
48769                             i_1++;
48770                         };
48771                         for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
48772                             var c = candidatesForArgumentError_1[_a];
48773                             _loop_17(c);
48774                         }
48775                         var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
48776                         ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
48777                         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);
48778                         var related = ts.flatMap(diags_3, function (d) { return d.relatedInformation; });
48779                         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; })) {
48780                             var _b = diags_3[0], file = _b.file, start = _b.start, length_6 = _b.length;
48781                             diagnostics.add({ file: file, start: start, length: length_6, code: chain.code, category: chain.category, messageText: chain, relatedInformation: related });
48782                         }
48783                         else {
48784                             diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, chain, related));
48785                         }
48786                     }
48787                 }
48788                 else if (candidateForArgumentArityError) {
48789                     diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args));
48790                 }
48791                 else if (candidateForTypeArgumentError) {
48792                     checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, true, fallbackError);
48793                 }
48794                 else {
48795                     var signaturesWithCorrectTypeArgumentArity = ts.filter(signatures, function (s) { return hasCorrectTypeArgumentArity(s, typeArguments); });
48796                     if (signaturesWithCorrectTypeArgumentArity.length === 0) {
48797                         diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments));
48798                     }
48799                     else if (!isDecorator) {
48800                         diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args));
48801                     }
48802                     else if (fallbackError) {
48803                         diagnostics.add(getDiagnosticForCallNode(node, fallbackError));
48804                     }
48805                 }
48806             }
48807             return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray);
48808             function chooseOverload(candidates, relation, signatureHelpTrailingComma) {
48809                 if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; }
48810                 candidatesForArgumentError = undefined;
48811                 candidateForArgumentArityError = undefined;
48812                 candidateForTypeArgumentError = undefined;
48813                 if (isSingleNonGenericCandidate) {
48814                     var candidate = candidates[0];
48815                     if (ts.some(typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) {
48816                         return undefined;
48817                     }
48818                     if (getSignatureApplicabilityError(node, args, candidate, relation, 0, false, undefined)) {
48819                         candidatesForArgumentError = [candidate];
48820                         return undefined;
48821                     }
48822                     return candidate;
48823                 }
48824                 for (var candidateIndex = 0; candidateIndex < candidates.length; candidateIndex++) {
48825                     var candidate = candidates[candidateIndex];
48826                     if (!hasCorrectTypeArgumentArity(candidate, typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) {
48827                         continue;
48828                     }
48829                     var checkCandidate = void 0;
48830                     var inferenceContext = void 0;
48831                     if (candidate.typeParameters) {
48832                         var typeArgumentTypes = void 0;
48833                         if (ts.some(typeArguments)) {
48834                             typeArgumentTypes = checkTypeArguments(candidate, typeArguments, false);
48835                             if (!typeArgumentTypes) {
48836                                 candidateForTypeArgumentError = candidate;
48837                                 continue;
48838                             }
48839                         }
48840                         else {
48841                             inferenceContext = createInferenceContext(candidate.typeParameters, candidate, ts.isInJSFile(node) ? 2 : 0);
48842                             typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8, inferenceContext);
48843                             argCheckMode |= inferenceContext.flags & 4 ? 8 : 0;
48844                         }
48845                         checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
48846                         if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) {
48847                             candidateForArgumentArityError = checkCandidate;
48848                             continue;
48849                         }
48850                     }
48851                     else {
48852                         checkCandidate = candidate;
48853                     }
48854                     if (getSignatureApplicabilityError(node, args, checkCandidate, relation, argCheckMode, false, undefined)) {
48855                         (candidatesForArgumentError || (candidatesForArgumentError = [])).push(checkCandidate);
48856                         continue;
48857                     }
48858                     if (argCheckMode) {
48859                         argCheckMode = 0;
48860                         if (inferenceContext) {
48861                             var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
48862                             checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
48863                             if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) {
48864                                 candidateForArgumentArityError = checkCandidate;
48865                                 continue;
48866                             }
48867                         }
48868                         if (getSignatureApplicabilityError(node, args, checkCandidate, relation, argCheckMode, false, undefined)) {
48869                             (candidatesForArgumentError || (candidatesForArgumentError = [])).push(checkCandidate);
48870                             continue;
48871                         }
48872                     }
48873                     candidates[candidateIndex] = checkCandidate;
48874                     return checkCandidate;
48875                 }
48876                 return undefined;
48877             }
48878         }
48879         function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray) {
48880             ts.Debug.assert(candidates.length > 0);
48881             checkNodeDeferred(node);
48882             return hasCandidatesOutArray || candidates.length === 1 || candidates.some(function (c) { return !!c.typeParameters; })
48883                 ? pickLongestCandidateSignature(node, candidates, args)
48884                 : createUnionOfSignaturesForOverloadFailure(candidates);
48885         }
48886         function createUnionOfSignaturesForOverloadFailure(candidates) {
48887             var thisParameters = ts.mapDefined(candidates, function (c) { return c.thisParameter; });
48888             var thisParameter;
48889             if (thisParameters.length) {
48890                 thisParameter = createCombinedSymbolFromTypes(thisParameters, thisParameters.map(getTypeOfParameter));
48891             }
48892             var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
48893             var parameters = [];
48894             var _loop_18 = function (i) {
48895                 var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
48896                     i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
48897                     i < s.parameters.length ? s.parameters[i] : undefined; });
48898                 ts.Debug.assert(symbols.length !== 0);
48899                 parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
48900             };
48901             for (var i = 0; i < maxNonRestParam; i++) {
48902                 _loop_18(i);
48903             }
48904             var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
48905             var flags = 0;
48906             if (restParameterSymbols.length !== 0) {
48907                 var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2));
48908                 parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type));
48909                 flags |= 1;
48910             }
48911             if (candidates.some(signatureHasLiteralTypes)) {
48912                 flags |= 2;
48913             }
48914             return createSignature(candidates[0].declaration, undefined, thisParameter, parameters, getIntersectionType(candidates.map(getReturnTypeOfSignature)), undefined, minArgumentCount, flags);
48915         }
48916         function getNumNonRestParameters(signature) {
48917             var numParams = signature.parameters.length;
48918             return signatureHasRestParameter(signature) ? numParams - 1 : numParams;
48919         }
48920         function createCombinedSymbolFromTypes(sources, types) {
48921             return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2));
48922         }
48923         function createCombinedSymbolForOverloadFailure(sources, type) {
48924             return createSymbolWithType(ts.first(sources), type);
48925         }
48926         function pickLongestCandidateSignature(node, candidates, args) {
48927             var bestIndex = getLongestCandidateIndex(candidates, apparentArgumentCount === undefined ? args.length : apparentArgumentCount);
48928             var candidate = candidates[bestIndex];
48929             var typeParameters = candidate.typeParameters;
48930             if (!typeParameters) {
48931                 return candidate;
48932             }
48933             var typeArgumentNodes = callLikeExpressionMayHaveTypeArguments(node) ? node.typeArguments : undefined;
48934             var instantiated = typeArgumentNodes
48935                 ? createSignatureInstantiation(candidate, getTypeArgumentsFromNodes(typeArgumentNodes, typeParameters, ts.isInJSFile(node)))
48936                 : inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args);
48937             candidates[bestIndex] = instantiated;
48938             return instantiated;
48939         }
48940         function getTypeArgumentsFromNodes(typeArgumentNodes, typeParameters, isJs) {
48941             var typeArguments = typeArgumentNodes.map(getTypeOfNode);
48942             while (typeArguments.length > typeParameters.length) {
48943                 typeArguments.pop();
48944             }
48945             while (typeArguments.length < typeParameters.length) {
48946                 typeArguments.push(getConstraintOfTypeParameter(typeParameters[typeArguments.length]) || getDefaultTypeArgumentType(isJs));
48947             }
48948             return typeArguments;
48949         }
48950         function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args) {
48951             var inferenceContext = createInferenceContext(typeParameters, candidate, ts.isInJSFile(node) ? 2 : 0);
48952             var typeArgumentTypes = inferTypeArguments(node, candidate, args, 4 | 8, inferenceContext);
48953             return createSignatureInstantiation(candidate, typeArgumentTypes);
48954         }
48955         function getLongestCandidateIndex(candidates, argsCount) {
48956             var maxParamsIndex = -1;
48957             var maxParams = -1;
48958             for (var i = 0; i < candidates.length; i++) {
48959                 var candidate = candidates[i];
48960                 var paramCount = getParameterCount(candidate);
48961                 if (hasEffectiveRestParameter(candidate) || paramCount >= argsCount) {
48962                     return i;
48963                 }
48964                 if (paramCount > maxParams) {
48965                     maxParams = paramCount;
48966                     maxParamsIndex = i;
48967                 }
48968             }
48969             return maxParamsIndex;
48970         }
48971         function resolveCallExpression(node, candidatesOutArray, checkMode) {
48972             if (node.expression.kind === 102) {
48973                 var superType = checkSuperExpression(node.expression);
48974                 if (isTypeAny(superType)) {
48975                     for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) {
48976                         var arg = _a[_i];
48977                         checkExpression(arg);
48978                     }
48979                     return anySignature;
48980                 }
48981                 if (superType !== errorType) {
48982                     var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node));
48983                     if (baseTypeNode) {
48984                         var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode);
48985                         return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0);
48986                     }
48987                 }
48988                 return resolveUntypedCall(node);
48989             }
48990             var callChainFlags;
48991             var funcType = checkExpression(node.expression);
48992             if (ts.isCallChain(node)) {
48993                 var nonOptionalType = getOptionalExpressionType(funcType, node.expression);
48994                 callChainFlags = nonOptionalType === funcType ? 0 :
48995                     ts.isOutermostOptionalChain(node) ? 8 :
48996                         4;
48997                 funcType = nonOptionalType;
48998             }
48999             else {
49000                 callChainFlags = 0;
49001             }
49002             funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError);
49003             if (funcType === silentNeverType) {
49004                 return silentNeverSignature;
49005             }
49006             var apparentType = getApparentType(funcType);
49007             if (apparentType === errorType) {
49008                 return resolveErrorCall(node);
49009             }
49010             var callSignatures = getSignaturesOfType(apparentType, 0);
49011             var numConstructSignatures = getSignaturesOfType(apparentType, 1).length;
49012             if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) {
49013                 if (funcType !== errorType && node.typeArguments) {
49014                     error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
49015                 }
49016                 return resolveUntypedCall(node);
49017             }
49018             if (!callSignatures.length) {
49019                 if (numConstructSignatures) {
49020                     error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
49021                 }
49022                 else {
49023                     var relatedInformation = void 0;
49024                     if (node.arguments.length === 1) {
49025                         var text = ts.getSourceFileOfNode(node).text;
49026                         if (ts.isLineBreak(text.charCodeAt(ts.skipTrivia(text, node.expression.end, true) - 1))) {
49027                             relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.Are_you_missing_a_semicolon);
49028                         }
49029                     }
49030                     invocationError(node.expression, apparentType, 0, relatedInformation);
49031                 }
49032                 return resolveErrorCall(node);
49033             }
49034             if (checkMode & 8 && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) {
49035                 skippedGenericFunction(node, checkMode);
49036                 return resolvingSignature;
49037             }
49038             if (callSignatures.some(function (sig) { return ts.isInJSFile(sig.declaration) && !!ts.getJSDocClassTag(sig.declaration); })) {
49039                 error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
49040                 return resolveErrorCall(node);
49041             }
49042             return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
49043         }
49044         function isGenericFunctionReturningFunction(signature) {
49045             return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
49046         }
49047         function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) {
49048             return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144) ||
49049                 !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (1048576 | 131072)) && isTypeAssignableTo(funcType, globalFunctionType);
49050         }
49051         function resolveNewExpression(node, candidatesOutArray, checkMode) {
49052             if (node.arguments && languageVersion < 1) {
49053                 var spreadIndex = getSpreadArgumentIndex(node.arguments);
49054                 if (spreadIndex >= 0) {
49055                     error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher);
49056                 }
49057             }
49058             var expressionType = checkNonNullExpression(node.expression);
49059             if (expressionType === silentNeverType) {
49060                 return silentNeverSignature;
49061             }
49062             expressionType = getApparentType(expressionType);
49063             if (expressionType === errorType) {
49064                 return resolveErrorCall(node);
49065             }
49066             if (isTypeAny(expressionType)) {
49067                 if (node.typeArguments) {
49068                     error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
49069                 }
49070                 return resolveUntypedCall(node);
49071             }
49072             var constructSignatures = getSignaturesOfType(expressionType, 1);
49073             if (constructSignatures.length) {
49074                 if (!isConstructorAccessible(node, constructSignatures[0])) {
49075                     return resolveErrorCall(node);
49076                 }
49077                 var valueDecl = expressionType.symbol && ts.getClassLikeDeclarationOfSymbol(expressionType.symbol);
49078                 if (valueDecl && ts.hasModifier(valueDecl, 128)) {
49079                     error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class);
49080                     return resolveErrorCall(node);
49081                 }
49082                 return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0);
49083             }
49084             var callSignatures = getSignaturesOfType(expressionType, 0);
49085             if (callSignatures.length) {
49086                 var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0);
49087                 if (!noImplicitAny) {
49088                     if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) {
49089                         error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword);
49090                     }
49091                     if (getThisTypeOfSignature(signature) === voidType) {
49092                         error(node, ts.Diagnostics.A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void);
49093                     }
49094                 }
49095                 return signature;
49096             }
49097             invocationError(node.expression, expressionType, 1);
49098             return resolveErrorCall(node);
49099         }
49100         function typeHasProtectedAccessibleBase(target, type) {
49101             var baseTypes = getBaseTypes(type);
49102             if (!ts.length(baseTypes)) {
49103                 return false;
49104             }
49105             var firstBase = baseTypes[0];
49106             if (firstBase.flags & 2097152) {
49107                 var types = firstBase.types;
49108                 var mixinFlags = findMixins(types);
49109                 var i = 0;
49110                 for (var _i = 0, _a = firstBase.types; _i < _a.length; _i++) {
49111                     var intersectionMember = _a[_i];
49112                     if (!mixinFlags[i]) {
49113                         if (ts.getObjectFlags(intersectionMember) & (1 | 2)) {
49114                             if (intersectionMember.symbol === target) {
49115                                 return true;
49116                             }
49117                             if (typeHasProtectedAccessibleBase(target, intersectionMember)) {
49118                                 return true;
49119                             }
49120                         }
49121                     }
49122                     i++;
49123                 }
49124                 return false;
49125             }
49126             if (firstBase.symbol === target) {
49127                 return true;
49128             }
49129             return typeHasProtectedAccessibleBase(target, firstBase);
49130         }
49131         function isConstructorAccessible(node, signature) {
49132             if (!signature || !signature.declaration) {
49133                 return true;
49134             }
49135             var declaration = signature.declaration;
49136             var modifiers = ts.getSelectedModifierFlags(declaration, 24);
49137             if (!modifiers || declaration.kind !== 162) {
49138                 return true;
49139             }
49140             var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol);
49141             var declaringClass = getDeclaredTypeOfSymbol(declaration.parent.symbol);
49142             if (!isNodeWithinClass(node, declaringClassDeclaration)) {
49143                 var containingClass = ts.getContainingClass(node);
49144                 if (containingClass && modifiers & 16) {
49145                     var containingType = getTypeOfNode(containingClass);
49146                     if (typeHasProtectedAccessibleBase(declaration.parent.symbol, containingType)) {
49147                         return true;
49148                     }
49149                 }
49150                 if (modifiers & 8) {
49151                     error(node, ts.Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass));
49152                 }
49153                 if (modifiers & 16) {
49154                     error(node, ts.Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass));
49155                 }
49156                 return false;
49157             }
49158             return true;
49159         }
49160         function invocationErrorDetails(apparentType, kind) {
49161             var errorInfo;
49162             var isCall = kind === 0;
49163             var awaitedType = getAwaitedType(apparentType);
49164             var maybeMissingAwait = awaitedType && getSignaturesOfType(awaitedType, kind).length > 0;
49165             if (apparentType.flags & 1048576) {
49166                 var types = apparentType.types;
49167                 var hasSignatures = false;
49168                 for (var _i = 0, types_18 = types; _i < types_18.length; _i++) {
49169                     var constituent = types_18[_i];
49170                     var signatures = getSignaturesOfType(constituent, kind);
49171                     if (signatures.length !== 0) {
49172                         hasSignatures = true;
49173                         if (errorInfo) {
49174                             break;
49175                         }
49176                     }
49177                     else {
49178                         if (!errorInfo) {
49179                             errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
49180                                 ts.Diagnostics.Type_0_has_no_call_signatures :
49181                                 ts.Diagnostics.Type_0_has_no_construct_signatures, typeToString(constituent));
49182                             errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
49183                                 ts.Diagnostics.Not_all_constituents_of_type_0_are_callable :
49184                                 ts.Diagnostics.Not_all_constituents_of_type_0_are_constructable, typeToString(apparentType));
49185                         }
49186                         if (hasSignatures) {
49187                             break;
49188                         }
49189                     }
49190                 }
49191                 if (!hasSignatures) {
49192                     errorInfo = ts.chainDiagnosticMessages(undefined, isCall ?
49193                         ts.Diagnostics.No_constituent_of_type_0_is_callable :
49194                         ts.Diagnostics.No_constituent_of_type_0_is_constructable, typeToString(apparentType));
49195                 }
49196                 if (!errorInfo) {
49197                     errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
49198                         ts.Diagnostics.Each_member_of_the_union_type_0_has_signatures_but_none_of_those_signatures_are_compatible_with_each_other :
49199                         ts.Diagnostics.Each_member_of_the_union_type_0_has_construct_signatures_but_none_of_those_signatures_are_compatible_with_each_other, typeToString(apparentType));
49200                 }
49201             }
49202             else {
49203                 errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
49204                     ts.Diagnostics.Type_0_has_no_call_signatures :
49205                     ts.Diagnostics.Type_0_has_no_construct_signatures, typeToString(apparentType));
49206             }
49207             return {
49208                 messageChain: ts.chainDiagnosticMessages(errorInfo, isCall ? ts.Diagnostics.This_expression_is_not_callable : ts.Diagnostics.This_expression_is_not_constructable),
49209                 relatedMessage: maybeMissingAwait ? ts.Diagnostics.Did_you_forget_to_use_await : undefined,
49210             };
49211         }
49212         function invocationError(errorTarget, apparentType, kind, relatedInformation) {
49213             var _a = invocationErrorDetails(apparentType, kind), messageChain = _a.messageChain, relatedInfo = _a.relatedMessage;
49214             var diagnostic = ts.createDiagnosticForNodeFromMessageChain(errorTarget, messageChain);
49215             if (relatedInfo) {
49216                 ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(errorTarget, relatedInfo));
49217             }
49218             if (ts.isCallExpression(errorTarget.parent)) {
49219                 var _b = getDiagnosticSpanForCallNode(errorTarget.parent, true), start = _b.start, length_7 = _b.length;
49220                 diagnostic.start = start;
49221                 diagnostic.length = length_7;
49222             }
49223             diagnostics.add(diagnostic);
49224             invocationErrorRecovery(apparentType, kind, relatedInformation ? ts.addRelatedInfo(diagnostic, relatedInformation) : diagnostic);
49225         }
49226         function invocationErrorRecovery(apparentType, kind, diagnostic) {
49227             if (!apparentType.symbol) {
49228                 return;
49229             }
49230             var importNode = getSymbolLinks(apparentType.symbol).originatingImport;
49231             if (importNode && !ts.isImportCall(importNode)) {
49232                 var sigs = getSignaturesOfType(getTypeOfSymbol(getSymbolLinks(apparentType.symbol).target), kind);
49233                 if (!sigs || !sigs.length)
49234                     return;
49235                 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));
49236             }
49237         }
49238         function resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode) {
49239             var tagType = checkExpression(node.tag);
49240             var apparentType = getApparentType(tagType);
49241             if (apparentType === errorType) {
49242                 return resolveErrorCall(node);
49243             }
49244             var callSignatures = getSignaturesOfType(apparentType, 0);
49245             var numConstructSignatures = getSignaturesOfType(apparentType, 1).length;
49246             if (isUntypedFunctionCall(tagType, apparentType, callSignatures.length, numConstructSignatures)) {
49247                 return resolveUntypedCall(node);
49248             }
49249             if (!callSignatures.length) {
49250                 invocationError(node.tag, apparentType, 0);
49251                 return resolveErrorCall(node);
49252             }
49253             return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0);
49254         }
49255         function getDiagnosticHeadMessageForDecoratorResolution(node) {
49256             switch (node.parent.kind) {
49257                 case 245:
49258                 case 214:
49259                     return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression;
49260                 case 156:
49261                     return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression;
49262                 case 159:
49263                     return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression;
49264                 case 161:
49265                 case 163:
49266                 case 164:
49267                     return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression;
49268                 default:
49269                     return ts.Debug.fail();
49270             }
49271         }
49272         function resolveDecorator(node, candidatesOutArray, checkMode) {
49273             var funcType = checkExpression(node.expression);
49274             var apparentType = getApparentType(funcType);
49275             if (apparentType === errorType) {
49276                 return resolveErrorCall(node);
49277             }
49278             var callSignatures = getSignaturesOfType(apparentType, 0);
49279             var numConstructSignatures = getSignaturesOfType(apparentType, 1).length;
49280             if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) {
49281                 return resolveUntypedCall(node);
49282             }
49283             if (isPotentiallyUncalledDecorator(node, callSignatures)) {
49284                 var nodeStr = ts.getTextOfNode(node.expression, false);
49285                 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);
49286                 return resolveErrorCall(node);
49287             }
49288             var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
49289             if (!callSignatures.length) {
49290                 var errorDetails = invocationErrorDetails(apparentType, 0);
49291                 var messageChain = ts.chainDiagnosticMessages(errorDetails.messageChain, headMessage);
49292                 var diag = ts.createDiagnosticForNodeFromMessageChain(node.expression, messageChain);
49293                 if (errorDetails.relatedMessage) {
49294                     ts.addRelatedInfo(diag, ts.createDiagnosticForNode(node.expression, errorDetails.relatedMessage));
49295                 }
49296                 diagnostics.add(diag);
49297                 invocationErrorRecovery(apparentType, 0, diag);
49298                 return resolveErrorCall(node);
49299             }
49300             return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0, headMessage);
49301         }
49302         function createSignatureForJSXIntrinsic(node, result) {
49303             var namespace = getJsxNamespaceAt(node);
49304             var exports = namespace && getExportsOfSymbol(namespace);
49305             var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968);
49306             var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968, node);
49307             var declaration = ts.createFunctionTypeNode(undefined, [ts.createParameter(undefined, undefined, undefined, "props", undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, undefined) : ts.createKeywordTypeNode(125));
49308             var parameterSymbol = createSymbol(1, "props");
49309             parameterSymbol.type = result;
49310             return createSignature(declaration, undefined, undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, undefined, 1, 0);
49311         }
49312         function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) {
49313             if (isJsxIntrinsicIdentifier(node.tagName)) {
49314                 var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node);
49315                 var fakeSignature = createSignatureForJSXIntrinsic(node, result);
49316                 checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), undefined, 0), result, node.tagName, node.attributes);
49317                 return fakeSignature;
49318             }
49319             var exprTypes = checkExpression(node.tagName);
49320             var apparentType = getApparentType(exprTypes);
49321             if (apparentType === errorType) {
49322                 return resolveErrorCall(node);
49323             }
49324             var signatures = getUninstantiatedJsxSignaturesOfType(exprTypes, node);
49325             if (isUntypedFunctionCall(exprTypes, apparentType, signatures.length, 0)) {
49326                 return resolveUntypedCall(node);
49327             }
49328             if (signatures.length === 0) {
49329                 error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName));
49330                 return resolveErrorCall(node);
49331             }
49332             return resolveCall(node, signatures, candidatesOutArray, checkMode, 0);
49333         }
49334         function isPotentiallyUncalledDecorator(decorator, signatures) {
49335             return signatures.length && ts.every(signatures, function (signature) {
49336                 return signature.minArgumentCount === 0 &&
49337                     !signatureHasRestParameter(signature) &&
49338                     signature.parameters.length < getDecoratorArgumentCount(decorator, signature);
49339             });
49340         }
49341         function resolveSignature(node, candidatesOutArray, checkMode) {
49342             switch (node.kind) {
49343                 case 196:
49344                     return resolveCallExpression(node, candidatesOutArray, checkMode);
49345                 case 197:
49346                     return resolveNewExpression(node, candidatesOutArray, checkMode);
49347                 case 198:
49348                     return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode);
49349                 case 157:
49350                     return resolveDecorator(node, candidatesOutArray, checkMode);
49351                 case 268:
49352                 case 267:
49353                     return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode);
49354             }
49355             throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable.");
49356         }
49357         function getResolvedSignature(node, candidatesOutArray, checkMode) {
49358             var links = getNodeLinks(node);
49359             var cached = links.resolvedSignature;
49360             if (cached && cached !== resolvingSignature && !candidatesOutArray) {
49361                 return cached;
49362             }
49363             links.resolvedSignature = resolvingSignature;
49364             var result = resolveSignature(node, candidatesOutArray, checkMode || 0);
49365             if (result !== resolvingSignature) {
49366                 links.resolvedSignature = flowLoopStart === flowLoopCount ? result : cached;
49367             }
49368             return result;
49369         }
49370         function isJSConstructor(node) {
49371             if (!node || !ts.isInJSFile(node)) {
49372                 return false;
49373             }
49374             var func = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) ? node :
49375                 ts.isVariableDeclaration(node) && node.initializer && ts.isFunctionExpression(node.initializer) ? node.initializer :
49376                     undefined;
49377             if (func) {
49378                 if (ts.getJSDocClassTag(node))
49379                     return true;
49380                 var symbol = getSymbolOfNode(func);
49381                 return !!symbol && ts.hasEntries(symbol.members);
49382             }
49383             return false;
49384         }
49385         function mergeJSSymbols(target, source) {
49386             if (source) {
49387                 var links = getSymbolLinks(source);
49388                 if (!links.inferredClassSymbol || !links.inferredClassSymbol.has("" + getSymbolId(target))) {
49389                     var inferred = ts.isTransientSymbol(target) ? target : cloneSymbol(target);
49390                     inferred.exports = inferred.exports || ts.createSymbolTable();
49391                     inferred.members = inferred.members || ts.createSymbolTable();
49392                     inferred.flags |= source.flags & 32;
49393                     if (ts.hasEntries(source.exports)) {
49394                         mergeSymbolTable(inferred.exports, source.exports);
49395                     }
49396                     if (ts.hasEntries(source.members)) {
49397                         mergeSymbolTable(inferred.members, source.members);
49398                     }
49399                     (links.inferredClassSymbol || (links.inferredClassSymbol = ts.createMap())).set("" + getSymbolId(inferred), inferred);
49400                     return inferred;
49401                 }
49402                 return links.inferredClassSymbol.get("" + getSymbolId(target));
49403             }
49404         }
49405         function getAssignedClassSymbol(decl) {
49406             var assignmentSymbol = decl && decl.parent &&
49407                 (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) ||
49408                     ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) ||
49409                     ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent));
49410             var prototype = assignmentSymbol && assignmentSymbol.exports && assignmentSymbol.exports.get("prototype");
49411             var init = prototype && prototype.valueDeclaration && getAssignedJSPrototype(prototype.valueDeclaration);
49412             return init ? getSymbolOfNode(init) : undefined;
49413         }
49414         function getAssignedJSPrototype(node) {
49415             if (!node.parent) {
49416                 return false;
49417             }
49418             var parent = node.parent;
49419             while (parent && parent.kind === 194) {
49420                 parent = parent.parent;
49421             }
49422             if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62) {
49423                 var right = ts.getInitializerOfBinaryExpression(parent);
49424                 return ts.isObjectLiteralExpression(right) && right;
49425             }
49426         }
49427         function checkCallExpression(node, checkMode) {
49428             if (!checkGrammarTypeArguments(node, node.typeArguments))
49429                 checkGrammarArguments(node.arguments);
49430             var signature = getResolvedSignature(node, undefined, checkMode);
49431             if (signature === resolvingSignature) {
49432                 return nonInferrableType;
49433             }
49434             if (node.expression.kind === 102) {
49435                 return voidType;
49436             }
49437             if (node.kind === 197) {
49438                 var declaration = signature.declaration;
49439                 if (declaration &&
49440                     declaration.kind !== 162 &&
49441                     declaration.kind !== 166 &&
49442                     declaration.kind !== 171 &&
49443                     !ts.isJSDocConstructSignature(declaration) &&
49444                     !isJSConstructor(declaration)) {
49445                     if (noImplicitAny) {
49446                         error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type);
49447                     }
49448                     return anyType;
49449                 }
49450             }
49451             if (ts.isInJSFile(node) && isCommonJsRequire(node)) {
49452                 return resolveExternalModuleTypeByLiteral(node.arguments[0]);
49453             }
49454             var returnType = getReturnTypeOfSignature(signature);
49455             if (returnType.flags & 12288 && isSymbolOrSymbolForCall(node)) {
49456                 return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent));
49457             }
49458             if (node.kind === 196 && node.parent.kind === 226 &&
49459                 returnType.flags & 16384 && getTypePredicateOfSignature(signature)) {
49460                 if (!ts.isDottedName(node.expression)) {
49461                     error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name);
49462                 }
49463                 else if (!getEffectsSignature(node)) {
49464                     var diagnostic = error(node.expression, ts.Diagnostics.Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation);
49465                     getTypeOfDottedName(node.expression, diagnostic);
49466                 }
49467             }
49468             if (ts.isInJSFile(node)) {
49469                 var decl = ts.getDeclarationOfExpando(node);
49470                 if (decl) {
49471                     var jsSymbol = getSymbolOfNode(decl);
49472                     if (jsSymbol && ts.hasEntries(jsSymbol.exports)) {
49473                         var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined);
49474                         jsAssignmentType.objectFlags |= 16384;
49475                         return getIntersectionType([returnType, jsAssignmentType]);
49476                     }
49477                 }
49478             }
49479             return returnType;
49480         }
49481         function isSymbolOrSymbolForCall(node) {
49482             if (!ts.isCallExpression(node))
49483                 return false;
49484             var left = node.expression;
49485             if (ts.isPropertyAccessExpression(left) && left.name.escapedText === "for") {
49486                 left = left.expression;
49487             }
49488             if (!ts.isIdentifier(left) || left.escapedText !== "Symbol") {
49489                 return false;
49490             }
49491             var globalESSymbol = getGlobalESSymbolConstructorSymbol(false);
49492             if (!globalESSymbol) {
49493                 return false;
49494             }
49495             return globalESSymbol === resolveName(left, "Symbol", 111551, undefined, undefined, false);
49496         }
49497         function checkImportCallExpression(node) {
49498             if (!checkGrammarArguments(node.arguments))
49499                 checkGrammarImportCallExpression(node);
49500             if (node.arguments.length === 0) {
49501                 return createPromiseReturnType(node, anyType);
49502             }
49503             var specifier = node.arguments[0];
49504             var specifierType = checkExpressionCached(specifier);
49505             for (var i = 1; i < node.arguments.length; ++i) {
49506                 checkExpressionCached(node.arguments[i]);
49507             }
49508             if (specifierType.flags & 32768 || specifierType.flags & 65536 || !isTypeAssignableTo(specifierType, stringType)) {
49509                 error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType));
49510             }
49511             var moduleSymbol = resolveExternalModuleName(node, specifier);
49512             if (moduleSymbol) {
49513                 var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, true, false);
49514                 if (esModuleSymbol) {
49515                     return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol));
49516                 }
49517             }
49518             return createPromiseReturnType(node, anyType);
49519         }
49520         function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) {
49521             if (allowSyntheticDefaultImports && type && type !== errorType) {
49522                 var synthType = type;
49523                 if (!synthType.syntheticType) {
49524                     var file = ts.find(originalSymbol.declarations, ts.isSourceFile);
49525                     var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, false);
49526                     if (hasSyntheticDefault) {
49527                         var memberTable = ts.createSymbolTable();
49528                         var newSymbol = createSymbol(2097152, "default");
49529                         newSymbol.nameType = getLiteralType("default");
49530                         newSymbol.target = resolveSymbol(symbol);
49531                         memberTable.set("default", newSymbol);
49532                         var anonymousSymbol = createSymbol(2048, "__type");
49533                         var defaultContainingObject = createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, undefined, undefined);
49534                         anonymousSymbol.type = defaultContainingObject;
49535                         synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, 0, false) : defaultContainingObject;
49536                     }
49537                     else {
49538                         synthType.syntheticType = type;
49539                     }
49540                 }
49541                 return synthType.syntheticType;
49542             }
49543             return type;
49544         }
49545         function isCommonJsRequire(node) {
49546             if (!ts.isRequireCall(node, true)) {
49547                 return false;
49548             }
49549             if (!ts.isIdentifier(node.expression))
49550                 return ts.Debug.fail();
49551             var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551, undefined, undefined, true);
49552             if (resolvedRequire === requireSymbol) {
49553                 return true;
49554             }
49555             if (resolvedRequire.flags & 2097152) {
49556                 return false;
49557             }
49558             var targetDeclarationKind = resolvedRequire.flags & 16
49559                 ? 244
49560                 : resolvedRequire.flags & 3
49561                     ? 242
49562                     : 0;
49563             if (targetDeclarationKind !== 0) {
49564                 var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind);
49565                 return !!decl && !!(decl.flags & 8388608);
49566             }
49567             return false;
49568         }
49569         function checkTaggedTemplateExpression(node) {
49570             if (!checkGrammarTaggedTemplateChain(node))
49571                 checkGrammarTypeArguments(node, node.typeArguments);
49572             if (languageVersion < 2) {
49573                 checkExternalEmitHelpers(node, 131072);
49574             }
49575             return getReturnTypeOfSignature(getResolvedSignature(node));
49576         }
49577         function checkAssertion(node) {
49578             return checkAssertionWorker(node, node.type, node.expression);
49579         }
49580         function isValidConstAssertionArgument(node) {
49581             switch (node.kind) {
49582                 case 10:
49583                 case 14:
49584                 case 8:
49585                 case 9:
49586                 case 106:
49587                 case 91:
49588                 case 192:
49589                 case 193:
49590                     return true;
49591                 case 200:
49592                     return isValidConstAssertionArgument(node.expression);
49593                 case 207:
49594                     var op = node.operator;
49595                     var arg = node.operand;
49596                     return op === 40 && (arg.kind === 8 || arg.kind === 9) ||
49597                         op === 39 && arg.kind === 8;
49598                 case 194:
49599                 case 195:
49600                     var expr = node.expression;
49601                     if (ts.isIdentifier(expr)) {
49602                         var symbol = getSymbolAtLocation(expr);
49603                         if (symbol && symbol.flags & 2097152) {
49604                             symbol = resolveAlias(symbol);
49605                         }
49606                         return !!(symbol && (symbol.flags & 384) && getEnumKind(symbol) === 1);
49607                     }
49608             }
49609             return false;
49610         }
49611         function checkAssertionWorker(errNode, type, expression, checkMode) {
49612             var exprType = checkExpression(expression, checkMode);
49613             if (ts.isConstTypeReference(type)) {
49614                 if (!isValidConstAssertionArgument(expression)) {
49615                     error(expression, ts.Diagnostics.A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals);
49616                 }
49617                 return getRegularTypeOfLiteralType(exprType);
49618             }
49619             checkSourceElement(type);
49620             exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(exprType));
49621             var targetType = getTypeFromTypeNode(type);
49622             if (produceDiagnostics && targetType !== errorType) {
49623                 var widenedType = getWidenedType(exprType);
49624                 if (!isTypeComparableTo(targetType, widenedType)) {
49625                     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);
49626                 }
49627             }
49628             return targetType;
49629         }
49630         function checkNonNullChain(node) {
49631             var leftType = checkExpression(node.expression);
49632             var nonOptionalType = getOptionalExpressionType(leftType, node.expression);
49633             return propagateOptionalTypeMarker(getNonNullableType(nonOptionalType), node, nonOptionalType !== leftType);
49634         }
49635         function checkNonNullAssertion(node) {
49636             return node.flags & 32 ? checkNonNullChain(node) :
49637                 getNonNullableType(checkExpression(node.expression));
49638         }
49639         function checkMetaProperty(node) {
49640             checkGrammarMetaProperty(node);
49641             if (node.keywordToken === 99) {
49642                 return checkNewTargetMetaProperty(node);
49643             }
49644             if (node.keywordToken === 96) {
49645                 return checkImportMetaProperty(node);
49646             }
49647             return ts.Debug.assertNever(node.keywordToken);
49648         }
49649         function checkNewTargetMetaProperty(node) {
49650             var container = ts.getNewTargetContainer(node);
49651             if (!container) {
49652                 error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target");
49653                 return errorType;
49654             }
49655             else if (container.kind === 162) {
49656                 var symbol = getSymbolOfNode(container.parent);
49657                 return getTypeOfSymbol(symbol);
49658             }
49659             else {
49660                 var symbol = getSymbolOfNode(container);
49661                 return getTypeOfSymbol(symbol);
49662             }
49663         }
49664         function checkImportMetaProperty(node) {
49665             if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) {
49666                 error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system);
49667             }
49668             var file = ts.getSourceFileOfNode(node);
49669             ts.Debug.assert(!!(file.flags & 2097152), "Containing file is missing import meta node flag.");
49670             ts.Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module.");
49671             return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType;
49672         }
49673         function getTypeOfParameter(symbol) {
49674             var type = getTypeOfSymbol(symbol);
49675             if (strictNullChecks) {
49676                 var declaration = symbol.valueDeclaration;
49677                 if (declaration && ts.hasInitializer(declaration)) {
49678                     return getOptionalType(type);
49679                 }
49680             }
49681             return type;
49682         }
49683         function getParameterNameAtPosition(signature, pos) {
49684             var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
49685             if (pos < paramCount) {
49686                 return signature.parameters[pos].escapedName;
49687             }
49688             var restParameter = signature.parameters[paramCount] || unknownSymbol;
49689             var restType = getTypeOfSymbol(restParameter);
49690             if (isTupleType(restType)) {
49691                 var associatedNames = restType.target.associatedNames;
49692                 var index = pos - paramCount;
49693                 return associatedNames && associatedNames[index] || restParameter.escapedName + "_" + index;
49694             }
49695             return restParameter.escapedName;
49696         }
49697         function getTypeAtPosition(signature, pos) {
49698             return tryGetTypeAtPosition(signature, pos) || anyType;
49699         }
49700         function tryGetTypeAtPosition(signature, pos) {
49701             var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
49702             if (pos < paramCount) {
49703                 return getTypeOfParameter(signature.parameters[pos]);
49704             }
49705             if (signatureHasRestParameter(signature)) {
49706                 var restType = getTypeOfSymbol(signature.parameters[paramCount]);
49707                 var index = pos - paramCount;
49708                 if (!isTupleType(restType) || restType.target.hasRestElement || index < getTypeArguments(restType).length) {
49709                     return getIndexedAccessType(restType, getLiteralType(index));
49710                 }
49711             }
49712             return undefined;
49713         }
49714         function getRestTypeAtPosition(source, pos) {
49715             var paramCount = getParameterCount(source);
49716             var restType = getEffectiveRestType(source);
49717             var nonRestCount = paramCount - (restType ? 1 : 0);
49718             if (restType && pos === nonRestCount) {
49719                 return restType;
49720             }
49721             var types = [];
49722             var names = [];
49723             for (var i = pos; i < nonRestCount; i++) {
49724                 types.push(getTypeAtPosition(source, i));
49725                 names.push(getParameterNameAtPosition(source, i));
49726             }
49727             if (restType) {
49728                 types.push(getIndexedAccessType(restType, numberType));
49729                 names.push(getParameterNameAtPosition(source, nonRestCount));
49730             }
49731             var minArgumentCount = getMinArgumentCount(source);
49732             var minLength = minArgumentCount < pos ? 0 : minArgumentCount - pos;
49733             return createTupleType(types, minLength, !!restType, false, names);
49734         }
49735         function getParameterCount(signature) {
49736             var length = signature.parameters.length;
49737             if (signatureHasRestParameter(signature)) {
49738                 var restType = getTypeOfSymbol(signature.parameters[length - 1]);
49739                 if (isTupleType(restType)) {
49740                     return length + getTypeArguments(restType).length - 1;
49741                 }
49742             }
49743             return length;
49744         }
49745         function getMinArgumentCount(signature, strongArityForUntypedJS) {
49746             if (signatureHasRestParameter(signature)) {
49747                 var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
49748                 if (isTupleType(restType)) {
49749                     var minLength = restType.target.minLength;
49750                     if (minLength > 0) {
49751                         return signature.parameters.length - 1 + minLength;
49752                     }
49753                 }
49754             }
49755             if (!strongArityForUntypedJS && signature.flags & 16) {
49756                 return 0;
49757             }
49758             return signature.minArgumentCount;
49759         }
49760         function hasEffectiveRestParameter(signature) {
49761             if (signatureHasRestParameter(signature)) {
49762                 var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
49763                 return !isTupleType(restType) || restType.target.hasRestElement;
49764             }
49765             return false;
49766         }
49767         function getEffectiveRestType(signature) {
49768             if (signatureHasRestParameter(signature)) {
49769                 var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
49770                 return isTupleType(restType) ? getRestArrayTypeOfTupleType(restType) : restType;
49771             }
49772             return undefined;
49773         }
49774         function getNonArrayRestType(signature) {
49775             var restType = getEffectiveRestType(signature);
49776             return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072) === 0 ? restType : undefined;
49777         }
49778         function getTypeOfFirstParameterOfSignature(signature) {
49779             return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType);
49780         }
49781         function getTypeOfFirstParameterOfSignatureWithFallback(signature, fallbackType) {
49782             return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : fallbackType;
49783         }
49784         function inferFromAnnotatedParameters(signature, context, inferenceContext) {
49785             var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
49786             for (var i = 0; i < len; i++) {
49787                 var declaration = signature.parameters[i].valueDeclaration;
49788                 if (declaration.type) {
49789                     var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
49790                     if (typeNode) {
49791                         inferTypes(inferenceContext.inferences, getTypeFromTypeNode(typeNode), getTypeAtPosition(context, i));
49792                     }
49793                 }
49794             }
49795             var restType = getEffectiveRestType(context);
49796             if (restType && restType.flags & 262144) {
49797                 var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper);
49798                 assignContextualParameterTypes(signature, instantiatedContext);
49799                 var restPos = getParameterCount(context) - 1;
49800                 inferTypes(inferenceContext.inferences, getRestTypeAtPosition(signature, restPos), restType);
49801             }
49802         }
49803         function assignContextualParameterTypes(signature, context) {
49804             signature.typeParameters = context.typeParameters;
49805             if (context.thisParameter) {
49806                 var parameter = signature.thisParameter;
49807                 if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) {
49808                     if (!parameter) {
49809                         signature.thisParameter = createSymbolWithType(context.thisParameter, undefined);
49810                     }
49811                     assignParameterType(signature.thisParameter, getTypeOfSymbol(context.thisParameter));
49812                 }
49813             }
49814             var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
49815             for (var i = 0; i < len; i++) {
49816                 var parameter = signature.parameters[i];
49817                 if (!ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) {
49818                     var contextualParameterType = tryGetTypeAtPosition(context, i);
49819                     assignParameterType(parameter, contextualParameterType);
49820                 }
49821             }
49822             if (signatureHasRestParameter(signature)) {
49823                 var parameter = ts.last(signature.parameters);
49824                 if (ts.isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) {
49825                     var contextualParameterType = getRestTypeAtPosition(context, len);
49826                     assignParameterType(parameter, contextualParameterType);
49827                 }
49828             }
49829         }
49830         function assignNonContextualParameterTypes(signature) {
49831             if (signature.thisParameter) {
49832                 assignParameterType(signature.thisParameter);
49833             }
49834             for (var _i = 0, _a = signature.parameters; _i < _a.length; _i++) {
49835                 var parameter = _a[_i];
49836                 assignParameterType(parameter);
49837             }
49838         }
49839         function assignParameterType(parameter, type) {
49840             var links = getSymbolLinks(parameter);
49841             if (!links.type) {
49842                 var declaration = parameter.valueDeclaration;
49843                 links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, true);
49844                 if (declaration.name.kind !== 75) {
49845                     if (links.type === unknownType) {
49846                         links.type = getTypeFromBindingPattern(declaration.name);
49847                     }
49848                     assignBindingElementTypes(declaration.name);
49849                 }
49850             }
49851         }
49852         function assignBindingElementTypes(pattern) {
49853             for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
49854                 var element = _a[_i];
49855                 if (!ts.isOmittedExpression(element)) {
49856                     if (element.name.kind === 75) {
49857                         getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element);
49858                     }
49859                     else {
49860                         assignBindingElementTypes(element.name);
49861                     }
49862                 }
49863             }
49864         }
49865         function createPromiseType(promisedType) {
49866             var globalPromiseType = getGlobalPromiseType(true);
49867             if (globalPromiseType !== emptyGenericType) {
49868                 promisedType = getAwaitedType(promisedType) || unknownType;
49869                 return createTypeReference(globalPromiseType, [promisedType]);
49870             }
49871             return unknownType;
49872         }
49873         function createPromiseLikeType(promisedType) {
49874             var globalPromiseLikeType = getGlobalPromiseLikeType(true);
49875             if (globalPromiseLikeType !== emptyGenericType) {
49876                 promisedType = getAwaitedType(promisedType) || unknownType;
49877                 return createTypeReference(globalPromiseLikeType, [promisedType]);
49878             }
49879             return unknownType;
49880         }
49881         function createPromiseReturnType(func, promisedType) {
49882             var promiseType = createPromiseType(promisedType);
49883             if (promiseType === unknownType) {
49884                 error(func, ts.isImportCall(func) ?
49885                     ts.Diagnostics.A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option :
49886                     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);
49887                 return errorType;
49888             }
49889             else if (!getGlobalPromiseConstructorSymbol(true)) {
49890                 error(func, ts.isImportCall(func) ?
49891                     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 :
49892                     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);
49893             }
49894             return promiseType;
49895         }
49896         function getReturnTypeFromBody(func, checkMode) {
49897             if (!func.body) {
49898                 return errorType;
49899             }
49900             var functionFlags = ts.getFunctionFlags(func);
49901             var isAsync = (functionFlags & 2) !== 0;
49902             var isGenerator = (functionFlags & 1) !== 0;
49903             var returnType;
49904             var yieldType;
49905             var nextType;
49906             var fallbackReturnType = voidType;
49907             if (func.body.kind !== 223) {
49908                 returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8);
49909                 if (isAsync) {
49910                     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);
49911                 }
49912             }
49913             else if (isGenerator) {
49914                 var returnTypes = checkAndAggregateReturnExpressionTypes(func, checkMode);
49915                 if (!returnTypes) {
49916                     fallbackReturnType = neverType;
49917                 }
49918                 else if (returnTypes.length > 0) {
49919                     returnType = getUnionType(returnTypes, 2);
49920                 }
49921                 var _a = checkAndAggregateYieldOperandTypes(func, checkMode), yieldTypes = _a.yieldTypes, nextTypes = _a.nextTypes;
49922                 yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2) : undefined;
49923                 nextType = ts.some(nextTypes) ? getIntersectionType(nextTypes) : undefined;
49924             }
49925             else {
49926                 var types = checkAndAggregateReturnExpressionTypes(func, checkMode);
49927                 if (!types) {
49928                     return functionFlags & 2
49929                         ? createPromiseReturnType(func, neverType)
49930                         : neverType;
49931                 }
49932                 if (types.length === 0) {
49933                     return functionFlags & 2
49934                         ? createPromiseReturnType(func, voidType)
49935                         : voidType;
49936                 }
49937                 returnType = getUnionType(types, 2);
49938             }
49939             if (returnType || yieldType || nextType) {
49940                 if (yieldType)
49941                     reportErrorsFromWidening(func, yieldType, 3);
49942                 if (returnType)
49943                     reportErrorsFromWidening(func, returnType, 1);
49944                 if (nextType)
49945                     reportErrorsFromWidening(func, nextType, 2);
49946                 if (returnType && isUnitType(returnType) ||
49947                     yieldType && isUnitType(yieldType) ||
49948                     nextType && isUnitType(nextType)) {
49949                     var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func);
49950                     var contextualType = !contextualSignature ? undefined :
49951                         contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType :
49952                             instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func);
49953                     if (isGenerator) {
49954                         yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0, isAsync);
49955                         returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1, isAsync);
49956                         nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2, isAsync);
49957                     }
49958                     else {
49959                         returnType = getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(returnType, contextualType, isAsync);
49960                     }
49961                 }
49962                 if (yieldType)
49963                     yieldType = getWidenedType(yieldType);
49964                 if (returnType)
49965                     returnType = getWidenedType(returnType);
49966                 if (nextType)
49967                     nextType = getWidenedType(nextType);
49968             }
49969             if (isGenerator) {
49970                 return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2, func) || unknownType, isAsync);
49971             }
49972             else {
49973                 return isAsync
49974                     ? createPromiseType(returnType || fallbackReturnType)
49975                     : returnType || fallbackReturnType;
49976             }
49977         }
49978         function createGeneratorReturnType(yieldType, returnType, nextType, isAsyncGenerator) {
49979             var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
49980             var globalGeneratorType = resolver.getGlobalGeneratorType(false);
49981             yieldType = resolver.resolveIterationType(yieldType, undefined) || unknownType;
49982             returnType = resolver.resolveIterationType(returnType, undefined) || unknownType;
49983             nextType = resolver.resolveIterationType(nextType, undefined) || unknownType;
49984             if (globalGeneratorType === emptyGenericType) {
49985                 var globalType = resolver.getGlobalIterableIteratorType(false);
49986                 var iterationTypes = globalType !== emptyGenericType ? getIterationTypesOfGlobalIterableType(globalType, resolver) : undefined;
49987                 var iterableIteratorReturnType = iterationTypes ? iterationTypes.returnType : anyType;
49988                 var iterableIteratorNextType = iterationTypes ? iterationTypes.nextType : undefinedType;
49989                 if (isTypeAssignableTo(returnType, iterableIteratorReturnType) &&
49990                     isTypeAssignableTo(iterableIteratorNextType, nextType)) {
49991                     if (globalType !== emptyGenericType) {
49992                         return createTypeFromGenericGlobalType(globalType, [yieldType]);
49993                     }
49994                     resolver.getGlobalIterableIteratorType(true);
49995                     return emptyObjectType;
49996                 }
49997                 resolver.getGlobalGeneratorType(true);
49998                 return emptyObjectType;
49999             }
50000             return createTypeFromGenericGlobalType(globalGeneratorType, [yieldType, returnType, nextType]);
50001         }
50002         function checkAndAggregateYieldOperandTypes(func, checkMode) {
50003             var yieldTypes = [];
50004             var nextTypes = [];
50005             var isAsync = (ts.getFunctionFlags(func) & 2) !== 0;
50006             ts.forEachYieldExpression(func.body, function (yieldExpression) {
50007                 var yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType;
50008                 ts.pushIfUnique(yieldTypes, getYieldedTypeOfYieldExpression(yieldExpression, yieldExpressionType, anyType, isAsync));
50009                 var nextType;
50010                 if (yieldExpression.asteriskToken) {
50011                     var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 : 17, yieldExpression.expression);
50012                     nextType = iterationTypes && iterationTypes.nextType;
50013                 }
50014                 else {
50015                     nextType = getContextualType(yieldExpression);
50016                 }
50017                 if (nextType)
50018                     ts.pushIfUnique(nextTypes, nextType);
50019             });
50020             return { yieldTypes: yieldTypes, nextTypes: nextTypes };
50021         }
50022         function getYieldedTypeOfYieldExpression(node, expressionType, sentType, isAsync) {
50023             var errorNode = node.expression || node;
50024             var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 : 17, expressionType, sentType, errorNode) : expressionType;
50025             return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken
50026                 ? 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
50027                 : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
50028         }
50029         function getFactsFromTypeofSwitch(start, end, witnesses, hasDefault) {
50030             var facts = 0;
50031             if (hasDefault) {
50032                 for (var i = end; i < witnesses.length; i++) {
50033                     facts |= typeofNEFacts.get(witnesses[i]) || 32768;
50034                 }
50035                 for (var i = start; i < end; i++) {
50036                     facts &= ~(typeofNEFacts.get(witnesses[i]) || 0);
50037                 }
50038                 for (var i = 0; i < start; i++) {
50039                     facts |= typeofNEFacts.get(witnesses[i]) || 32768;
50040                 }
50041             }
50042             else {
50043                 for (var i = start; i < end; i++) {
50044                     facts |= typeofEQFacts.get(witnesses[i]) || 128;
50045                 }
50046                 for (var i = 0; i < start; i++) {
50047                     facts &= ~(typeofEQFacts.get(witnesses[i]) || 0);
50048                 }
50049             }
50050             return facts;
50051         }
50052         function isExhaustiveSwitchStatement(node) {
50053             var links = getNodeLinks(node);
50054             return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node));
50055         }
50056         function computeExhaustiveSwitchStatement(node) {
50057             if (node.expression.kind === 204) {
50058                 var operandType = getTypeOfExpression(node.expression.expression);
50059                 var witnesses = getSwitchClauseTypeOfWitnesses(node, false);
50060                 var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, true);
50061                 var type_3 = getBaseConstraintOfType(operandType) || operandType;
50062                 return !!(filterType(type_3, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072);
50063             }
50064             var type = getTypeOfExpression(node.expression);
50065             if (!isLiteralType(type)) {
50066                 return false;
50067             }
50068             var switchTypes = getSwitchClauseTypes(node);
50069             if (!switchTypes.length || ts.some(switchTypes, isNeitherUnitTypeNorNever)) {
50070                 return false;
50071             }
50072             return eachTypeContainedIn(mapType(type, getRegularTypeOfLiteralType), switchTypes);
50073         }
50074         function functionHasImplicitReturn(func) {
50075             return func.endFlowNode && isReachableFlowNode(func.endFlowNode);
50076         }
50077         function checkAndAggregateReturnExpressionTypes(func, checkMode) {
50078             var functionFlags = ts.getFunctionFlags(func);
50079             var aggregatedTypes = [];
50080             var hasReturnWithNoExpression = functionHasImplicitReturn(func);
50081             var hasReturnOfTypeNever = false;
50082             ts.forEachReturnStatement(func.body, function (returnStatement) {
50083                 var expr = returnStatement.expression;
50084                 if (expr) {
50085                     var type = checkExpressionCached(expr, checkMode && checkMode & ~8);
50086                     if (functionFlags & 2) {
50087                         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);
50088                     }
50089                     if (type.flags & 131072) {
50090                         hasReturnOfTypeNever = true;
50091                     }
50092                     ts.pushIfUnique(aggregatedTypes, type);
50093                 }
50094                 else {
50095                     hasReturnWithNoExpression = true;
50096                 }
50097             });
50098             if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || mayReturnNever(func))) {
50099                 return undefined;
50100             }
50101             if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression &&
50102                 !(isJSConstructor(func) && aggregatedTypes.some(function (t) { return t.symbol === func.symbol; }))) {
50103                 ts.pushIfUnique(aggregatedTypes, undefinedType);
50104             }
50105             return aggregatedTypes;
50106         }
50107         function mayReturnNever(func) {
50108             switch (func.kind) {
50109                 case 201:
50110                 case 202:
50111                     return true;
50112                 case 161:
50113                     return func.parent.kind === 193;
50114                 default:
50115                     return false;
50116             }
50117         }
50118         function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) {
50119             if (!produceDiagnostics) {
50120                 return;
50121             }
50122             var functionFlags = ts.getFunctionFlags(func);
50123             var type = returnType && unwrapReturnType(returnType, functionFlags);
50124             if (type && maybeTypeOfKind(type, 1 | 16384)) {
50125                 return;
50126             }
50127             if (func.kind === 160 || ts.nodeIsMissing(func.body) || func.body.kind !== 223 || !functionHasImplicitReturn(func)) {
50128                 return;
50129             }
50130             var hasExplicitReturn = func.flags & 512;
50131             if (type && type.flags & 131072) {
50132                 error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
50133             }
50134             else if (type && !hasExplicitReturn) {
50135                 error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
50136             }
50137             else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
50138                 error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
50139             }
50140             else if (compilerOptions.noImplicitReturns) {
50141                 if (!type) {
50142                     if (!hasExplicitReturn) {
50143                         return;
50144                     }
50145                     var inferredReturnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func));
50146                     if (isUnwrappedReturnTypeVoidOrAny(func, inferredReturnType)) {
50147                         return;
50148                     }
50149                 }
50150                 error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Not_all_code_paths_return_a_value);
50151             }
50152         }
50153         function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) {
50154             ts.Debug.assert(node.kind !== 161 || ts.isObjectLiteralMethod(node));
50155             checkNodeDeferred(node);
50156             if (checkMode && checkMode & 4 && isContextSensitive(node)) {
50157                 if (!ts.getEffectiveReturnTypeNode(node) && !hasContextSensitiveParameters(node)) {
50158                     var contextualSignature = getContextualSignature(node);
50159                     if (contextualSignature && couldContainTypeVariables(getReturnTypeOfSignature(contextualSignature))) {
50160                         var links = getNodeLinks(node);
50161                         if (links.contextFreeType) {
50162                             return links.contextFreeType;
50163                         }
50164                         var returnType = getReturnTypeFromBody(node, checkMode);
50165                         var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, undefined, 0, 0);
50166                         var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, undefined, undefined);
50167                         returnOnlyType.objectFlags |= 2097152;
50168                         return links.contextFreeType = returnOnlyType;
50169                     }
50170                 }
50171                 return anyFunctionType;
50172             }
50173             var hasGrammarError = checkGrammarFunctionLikeDeclaration(node);
50174             if (!hasGrammarError && node.kind === 201) {
50175                 checkGrammarForGenerator(node);
50176             }
50177             contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode);
50178             return getTypeOfSymbol(getSymbolOfNode(node));
50179         }
50180         function contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode) {
50181             var links = getNodeLinks(node);
50182             if (!(links.flags & 1024)) {
50183                 var contextualSignature = getContextualSignature(node);
50184                 if (!(links.flags & 1024)) {
50185                     links.flags |= 1024;
50186                     var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0));
50187                     if (!signature) {
50188                         return;
50189                     }
50190                     if (isContextSensitive(node)) {
50191                         if (contextualSignature) {
50192                             var inferenceContext = getInferenceContext(node);
50193                             if (checkMode && checkMode & 2) {
50194                                 inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
50195                             }
50196                             var instantiatedContextualSignature = inferenceContext ?
50197                                 instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature;
50198                             assignContextualParameterTypes(signature, instantiatedContextualSignature);
50199                         }
50200                         else {
50201                             assignNonContextualParameterTypes(signature);
50202                         }
50203                     }
50204                     if (contextualSignature && !getReturnTypeFromAnnotation(node) && !signature.resolvedReturnType) {
50205                         var returnType = getReturnTypeFromBody(node, checkMode);
50206                         if (!signature.resolvedReturnType) {
50207                             signature.resolvedReturnType = returnType;
50208                         }
50209                     }
50210                     checkSignatureDeclaration(node);
50211                 }
50212             }
50213         }
50214         function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) {
50215             ts.Debug.assert(node.kind !== 161 || ts.isObjectLiteralMethod(node));
50216             var functionFlags = ts.getFunctionFlags(node);
50217             var returnType = getReturnTypeFromAnnotation(node);
50218             checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType);
50219             if (node.body) {
50220                 if (!ts.getEffectiveReturnTypeNode(node)) {
50221                     getReturnTypeOfSignature(getSignatureFromDeclaration(node));
50222                 }
50223                 if (node.body.kind === 223) {
50224                     checkSourceElement(node.body);
50225                 }
50226                 else {
50227                     var exprType = checkExpression(node.body);
50228                     var returnOrPromisedType = returnType && unwrapReturnType(returnType, functionFlags);
50229                     if (returnOrPromisedType) {
50230                         if ((functionFlags & 3) === 2) {
50231                             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);
50232                             checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body);
50233                         }
50234                         else {
50235                             checkTypeAssignableToAndOptionallyElaborate(exprType, returnOrPromisedType, node.body, node.body);
50236                         }
50237                     }
50238                 }
50239             }
50240         }
50241         function checkArithmeticOperandType(operand, type, diagnostic, isAwaitValid) {
50242             if (isAwaitValid === void 0) { isAwaitValid = false; }
50243             if (!isTypeAssignableTo(type, numberOrBigIntType)) {
50244                 var awaitedType = isAwaitValid && getAwaitedTypeOfPromise(type);
50245                 errorAndMaybeSuggestAwait(operand, !!awaitedType && isTypeAssignableTo(awaitedType, numberOrBigIntType), diagnostic);
50246                 return false;
50247             }
50248             return true;
50249         }
50250         function isReadonlyAssignmentDeclaration(d) {
50251             if (!ts.isCallExpression(d)) {
50252                 return false;
50253             }
50254             if (!ts.isBindableObjectDefinePropertyCall(d)) {
50255                 return false;
50256             }
50257             var objectLitType = checkExpressionCached(d.arguments[2]);
50258             var valueType = getTypeOfPropertyOfType(objectLitType, "value");
50259             if (valueType) {
50260                 var writableProp = getPropertyOfType(objectLitType, "writable");
50261                 var writableType = writableProp && getTypeOfSymbol(writableProp);
50262                 if (!writableType || writableType === falseType || writableType === regularFalseType) {
50263                     return true;
50264                 }
50265                 if (writableProp && writableProp.valueDeclaration && ts.isPropertyAssignment(writableProp.valueDeclaration)) {
50266                     var initializer = writableProp.valueDeclaration.initializer;
50267                     var rawOriginalType = checkExpression(initializer);
50268                     if (rawOriginalType === falseType || rawOriginalType === regularFalseType) {
50269                         return true;
50270                     }
50271                 }
50272                 return false;
50273             }
50274             var setProp = getPropertyOfType(objectLitType, "set");
50275             return !setProp;
50276         }
50277         function isReadonlySymbol(symbol) {
50278             return !!(ts.getCheckFlags(symbol) & 8 ||
50279                 symbol.flags & 4 && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 ||
50280                 symbol.flags & 3 && getDeclarationNodeFlagsFromSymbol(symbol) & 2 ||
50281                 symbol.flags & 98304 && !(symbol.flags & 65536) ||
50282                 symbol.flags & 8 ||
50283                 ts.some(symbol.declarations, isReadonlyAssignmentDeclaration));
50284         }
50285         function isAssignmentToReadonlyEntity(expr, symbol, assignmentKind) {
50286             var _a, _b;
50287             if (assignmentKind === 0) {
50288                 return false;
50289             }
50290             if (isReadonlySymbol(symbol)) {
50291                 if (symbol.flags & 4 &&
50292                     ts.isAccessExpression(expr) &&
50293                     expr.expression.kind === 104) {
50294                     var ctor = ts.getContainingFunction(expr);
50295                     if (!(ctor && ctor.kind === 162)) {
50296                         return true;
50297                     }
50298                     if (symbol.valueDeclaration) {
50299                         var isAssignmentDeclaration_1 = ts.isBinaryExpression(symbol.valueDeclaration);
50300                         var isLocalPropertyDeclaration = ctor.parent === symbol.valueDeclaration.parent;
50301                         var isLocalParameterProperty = ctor === symbol.valueDeclaration.parent;
50302                         var isLocalThisPropertyAssignment = isAssignmentDeclaration_1 && ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) === ctor.parent;
50303                         var isLocalThisPropertyAssignmentConstructorFunction = isAssignmentDeclaration_1 && ((_b = symbol.parent) === null || _b === void 0 ? void 0 : _b.valueDeclaration) === ctor;
50304                         var isWriteableSymbol = isLocalPropertyDeclaration
50305                             || isLocalParameterProperty
50306                             || isLocalThisPropertyAssignment
50307                             || isLocalThisPropertyAssignmentConstructorFunction;
50308                         return !isWriteableSymbol;
50309                     }
50310                 }
50311                 return true;
50312             }
50313             if (ts.isAccessExpression(expr)) {
50314                 var node = ts.skipParentheses(expr.expression);
50315                 if (node.kind === 75) {
50316                     var symbol_2 = getNodeLinks(node).resolvedSymbol;
50317                     if (symbol_2.flags & 2097152) {
50318                         var declaration = getDeclarationOfAliasSymbol(symbol_2);
50319                         return !!declaration && declaration.kind === 256;
50320                     }
50321                 }
50322             }
50323             return false;
50324         }
50325         function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) {
50326             var node = ts.skipOuterExpressions(expr, 6 | 1);
50327             if (node.kind !== 75 && !ts.isAccessExpression(node)) {
50328                 error(expr, invalidReferenceMessage);
50329                 return false;
50330             }
50331             if (node.flags & 32) {
50332                 error(expr, invalidOptionalChainMessage);
50333                 return false;
50334             }
50335             return true;
50336         }
50337         function checkDeleteExpression(node) {
50338             checkExpression(node.expression);
50339             var expr = ts.skipParentheses(node.expression);
50340             if (!ts.isAccessExpression(expr)) {
50341                 error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference);
50342                 return booleanType;
50343             }
50344             if (expr.kind === 194 && ts.isPrivateIdentifier(expr.name)) {
50345                 error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_private_identifier);
50346             }
50347             var links = getNodeLinks(expr);
50348             var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol);
50349             if (symbol && isReadonlySymbol(symbol)) {
50350                 error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property);
50351             }
50352             return booleanType;
50353         }
50354         function checkTypeOfExpression(node) {
50355             checkExpression(node.expression);
50356             return typeofType;
50357         }
50358         function checkVoidExpression(node) {
50359             checkExpression(node.expression);
50360             return undefinedWideningType;
50361         }
50362         function isTopLevelAwait(node) {
50363             var container = ts.getThisContainer(node, true);
50364             return ts.isSourceFile(container);
50365         }
50366         function checkAwaitExpression(node) {
50367             if (produceDiagnostics) {
50368                 if (!(node.flags & 32768)) {
50369                     if (isTopLevelAwait(node)) {
50370                         var sourceFile = ts.getSourceFileOfNode(node);
50371                         if (!hasParseDiagnostics(sourceFile)) {
50372                             var span = void 0;
50373                             if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
50374                                 if (!span)
50375                                     span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
50376                                 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);
50377                                 diagnostics.add(diagnostic);
50378                             }
50379                             if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) || languageVersion < 4) {
50380                                 span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
50381                                 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);
50382                                 diagnostics.add(diagnostic);
50383                             }
50384                         }
50385                     }
50386                     else {
50387                         var sourceFile = ts.getSourceFileOfNode(node);
50388                         if (!hasParseDiagnostics(sourceFile)) {
50389                             var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
50390                             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);
50391                             var func = ts.getContainingFunction(node);
50392                             if (func && func.kind !== 162 && (ts.getFunctionFlags(func) & 2) === 0) {
50393                                 var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
50394                                 ts.addRelatedInfo(diagnostic, relatedInfo);
50395                             }
50396                             diagnostics.add(diagnostic);
50397                         }
50398                     }
50399                 }
50400                 if (isInParameterInitializerBeforeContainingFunction(node)) {
50401                     error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer);
50402                 }
50403             }
50404             var operandType = checkExpression(node.expression);
50405             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);
50406             if (awaitedType === operandType && awaitedType !== errorType && !(operandType.flags & 3)) {
50407                 addErrorOrSuggestion(false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression));
50408             }
50409             return awaitedType;
50410         }
50411         function checkPrefixUnaryExpression(node) {
50412             var operandType = checkExpression(node.operand);
50413             if (operandType === silentNeverType) {
50414                 return silentNeverType;
50415             }
50416             switch (node.operand.kind) {
50417                 case 8:
50418                     switch (node.operator) {
50419                         case 40:
50420                             return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text));
50421                         case 39:
50422                             return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text));
50423                     }
50424                     break;
50425                 case 9:
50426                     if (node.operator === 40) {
50427                         return getFreshTypeOfLiteralType(getLiteralType({
50428                             negative: true,
50429                             base10Value: ts.parsePseudoBigInt(node.operand.text)
50430                         }));
50431                     }
50432             }
50433             switch (node.operator) {
50434                 case 39:
50435                 case 40:
50436                 case 54:
50437                     checkNonNullType(operandType, node.operand);
50438                     if (maybeTypeOfKind(operandType, 12288)) {
50439                         error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator));
50440                     }
50441                     if (node.operator === 39) {
50442                         if (maybeTypeOfKind(operandType, 2112)) {
50443                             error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType)));
50444                         }
50445                         return numberType;
50446                     }
50447                     return getUnaryResultType(operandType);
50448                 case 53:
50449                     checkTruthinessExpression(node.operand);
50450                     var facts = getTypeFacts(operandType) & (4194304 | 8388608);
50451                     return facts === 4194304 ? falseType :
50452                         facts === 8388608 ? trueType :
50453                             booleanType;
50454                 case 45:
50455                 case 46:
50456                     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);
50457                     if (ok) {
50458                         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);
50459                     }
50460                     return getUnaryResultType(operandType);
50461             }
50462             return errorType;
50463         }
50464         function checkPostfixUnaryExpression(node) {
50465             var operandType = checkExpression(node.operand);
50466             if (operandType === silentNeverType) {
50467                 return silentNeverType;
50468             }
50469             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);
50470             if (ok) {
50471                 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);
50472             }
50473             return getUnaryResultType(operandType);
50474         }
50475         function getUnaryResultType(operandType) {
50476             if (maybeTypeOfKind(operandType, 2112)) {
50477                 return isTypeAssignableToKind(operandType, 3) || maybeTypeOfKind(operandType, 296)
50478                     ? numberOrBigIntType
50479                     : bigintType;
50480             }
50481             return numberType;
50482         }
50483         function maybeTypeOfKind(type, kind) {
50484             if (type.flags & kind) {
50485                 return true;
50486             }
50487             if (type.flags & 3145728) {
50488                 var types = type.types;
50489                 for (var _i = 0, types_19 = types; _i < types_19.length; _i++) {
50490                     var t = types_19[_i];
50491                     if (maybeTypeOfKind(t, kind)) {
50492                         return true;
50493                     }
50494                 }
50495             }
50496             return false;
50497         }
50498         function isTypeAssignableToKind(source, kind, strict) {
50499             if (source.flags & kind) {
50500                 return true;
50501             }
50502             if (strict && source.flags & (3 | 16384 | 32768 | 65536)) {
50503                 return false;
50504             }
50505             return !!(kind & 296) && isTypeAssignableTo(source, numberType) ||
50506                 !!(kind & 2112) && isTypeAssignableTo(source, bigintType) ||
50507                 !!(kind & 132) && isTypeAssignableTo(source, stringType) ||
50508                 !!(kind & 528) && isTypeAssignableTo(source, booleanType) ||
50509                 !!(kind & 16384) && isTypeAssignableTo(source, voidType) ||
50510                 !!(kind & 131072) && isTypeAssignableTo(source, neverType) ||
50511                 !!(kind & 65536) && isTypeAssignableTo(source, nullType) ||
50512                 !!(kind & 32768) && isTypeAssignableTo(source, undefinedType) ||
50513                 !!(kind & 4096) && isTypeAssignableTo(source, esSymbolType) ||
50514                 !!(kind & 67108864) && isTypeAssignableTo(source, nonPrimitiveType);
50515         }
50516         function allTypesAssignableToKind(source, kind, strict) {
50517             return source.flags & 1048576 ?
50518                 ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) :
50519                 isTypeAssignableToKind(source, kind, strict);
50520         }
50521         function isConstEnumObjectType(type) {
50522             return !!(ts.getObjectFlags(type) & 16) && !!type.symbol && isConstEnumSymbol(type.symbol);
50523         }
50524         function isConstEnumSymbol(symbol) {
50525             return (symbol.flags & 128) !== 0;
50526         }
50527         function checkInstanceOfExpression(left, right, leftType, rightType) {
50528             if (leftType === silentNeverType || rightType === silentNeverType) {
50529                 return silentNeverType;
50530             }
50531             if (!isTypeAny(leftType) &&
50532                 allTypesAssignableToKind(leftType, 131068)) {
50533                 error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
50534             }
50535             if (!(isTypeAny(rightType) || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
50536                 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);
50537             }
50538             return booleanType;
50539         }
50540         function checkInExpression(left, right, leftType, rightType) {
50541             if (leftType === silentNeverType || rightType === silentNeverType) {
50542                 return silentNeverType;
50543             }
50544             leftType = checkNonNullType(leftType, left);
50545             rightType = checkNonNullType(rightType, right);
50546             if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 296 | 12288))) {
50547                 error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
50548             }
50549             if (!allTypesAssignableToKind(rightType, 67108864 | 58982400)) {
50550                 error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
50551             }
50552             return booleanType;
50553         }
50554         function checkObjectLiteralAssignment(node, sourceType, rightIsThis) {
50555             var properties = node.properties;
50556             if (strictNullChecks && properties.length === 0) {
50557                 return checkNonNullType(sourceType, node);
50558             }
50559             for (var i = 0; i < properties.length; i++) {
50560                 checkObjectLiteralDestructuringPropertyAssignment(node, sourceType, i, properties, rightIsThis);
50561             }
50562             return sourceType;
50563         }
50564         function checkObjectLiteralDestructuringPropertyAssignment(node, objectLiteralType, propertyIndex, allProperties, rightIsThis) {
50565             if (rightIsThis === void 0) { rightIsThis = false; }
50566             var properties = node.properties;
50567             var property = properties[propertyIndex];
50568             if (property.kind === 281 || property.kind === 282) {
50569                 var name = property.name;
50570                 var exprType = getLiteralTypeFromPropertyName(name);
50571                 if (isTypeUsableAsPropertyName(exprType)) {
50572                     var text = getPropertyNameFromType(exprType);
50573                     var prop = getPropertyOfType(objectLiteralType, text);
50574                     if (prop) {
50575                         markPropertyAsReferenced(prop, property, rightIsThis);
50576                         checkPropertyAccessibility(property, false, objectLiteralType, prop);
50577                     }
50578                 }
50579                 var elementType = getIndexedAccessType(objectLiteralType, exprType, name);
50580                 var type = getFlowTypeOfDestructuring(property, elementType);
50581                 return checkDestructuringAssignment(property.kind === 282 ? property : property.initializer, type);
50582             }
50583             else if (property.kind === 283) {
50584                 if (propertyIndex < properties.length - 1) {
50585                     error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
50586                 }
50587                 else {
50588                     if (languageVersion < 99) {
50589                         checkExternalEmitHelpers(property, 4);
50590                     }
50591                     var nonRestNames = [];
50592                     if (allProperties) {
50593                         for (var _i = 0, allProperties_1 = allProperties; _i < allProperties_1.length; _i++) {
50594                             var otherProperty = allProperties_1[_i];
50595                             if (!ts.isSpreadAssignment(otherProperty)) {
50596                                 nonRestNames.push(otherProperty.name);
50597                             }
50598                         }
50599                     }
50600                     var type = getRestType(objectLiteralType, nonRestNames, objectLiteralType.symbol);
50601                     checkGrammarForDisallowedTrailingComma(allProperties, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
50602                     return checkDestructuringAssignment(property.expression, type);
50603                 }
50604             }
50605             else {
50606                 error(property, ts.Diagnostics.Property_assignment_expected);
50607             }
50608         }
50609         function checkArrayLiteralAssignment(node, sourceType, checkMode) {
50610             var elements = node.elements;
50611             if (languageVersion < 2 && compilerOptions.downlevelIteration) {
50612                 checkExternalEmitHelpers(node, 512);
50613             }
50614             var elementType = checkIteratedTypeOrElementType(65, sourceType, undefinedType, node) || errorType;
50615             for (var i = 0; i < elements.length; i++) {
50616                 checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, checkMode);
50617             }
50618             return sourceType;
50619         }
50620         function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) {
50621             var elements = node.elements;
50622             var element = elements[elementIndex];
50623             if (element.kind !== 215) {
50624                 if (element.kind !== 213) {
50625                     var indexType = getLiteralType(elementIndex);
50626                     if (isArrayLikeType(sourceType)) {
50627                         var accessFlags = hasDefaultValue(element) ? 8 : 0;
50628                         var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, createSyntheticExpression(element, indexType), accessFlags) || errorType;
50629                         var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288) : elementType_2;
50630                         var type = getFlowTypeOfDestructuring(element, assignedType);
50631                         return checkDestructuringAssignment(element, type, checkMode);
50632                     }
50633                     return checkDestructuringAssignment(element, elementType, checkMode);
50634                 }
50635                 if (elementIndex < elements.length - 1) {
50636                     error(element, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
50637                 }
50638                 else {
50639                     var restExpression = element.expression;
50640                     if (restExpression.kind === 209 && restExpression.operatorToken.kind === 62) {
50641                         error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer);
50642                     }
50643                     else {
50644                         checkGrammarForDisallowedTrailingComma(node.elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
50645                         var type = everyType(sourceType, isTupleType) ?
50646                             mapType(sourceType, function (t) { return sliceTupleType(t, elementIndex); }) :
50647                             createArrayType(elementType);
50648                         return checkDestructuringAssignment(restExpression, type, checkMode);
50649                     }
50650                 }
50651             }
50652             return undefined;
50653         }
50654         function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) {
50655             var target;
50656             if (exprOrAssignment.kind === 282) {
50657                 var prop = exprOrAssignment;
50658                 if (prop.objectAssignmentInitializer) {
50659                     if (strictNullChecks &&
50660                         !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768)) {
50661                         sourceType = getTypeWithFacts(sourceType, 524288);
50662                     }
50663                     checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode);
50664                 }
50665                 target = exprOrAssignment.name;
50666             }
50667             else {
50668                 target = exprOrAssignment;
50669             }
50670             if (target.kind === 209 && target.operatorToken.kind === 62) {
50671                 checkBinaryExpression(target, checkMode);
50672                 target = target.left;
50673             }
50674             if (target.kind === 193) {
50675                 return checkObjectLiteralAssignment(target, sourceType, rightIsThis);
50676             }
50677             if (target.kind === 192) {
50678                 return checkArrayLiteralAssignment(target, sourceType, checkMode);
50679             }
50680             return checkReferenceAssignment(target, sourceType, checkMode);
50681         }
50682         function checkReferenceAssignment(target, sourceType, checkMode) {
50683             var targetType = checkExpression(target, checkMode);
50684             var error = target.parent.kind === 283 ?
50685                 ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access :
50686                 ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access;
50687             var optionalError = target.parent.kind === 283 ?
50688                 ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access :
50689                 ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access;
50690             if (checkReferenceExpression(target, error, optionalError)) {
50691                 checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target);
50692             }
50693             if (ts.isPrivateIdentifierPropertyAccessExpression(target)) {
50694                 checkExternalEmitHelpers(target.parent, 524288);
50695             }
50696             return sourceType;
50697         }
50698         function isSideEffectFree(node) {
50699             node = ts.skipParentheses(node);
50700             switch (node.kind) {
50701                 case 75:
50702                 case 10:
50703                 case 13:
50704                 case 198:
50705                 case 211:
50706                 case 14:
50707                 case 8:
50708                 case 9:
50709                 case 106:
50710                 case 91:
50711                 case 100:
50712                 case 146:
50713                 case 201:
50714                 case 214:
50715                 case 202:
50716                 case 192:
50717                 case 193:
50718                 case 204:
50719                 case 218:
50720                 case 267:
50721                 case 266:
50722                     return true;
50723                 case 210:
50724                     return isSideEffectFree(node.whenTrue) &&
50725                         isSideEffectFree(node.whenFalse);
50726                 case 209:
50727                     if (ts.isAssignmentOperator(node.operatorToken.kind)) {
50728                         return false;
50729                     }
50730                     return isSideEffectFree(node.left) &&
50731                         isSideEffectFree(node.right);
50732                 case 207:
50733                 case 208:
50734                     switch (node.operator) {
50735                         case 53:
50736                         case 39:
50737                         case 40:
50738                         case 54:
50739                             return true;
50740                     }
50741                     return false;
50742                 case 205:
50743                 case 199:
50744                 case 217:
50745                 default:
50746                     return false;
50747             }
50748         }
50749         function isTypeEqualityComparableTo(source, target) {
50750             return (target.flags & 98304) !== 0 || isTypeComparableTo(source, target);
50751         }
50752         function checkBinaryExpression(node, checkMode) {
50753             var workStacks = {
50754                 expr: [node],
50755                 state: [0],
50756                 leftType: [undefined]
50757             };
50758             var stackIndex = 0;
50759             var lastResult;
50760             while (stackIndex >= 0) {
50761                 node = workStacks.expr[stackIndex];
50762                 switch (workStacks.state[stackIndex]) {
50763                     case 0: {
50764                         if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) {
50765                             finishInvocation(checkExpression(node.right, checkMode));
50766                             break;
50767                         }
50768                         checkGrammarNullishCoalesceWithLogicalExpression(node);
50769                         var operator = node.operatorToken.kind;
50770                         if (operator === 62 && (node.left.kind === 193 || node.left.kind === 192)) {
50771                             finishInvocation(checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 104));
50772                             break;
50773                         }
50774                         advanceState(1);
50775                         maybeCheckExpression(node.left);
50776                         break;
50777                     }
50778                     case 1: {
50779                         var leftType = lastResult;
50780                         workStacks.leftType[stackIndex] = leftType;
50781                         var operator = node.operatorToken.kind;
50782                         if (operator === 55 || operator === 56 || operator === 60) {
50783                             checkTruthinessOfType(leftType, node.left);
50784                         }
50785                         advanceState(2);
50786                         maybeCheckExpression(node.right);
50787                         break;
50788                     }
50789                     case 2: {
50790                         var leftType = workStacks.leftType[stackIndex];
50791                         var rightType = lastResult;
50792                         finishInvocation(checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, node));
50793                         break;
50794                     }
50795                     default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for checkBinaryExpression");
50796                 }
50797             }
50798             return lastResult;
50799             function finishInvocation(result) {
50800                 lastResult = result;
50801                 stackIndex--;
50802             }
50803             function advanceState(nextState) {
50804                 workStacks.state[stackIndex] = nextState;
50805             }
50806             function maybeCheckExpression(node) {
50807                 if (ts.isBinaryExpression(node)) {
50808                     stackIndex++;
50809                     workStacks.expr[stackIndex] = node;
50810                     workStacks.state[stackIndex] = 0;
50811                     workStacks.leftType[stackIndex] = undefined;
50812                 }
50813                 else {
50814                     lastResult = checkExpression(node, checkMode);
50815                 }
50816             }
50817         }
50818         function checkGrammarNullishCoalesceWithLogicalExpression(node) {
50819             var left = node.left, operatorToken = node.operatorToken, right = node.right;
50820             if (operatorToken.kind === 60) {
50821                 if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 || left.operatorToken.kind === 55)) {
50822                     grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind));
50823                 }
50824                 if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 || right.operatorToken.kind === 55)) {
50825                     grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind));
50826                 }
50827             }
50828         }
50829         function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) {
50830             var operator = operatorToken.kind;
50831             if (operator === 62 && (left.kind === 193 || left.kind === 192)) {
50832                 return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 104);
50833             }
50834             var leftType;
50835             if (operator === 55 || operator === 56 || operator === 60) {
50836                 leftType = checkTruthinessExpression(left, checkMode);
50837             }
50838             else {
50839                 leftType = checkExpression(left, checkMode);
50840             }
50841             var rightType = checkExpression(right, checkMode);
50842             return checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode);
50843         }
50844         function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode) {
50845             var operator = operatorToken.kind;
50846             switch (operator) {
50847                 case 41:
50848                 case 42:
50849                 case 65:
50850                 case 66:
50851                 case 43:
50852                 case 67:
50853                 case 44:
50854                 case 68:
50855                 case 40:
50856                 case 64:
50857                 case 47:
50858                 case 69:
50859                 case 48:
50860                 case 70:
50861                 case 49:
50862                 case 71:
50863                 case 51:
50864                 case 73:
50865                 case 52:
50866                 case 74:
50867                 case 50:
50868                 case 72:
50869                     if (leftType === silentNeverType || rightType === silentNeverType) {
50870                         return silentNeverType;
50871                     }
50872                     leftType = checkNonNullType(leftType, left);
50873                     rightType = checkNonNullType(rightType, right);
50874                     var suggestedOperator = void 0;
50875                     if ((leftType.flags & 528) &&
50876                         (rightType.flags & 528) &&
50877                         (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) {
50878                         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));
50879                         return numberType;
50880                     }
50881                     else {
50882                         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);
50883                         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);
50884                         var resultType_1;
50885                         if ((isTypeAssignableToKind(leftType, 3) && isTypeAssignableToKind(rightType, 3)) ||
50886                             !(maybeTypeOfKind(leftType, 2112) || maybeTypeOfKind(rightType, 2112))) {
50887                             resultType_1 = numberType;
50888                         }
50889                         else if (bothAreBigIntLike(leftType, rightType)) {
50890                             switch (operator) {
50891                                 case 49:
50892                                 case 71:
50893                                     reportOperatorError();
50894                             }
50895                             resultType_1 = bigintType;
50896                         }
50897                         else {
50898                             reportOperatorError(bothAreBigIntLike);
50899                             resultType_1 = errorType;
50900                         }
50901                         if (leftOk && rightOk) {
50902                             checkAssignmentOperator(resultType_1);
50903                         }
50904                         return resultType_1;
50905                     }
50906                 case 39:
50907                 case 63:
50908                     if (leftType === silentNeverType || rightType === silentNeverType) {
50909                         return silentNeverType;
50910                     }
50911                     if (!isTypeAssignableToKind(leftType, 132) && !isTypeAssignableToKind(rightType, 132)) {
50912                         leftType = checkNonNullType(leftType, left);
50913                         rightType = checkNonNullType(rightType, right);
50914                     }
50915                     var resultType = void 0;
50916                     if (isTypeAssignableToKind(leftType, 296, true) && isTypeAssignableToKind(rightType, 296, true)) {
50917                         resultType = numberType;
50918                     }
50919                     else if (isTypeAssignableToKind(leftType, 2112, true) && isTypeAssignableToKind(rightType, 2112, true)) {
50920                         resultType = bigintType;
50921                     }
50922                     else if (isTypeAssignableToKind(leftType, 132, true) || isTypeAssignableToKind(rightType, 132, true)) {
50923                         resultType = stringType;
50924                     }
50925                     else if (isTypeAny(leftType) || isTypeAny(rightType)) {
50926                         resultType = leftType === errorType || rightType === errorType ? errorType : anyType;
50927                     }
50928                     if (resultType && !checkForDisallowedESSymbolOperand(operator)) {
50929                         return resultType;
50930                     }
50931                     if (!resultType) {
50932                         var closeEnoughKind_1 = 296 | 2112 | 132 | 3;
50933                         reportOperatorError(function (left, right) {
50934                             return isTypeAssignableToKind(left, closeEnoughKind_1) &&
50935                                 isTypeAssignableToKind(right, closeEnoughKind_1);
50936                         });
50937                         return anyType;
50938                     }
50939                     if (operator === 63) {
50940                         checkAssignmentOperator(resultType);
50941                     }
50942                     return resultType;
50943                 case 29:
50944                 case 31:
50945                 case 32:
50946                 case 33:
50947                     if (checkForDisallowedESSymbolOperand(operator)) {
50948                         leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left));
50949                         rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right));
50950                         reportOperatorErrorUnless(function (left, right) {
50951                             return isTypeComparableTo(left, right) || isTypeComparableTo(right, left) || (isTypeAssignableTo(left, numberOrBigIntType) && isTypeAssignableTo(right, numberOrBigIntType));
50952                         });
50953                     }
50954                     return booleanType;
50955                 case 34:
50956                 case 35:
50957                 case 36:
50958                 case 37:
50959                     reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); });
50960                     return booleanType;
50961                 case 98:
50962                     return checkInstanceOfExpression(left, right, leftType, rightType);
50963                 case 97:
50964                     return checkInExpression(left, right, leftType, rightType);
50965                 case 55:
50966                     return getTypeFacts(leftType) & 4194304 ?
50967                         getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) :
50968                         leftType;
50969                 case 56:
50970                     return getTypeFacts(leftType) & 8388608 ?
50971                         getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2) :
50972                         leftType;
50973                 case 60:
50974                     return getTypeFacts(leftType) & 262144 ?
50975                         getUnionType([getNonNullableType(leftType), rightType], 2) :
50976                         leftType;
50977                 case 62:
50978                     var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0;
50979                     checkAssignmentDeclaration(declKind, rightType);
50980                     if (isAssignmentDeclaration(declKind)) {
50981                         if (!(rightType.flags & 524288) ||
50982                             declKind !== 2 &&
50983                                 declKind !== 6 &&
50984                                 !isEmptyObjectType(rightType) &&
50985                                 !isFunctionObjectType(rightType) &&
50986                                 !(ts.getObjectFlags(rightType) & 1)) {
50987                             checkAssignmentOperator(rightType);
50988                         }
50989                         return leftType;
50990                     }
50991                     else {
50992                         checkAssignmentOperator(rightType);
50993                         return getRegularTypeOfObjectLiteral(rightType);
50994                     }
50995                 case 27:
50996                     if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) {
50997                         error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects);
50998                     }
50999                     return rightType;
51000                 default:
51001                     return ts.Debug.fail();
51002             }
51003             function bothAreBigIntLike(left, right) {
51004                 return isTypeAssignableToKind(left, 2112) && isTypeAssignableToKind(right, 2112);
51005             }
51006             function checkAssignmentDeclaration(kind, rightType) {
51007                 if (kind === 2) {
51008                     for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) {
51009                         var prop = _a[_i];
51010                         var propType = getTypeOfSymbol(prop);
51011                         if (propType.symbol && propType.symbol.flags & 32) {
51012                             var name = prop.escapedName;
51013                             var symbol = resolveName(prop.valueDeclaration, name, 788968, undefined, name, false);
51014                             if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) {
51015                                 addDuplicateDeclarationErrorsForSymbols(symbol, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), prop);
51016                                 addDuplicateDeclarationErrorsForSymbols(prop, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), symbol);
51017                             }
51018                         }
51019                     }
51020                 }
51021             }
51022             function isEvalNode(node) {
51023                 return node.kind === 75 && node.escapedText === "eval";
51024             }
51025             function checkForDisallowedESSymbolOperand(operator) {
51026                 var offendingSymbolOperand = maybeTypeOfKind(leftType, 12288) ? left :
51027                     maybeTypeOfKind(rightType, 12288) ? right :
51028                         undefined;
51029                 if (offendingSymbolOperand) {
51030                     error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator));
51031                     return false;
51032                 }
51033                 return true;
51034             }
51035             function getSuggestedBooleanOperator(operator) {
51036                 switch (operator) {
51037                     case 51:
51038                     case 73:
51039                         return 56;
51040                     case 52:
51041                     case 74:
51042                         return 37;
51043                     case 50:
51044                     case 72:
51045                         return 55;
51046                     default:
51047                         return undefined;
51048                 }
51049             }
51050             function checkAssignmentOperator(valueType) {
51051                 if (produceDiagnostics && ts.isAssignmentOperator(operator)) {
51052                     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)
51053                         && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) {
51054                         checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right);
51055                     }
51056                 }
51057             }
51058             function isAssignmentDeclaration(kind) {
51059                 switch (kind) {
51060                     case 2:
51061                         return true;
51062                     case 1:
51063                     case 5:
51064                     case 6:
51065                     case 3:
51066                     case 4:
51067                         var symbol = getSymbolOfNode(left);
51068                         var init = ts.getAssignedExpandoInitializer(right);
51069                         return init && ts.isObjectLiteralExpression(init) &&
51070                             symbol && ts.hasEntries(symbol.exports);
51071                     default:
51072                         return false;
51073                 }
51074             }
51075             function reportOperatorErrorUnless(typesAreCompatible) {
51076                 if (!typesAreCompatible(leftType, rightType)) {
51077                     reportOperatorError(typesAreCompatible);
51078                     return true;
51079                 }
51080                 return false;
51081             }
51082             function reportOperatorError(isRelated) {
51083                 var _a;
51084                 var wouldWorkWithAwait = false;
51085                 var errNode = errorNode || operatorToken;
51086                 if (isRelated) {
51087                     var awaitedLeftType = getAwaitedType(leftType);
51088                     var awaitedRightType = getAwaitedType(rightType);
51089                     wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType)
51090                         && !!(awaitedLeftType && awaitedRightType)
51091                         && isRelated(awaitedLeftType, awaitedRightType);
51092                 }
51093                 var effectiveLeft = leftType;
51094                 var effectiveRight = rightType;
51095                 if (!wouldWorkWithAwait && isRelated) {
51096                     _a = getBaseTypesIfUnrelated(leftType, rightType, isRelated), effectiveLeft = _a[0], effectiveRight = _a[1];
51097                 }
51098                 var _b = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight), leftStr = _b[0], rightStr = _b[1];
51099                 if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) {
51100                     errorAndMaybeSuggestAwait(errNode, wouldWorkWithAwait, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr);
51101                 }
51102             }
51103             function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) {
51104                 var typeName;
51105                 switch (operatorToken.kind) {
51106                     case 36:
51107                     case 34:
51108                         typeName = "false";
51109                         break;
51110                     case 37:
51111                     case 35:
51112                         typeName = "true";
51113                 }
51114                 if (typeName) {
51115                     return errorAndMaybeSuggestAwait(errNode, maybeMissingAwait, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, typeName, leftStr, rightStr);
51116                 }
51117                 return undefined;
51118             }
51119         }
51120         function getBaseTypesIfUnrelated(leftType, rightType, isRelated) {
51121             var effectiveLeft = leftType;
51122             var effectiveRight = rightType;
51123             var leftBase = getBaseTypeOfLiteralType(leftType);
51124             var rightBase = getBaseTypeOfLiteralType(rightType);
51125             if (!isRelated(leftBase, rightBase)) {
51126                 effectiveLeft = leftBase;
51127                 effectiveRight = rightBase;
51128             }
51129             return [effectiveLeft, effectiveRight];
51130         }
51131         function checkYieldExpression(node) {
51132             if (produceDiagnostics) {
51133                 if (!(node.flags & 8192)) {
51134                     grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body);
51135                 }
51136                 if (isInParameterInitializerBeforeContainingFunction(node)) {
51137                     error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer);
51138                 }
51139             }
51140             var func = ts.getContainingFunction(node);
51141             if (!func)
51142                 return anyType;
51143             var functionFlags = ts.getFunctionFlags(func);
51144             if (!(functionFlags & 1)) {
51145                 return anyType;
51146             }
51147             var isAsync = (functionFlags & 2) !== 0;
51148             if (node.asteriskToken) {
51149                 if (isAsync && languageVersion < 99) {
51150                     checkExternalEmitHelpers(node, 53248);
51151                 }
51152                 if (!isAsync && languageVersion < 2 && compilerOptions.downlevelIteration) {
51153                     checkExternalEmitHelpers(node, 256);
51154                 }
51155             }
51156             var returnType = getReturnTypeFromAnnotation(func);
51157             var iterationTypes = returnType && getIterationTypesOfGeneratorFunctionReturnType(returnType, isAsync);
51158             var signatureYieldType = iterationTypes && iterationTypes.yieldType || anyType;
51159             var signatureNextType = iterationTypes && iterationTypes.nextType || anyType;
51160             var resolvedSignatureNextType = isAsync ? getAwaitedType(signatureNextType) || anyType : signatureNextType;
51161             var yieldExpressionType = node.expression ? checkExpression(node.expression) : undefinedWideningType;
51162             var yieldedType = getYieldedTypeOfYieldExpression(node, yieldExpressionType, resolvedSignatureNextType, isAsync);
51163             if (returnType && yieldedType) {
51164                 checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureYieldType, node.expression || node, node.expression);
51165             }
51166             if (node.asteriskToken) {
51167                 var use = isAsync ? 19 : 17;
51168                 return getIterationTypeOfIterable(use, 1, yieldExpressionType, node.expression)
51169                     || anyType;
51170             }
51171             else if (returnType) {
51172                 return getIterationTypeOfGeneratorFunctionReturnType(2, returnType, isAsync)
51173                     || anyType;
51174             }
51175             return getContextualIterationType(2, func) || anyType;
51176         }
51177         function checkConditionalExpression(node, checkMode) {
51178             var type = checkTruthinessExpression(node.condition);
51179             checkTestingKnownTruthyCallableType(node.condition, node.whenTrue, type);
51180             var type1 = checkExpression(node.whenTrue, checkMode);
51181             var type2 = checkExpression(node.whenFalse, checkMode);
51182             return getUnionType([type1, type2], 2);
51183         }
51184         function checkTemplateExpression(node) {
51185             ts.forEach(node.templateSpans, function (templateSpan) {
51186                 if (maybeTypeOfKind(checkExpression(templateSpan.expression), 12288)) {
51187                     error(templateSpan.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String);
51188                 }
51189             });
51190             return stringType;
51191         }
51192         function getContextNode(node) {
51193             if (node.kind === 274 && !ts.isJsxSelfClosingElement(node.parent)) {
51194                 return node.parent.parent;
51195             }
51196             return node;
51197         }
51198         function checkExpressionWithContextualType(node, contextualType, inferenceContext, checkMode) {
51199             var context = getContextNode(node);
51200             var saveContextualType = context.contextualType;
51201             var saveInferenceContext = context.inferenceContext;
51202             try {
51203                 context.contextualType = contextualType;
51204                 context.inferenceContext = inferenceContext;
51205                 var type = checkExpression(node, checkMode | 1 | (inferenceContext ? 2 : 0));
51206                 var result = maybeTypeOfKind(type, 2944) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ?
51207                     getRegularTypeOfLiteralType(type) : type;
51208                 return result;
51209             }
51210             finally {
51211                 context.contextualType = saveContextualType;
51212                 context.inferenceContext = saveInferenceContext;
51213             }
51214         }
51215         function checkExpressionCached(node, checkMode) {
51216             var links = getNodeLinks(node);
51217             if (!links.resolvedType) {
51218                 if (checkMode && checkMode !== 0) {
51219                     return checkExpression(node, checkMode);
51220                 }
51221                 var saveFlowLoopStart = flowLoopStart;
51222                 var saveFlowTypeCache = flowTypeCache;
51223                 flowLoopStart = flowLoopCount;
51224                 flowTypeCache = undefined;
51225                 links.resolvedType = checkExpression(node, checkMode);
51226                 flowTypeCache = saveFlowTypeCache;
51227                 flowLoopStart = saveFlowLoopStart;
51228             }
51229             return links.resolvedType;
51230         }
51231         function isTypeAssertion(node) {
51232             node = ts.skipParentheses(node);
51233             return node.kind === 199 || node.kind === 217;
51234         }
51235         function checkDeclarationInitializer(declaration, contextualType) {
51236             var initializer = ts.getEffectiveInitializer(declaration);
51237             var type = getQuickTypeOfExpression(initializer) ||
51238                 (contextualType ? checkExpressionWithContextualType(initializer, contextualType, undefined, 0) : checkExpressionCached(initializer));
51239             return ts.isParameter(declaration) && declaration.name.kind === 190 &&
51240                 isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ?
51241                 padTupleType(type, declaration.name) : type;
51242         }
51243         function padTupleType(type, pattern) {
51244             var patternElements = pattern.elements;
51245             var arity = getTypeReferenceArity(type);
51246             var elementTypes = arity ? getTypeArguments(type).slice() : [];
51247             for (var i = arity; i < patternElements.length; i++) {
51248                 var e = patternElements[i];
51249                 if (i < patternElements.length - 1 || !(e.kind === 191 && e.dotDotDotToken)) {
51250                     elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, false, false) : anyType);
51251                     if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) {
51252                         reportImplicitAny(e, anyType);
51253                     }
51254                 }
51255             }
51256             return createTupleType(elementTypes, type.target.minLength, false, type.target.readonly);
51257         }
51258         function widenTypeInferredFromInitializer(declaration, type) {
51259             var widened = ts.getCombinedNodeFlags(declaration) & 2 || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type);
51260             if (ts.isInJSFile(declaration)) {
51261                 if (widened.flags & 98304) {
51262                     reportImplicitAny(declaration, anyType);
51263                     return anyType;
51264                 }
51265                 else if (isEmptyArrayLiteralType(widened)) {
51266                     reportImplicitAny(declaration, anyArrayType);
51267                     return anyArrayType;
51268                 }
51269             }
51270             return widened;
51271         }
51272         function isLiteralOfContextualType(candidateType, contextualType) {
51273             if (contextualType) {
51274                 if (contextualType.flags & 3145728) {
51275                     var types = contextualType.types;
51276                     return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); });
51277                 }
51278                 if (contextualType.flags & 58982400) {
51279                     var constraint = getBaseConstraintOfType(contextualType) || unknownType;
51280                     return maybeTypeOfKind(constraint, 4) && maybeTypeOfKind(candidateType, 128) ||
51281                         maybeTypeOfKind(constraint, 8) && maybeTypeOfKind(candidateType, 256) ||
51282                         maybeTypeOfKind(constraint, 64) && maybeTypeOfKind(candidateType, 2048) ||
51283                         maybeTypeOfKind(constraint, 4096) && maybeTypeOfKind(candidateType, 8192) ||
51284                         isLiteralOfContextualType(candidateType, constraint);
51285                 }
51286                 return !!(contextualType.flags & (128 | 4194304) && maybeTypeOfKind(candidateType, 128) ||
51287                     contextualType.flags & 256 && maybeTypeOfKind(candidateType, 256) ||
51288                     contextualType.flags & 2048 && maybeTypeOfKind(candidateType, 2048) ||
51289                     contextualType.flags & 512 && maybeTypeOfKind(candidateType, 512) ||
51290                     contextualType.flags & 8192 && maybeTypeOfKind(candidateType, 8192));
51291             }
51292             return false;
51293         }
51294         function isConstContext(node) {
51295             var parent = node.parent;
51296             return ts.isAssertionExpression(parent) && ts.isConstTypeReference(parent.type) ||
51297                 (ts.isParenthesizedExpression(parent) || ts.isArrayLiteralExpression(parent) || ts.isSpreadElement(parent)) && isConstContext(parent) ||
51298                 (ts.isPropertyAssignment(parent) || ts.isShorthandPropertyAssignment(parent)) && isConstContext(parent.parent);
51299         }
51300         function checkExpressionForMutableLocation(node, checkMode, contextualType, forceTuple) {
51301             var type = checkExpression(node, checkMode, forceTuple);
51302             return isConstContext(node) ? getRegularTypeOfLiteralType(type) :
51303                 isTypeAssertion(node) ? type :
51304                     getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node));
51305         }
51306         function checkPropertyAssignment(node, checkMode) {
51307             if (node.name.kind === 154) {
51308                 checkComputedPropertyName(node.name);
51309             }
51310             return checkExpressionForMutableLocation(node.initializer, checkMode);
51311         }
51312         function checkObjectLiteralMethod(node, checkMode) {
51313             checkGrammarMethod(node);
51314             if (node.name.kind === 154) {
51315                 checkComputedPropertyName(node.name);
51316             }
51317             var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode);
51318             return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode);
51319         }
51320         function instantiateTypeWithSingleGenericCallSignature(node, type, checkMode) {
51321             if (checkMode && checkMode & (2 | 8)) {
51322                 var callSignature = getSingleSignature(type, 0, true);
51323                 var constructSignature = getSingleSignature(type, 1, true);
51324                 var signature = callSignature || constructSignature;
51325                 if (signature && signature.typeParameters) {
51326                     var contextualType = getApparentTypeOfContextualType(node, 2);
51327                     if (contextualType) {
51328                         var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 : 1, false);
51329                         if (contextualSignature && !contextualSignature.typeParameters) {
51330                             if (checkMode & 8) {
51331                                 skippedGenericFunction(node, checkMode);
51332                                 return anyFunctionType;
51333                             }
51334                             var context = getInferenceContext(node);
51335                             var returnType = context.signature && getReturnTypeOfSignature(context.signature);
51336                             var returnSignature = returnType && getSingleCallOrConstructSignature(returnType);
51337                             if (returnSignature && !returnSignature.typeParameters && !ts.every(context.inferences, hasInferenceCandidates)) {
51338                                 var uniqueTypeParameters = getUniqueTypeParameters(context, signature.typeParameters);
51339                                 var instantiatedSignature = getSignatureInstantiationWithoutFillingInTypeArguments(signature, uniqueTypeParameters);
51340                                 var inferences_3 = ts.map(context.inferences, function (info) { return createInferenceInfo(info.typeParameter); });
51341                                 applyToParameterTypes(instantiatedSignature, contextualSignature, function (source, target) {
51342                                     inferTypes(inferences_3, source, target, 0, true);
51343                                 });
51344                                 if (ts.some(inferences_3, hasInferenceCandidates)) {
51345                                     applyToReturnTypes(instantiatedSignature, contextualSignature, function (source, target) {
51346                                         inferTypes(inferences_3, source, target);
51347                                     });
51348                                     if (!hasOverlappingInferences(context.inferences, inferences_3)) {
51349                                         mergeInferences(context.inferences, inferences_3);
51350                                         context.inferredTypeParameters = ts.concatenate(context.inferredTypeParameters, uniqueTypeParameters);
51351                                         return getOrCreateTypeFromSignature(instantiatedSignature);
51352                                     }
51353                                 }
51354                             }
51355                             return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, context));
51356                         }
51357                     }
51358                 }
51359             }
51360             return type;
51361         }
51362         function skippedGenericFunction(node, checkMode) {
51363             if (checkMode & 2) {
51364                 var context = getInferenceContext(node);
51365                 context.flags |= 4;
51366             }
51367         }
51368         function hasInferenceCandidates(info) {
51369             return !!(info.candidates || info.contraCandidates);
51370         }
51371         function hasOverlappingInferences(a, b) {
51372             for (var i = 0; i < a.length; i++) {
51373                 if (hasInferenceCandidates(a[i]) && hasInferenceCandidates(b[i])) {
51374                     return true;
51375                 }
51376             }
51377             return false;
51378         }
51379         function mergeInferences(target, source) {
51380             for (var i = 0; i < target.length; i++) {
51381                 if (!hasInferenceCandidates(target[i]) && hasInferenceCandidates(source[i])) {
51382                     target[i] = source[i];
51383                 }
51384             }
51385         }
51386         function getUniqueTypeParameters(context, typeParameters) {
51387             var result = [];
51388             var oldTypeParameters;
51389             var newTypeParameters;
51390             for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
51391                 var tp = typeParameters_2[_i];
51392                 var name = tp.symbol.escapedName;
51393                 if (hasTypeParameterByName(context.inferredTypeParameters, name) || hasTypeParameterByName(result, name)) {
51394                     var newName = getUniqueTypeParameterName(ts.concatenate(context.inferredTypeParameters, result), name);
51395                     var symbol = createSymbol(262144, newName);
51396                     var newTypeParameter = createTypeParameter(symbol);
51397                     newTypeParameter.target = tp;
51398                     oldTypeParameters = ts.append(oldTypeParameters, tp);
51399                     newTypeParameters = ts.append(newTypeParameters, newTypeParameter);
51400                     result.push(newTypeParameter);
51401                 }
51402                 else {
51403                     result.push(tp);
51404                 }
51405             }
51406             if (newTypeParameters) {
51407                 var mapper = createTypeMapper(oldTypeParameters, newTypeParameters);
51408                 for (var _a = 0, newTypeParameters_1 = newTypeParameters; _a < newTypeParameters_1.length; _a++) {
51409                     var tp = newTypeParameters_1[_a];
51410                     tp.mapper = mapper;
51411                 }
51412             }
51413             return result;
51414         }
51415         function hasTypeParameterByName(typeParameters, name) {
51416             return ts.some(typeParameters, function (tp) { return tp.symbol.escapedName === name; });
51417         }
51418         function getUniqueTypeParameterName(typeParameters, baseName) {
51419             var len = baseName.length;
51420             while (len > 1 && baseName.charCodeAt(len - 1) >= 48 && baseName.charCodeAt(len - 1) <= 57)
51421                 len--;
51422             var s = baseName.slice(0, len);
51423             for (var index = 1; true; index++) {
51424                 var augmentedName = (s + index);
51425                 if (!hasTypeParameterByName(typeParameters, augmentedName)) {
51426                     return augmentedName;
51427                 }
51428             }
51429         }
51430         function getReturnTypeOfSingleNonGenericCallSignature(funcType) {
51431             var signature = getSingleCallSignature(funcType);
51432             if (signature && !signature.typeParameters) {
51433                 return getReturnTypeOfSignature(signature);
51434             }
51435         }
51436         function getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) {
51437             var funcType = checkExpression(expr.expression);
51438             var nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
51439             var returnType = getReturnTypeOfSingleNonGenericCallSignature(funcType);
51440             return returnType && propagateOptionalTypeMarker(returnType, expr, nonOptionalType !== funcType);
51441         }
51442         function getTypeOfExpression(node) {
51443             var quickType = getQuickTypeOfExpression(node);
51444             if (quickType) {
51445                 return quickType;
51446             }
51447             if (node.flags & 67108864 && flowTypeCache) {
51448                 var cachedType = flowTypeCache[getNodeId(node)];
51449                 if (cachedType) {
51450                     return cachedType;
51451                 }
51452             }
51453             var startInvocationCount = flowInvocationCount;
51454             var type = checkExpression(node);
51455             if (flowInvocationCount !== startInvocationCount) {
51456                 var cache = flowTypeCache || (flowTypeCache = []);
51457                 cache[getNodeId(node)] = type;
51458                 node.flags |= 67108864;
51459             }
51460             return type;
51461         }
51462         function getQuickTypeOfExpression(node) {
51463             var expr = ts.skipParentheses(node);
51464             if (ts.isCallExpression(expr) && expr.expression.kind !== 102 && !ts.isRequireCall(expr, true) && !isSymbolOrSymbolForCall(expr)) {
51465                 var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
51466                     getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
51467                 if (type) {
51468                     return type;
51469                 }
51470             }
51471             else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) {
51472                 return getTypeFromTypeNode(expr.type);
51473             }
51474             else if (node.kind === 8 || node.kind === 10 ||
51475                 node.kind === 106 || node.kind === 91) {
51476                 return checkExpression(node);
51477             }
51478             return undefined;
51479         }
51480         function getContextFreeTypeOfExpression(node) {
51481             var links = getNodeLinks(node);
51482             if (links.contextFreeType) {
51483                 return links.contextFreeType;
51484             }
51485             var saveContextualType = node.contextualType;
51486             node.contextualType = anyType;
51487             try {
51488                 var type = links.contextFreeType = checkExpression(node, 4);
51489                 return type;
51490             }
51491             finally {
51492                 node.contextualType = saveContextualType;
51493             }
51494         }
51495         function checkExpression(node, checkMode, forceTuple) {
51496             var saveCurrentNode = currentNode;
51497             currentNode = node;
51498             instantiationCount = 0;
51499             var uninstantiatedType = checkExpressionWorker(node, checkMode, forceTuple);
51500             var type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode);
51501             if (isConstEnumObjectType(type)) {
51502                 checkConstEnumAccess(node, type);
51503             }
51504             currentNode = saveCurrentNode;
51505             return type;
51506         }
51507         function checkConstEnumAccess(node, type) {
51508             var ok = (node.parent.kind === 194 && node.parent.expression === node) ||
51509                 (node.parent.kind === 195 && node.parent.expression === node) ||
51510                 ((node.kind === 75 || node.kind === 153) && isInRightSideOfImportOrExportAssignment(node) ||
51511                     (node.parent.kind === 172 && node.parent.exprName === node)) ||
51512                 (node.parent.kind === 263);
51513             if (!ok) {
51514                 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);
51515             }
51516             if (compilerOptions.isolatedModules) {
51517                 ts.Debug.assert(!!(type.symbol.flags & 128));
51518                 var constEnumDeclaration = type.symbol.valueDeclaration;
51519                 if (constEnumDeclaration.flags & 8388608) {
51520                     error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided);
51521                 }
51522             }
51523         }
51524         function checkParenthesizedExpression(node, checkMode) {
51525             var tag = ts.isInJSFile(node) ? ts.getJSDocTypeTag(node) : undefined;
51526             if (tag) {
51527                 return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode);
51528             }
51529             return checkExpression(node.expression, checkMode);
51530         }
51531         function checkExpressionWorker(node, checkMode, forceTuple) {
51532             var kind = node.kind;
51533             if (cancellationToken) {
51534                 switch (kind) {
51535                     case 214:
51536                     case 201:
51537                     case 202:
51538                         cancellationToken.throwIfCancellationRequested();
51539                 }
51540             }
51541             switch (kind) {
51542                 case 75:
51543                     return checkIdentifier(node);
51544                 case 104:
51545                     return checkThisExpression(node);
51546                 case 102:
51547                     return checkSuperExpression(node);
51548                 case 100:
51549                     return nullWideningType;
51550                 case 14:
51551                 case 10:
51552                     return getFreshTypeOfLiteralType(getLiteralType(node.text));
51553                 case 8:
51554                     checkGrammarNumericLiteral(node);
51555                     return getFreshTypeOfLiteralType(getLiteralType(+node.text));
51556                 case 9:
51557                     checkGrammarBigIntLiteral(node);
51558                     return getFreshTypeOfLiteralType(getBigIntLiteralType(node));
51559                 case 106:
51560                     return trueType;
51561                 case 91:
51562                     return falseType;
51563                 case 211:
51564                     return checkTemplateExpression(node);
51565                 case 13:
51566                     return globalRegExpType;
51567                 case 192:
51568                     return checkArrayLiteral(node, checkMode, forceTuple);
51569                 case 193:
51570                     return checkObjectLiteral(node, checkMode);
51571                 case 194:
51572                     return checkPropertyAccessExpression(node);
51573                 case 153:
51574                     return checkQualifiedName(node);
51575                 case 195:
51576                     return checkIndexedAccess(node);
51577                 case 196:
51578                     if (node.expression.kind === 96) {
51579                         return checkImportCallExpression(node);
51580                     }
51581                 case 197:
51582                     return checkCallExpression(node, checkMode);
51583                 case 198:
51584                     return checkTaggedTemplateExpression(node);
51585                 case 200:
51586                     return checkParenthesizedExpression(node, checkMode);
51587                 case 214:
51588                     return checkClassExpression(node);
51589                 case 201:
51590                 case 202:
51591                     return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode);
51592                 case 204:
51593                     return checkTypeOfExpression(node);
51594                 case 199:
51595                 case 217:
51596                     return checkAssertion(node);
51597                 case 218:
51598                     return checkNonNullAssertion(node);
51599                 case 219:
51600                     return checkMetaProperty(node);
51601                 case 203:
51602                     return checkDeleteExpression(node);
51603                 case 205:
51604                     return checkVoidExpression(node);
51605                 case 206:
51606                     return checkAwaitExpression(node);
51607                 case 207:
51608                     return checkPrefixUnaryExpression(node);
51609                 case 208:
51610                     return checkPostfixUnaryExpression(node);
51611                 case 209:
51612                     return checkBinaryExpression(node, checkMode);
51613                 case 210:
51614                     return checkConditionalExpression(node, checkMode);
51615                 case 213:
51616                     return checkSpreadExpression(node, checkMode);
51617                 case 215:
51618                     return undefinedWideningType;
51619                 case 212:
51620                     return checkYieldExpression(node);
51621                 case 220:
51622                     return node.type;
51623                 case 276:
51624                     return checkJsxExpression(node, checkMode);
51625                 case 266:
51626                     return checkJsxElement(node, checkMode);
51627                 case 267:
51628                     return checkJsxSelfClosingElement(node, checkMode);
51629                 case 270:
51630                     return checkJsxFragment(node);
51631                 case 274:
51632                     return checkJsxAttributes(node, checkMode);
51633                 case 268:
51634                     ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement");
51635             }
51636             return errorType;
51637         }
51638         function checkTypeParameter(node) {
51639             if (node.expression) {
51640                 grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected);
51641             }
51642             checkSourceElement(node.constraint);
51643             checkSourceElement(node.default);
51644             var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node));
51645             getBaseConstraintOfType(typeParameter);
51646             if (!hasNonCircularTypeParameterDefault(typeParameter)) {
51647                 error(node.default, ts.Diagnostics.Type_parameter_0_has_a_circular_default, typeToString(typeParameter));
51648             }
51649             var constraintType = getConstraintOfTypeParameter(typeParameter);
51650             var defaultType = getDefaultFromTypeParameter(typeParameter);
51651             if (constraintType && defaultType) {
51652                 checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
51653             }
51654             if (produceDiagnostics) {
51655                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0);
51656             }
51657         }
51658         function checkParameter(node) {
51659             checkGrammarDecoratorsAndModifiers(node);
51660             checkVariableLikeDeclaration(node);
51661             var func = ts.getContainingFunction(node);
51662             if (ts.hasModifier(node, 92)) {
51663                 if (!(func.kind === 162 && ts.nodeIsPresent(func.body))) {
51664                     error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation);
51665                 }
51666                 if (func.kind === 162 && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") {
51667                     error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name);
51668                 }
51669             }
51670             if (node.questionToken && ts.isBindingPattern(node.name) && func.body) {
51671                 error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature);
51672             }
51673             if (node.name && ts.isIdentifier(node.name) && (node.name.escapedText === "this" || node.name.escapedText === "new")) {
51674                 if (func.parameters.indexOf(node) !== 0) {
51675                     error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText);
51676                 }
51677                 if (func.kind === 162 || func.kind === 166 || func.kind === 171) {
51678                     error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter);
51679                 }
51680                 if (func.kind === 202) {
51681                     error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter);
51682                 }
51683                 if (func.kind === 163 || func.kind === 164) {
51684                     error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters);
51685                 }
51686             }
51687             if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isTypeAssignableTo(getReducedType(getTypeOfSymbol(node.symbol)), anyReadonlyArrayType)) {
51688                 error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type);
51689             }
51690         }
51691         function checkTypePredicate(node) {
51692             var parent = getTypePredicateParent(node);
51693             if (!parent) {
51694                 error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods);
51695                 return;
51696             }
51697             var signature = getSignatureFromDeclaration(parent);
51698             var typePredicate = getTypePredicateOfSignature(signature);
51699             if (!typePredicate) {
51700                 return;
51701             }
51702             checkSourceElement(node.type);
51703             var parameterName = node.parameterName;
51704             if (typePredicate.kind === 0 || typePredicate.kind === 2) {
51705                 getTypeFromThisTypeNode(parameterName);
51706             }
51707             else {
51708                 if (typePredicate.parameterIndex >= 0) {
51709                     if (signatureHasRestParameter(signature) && typePredicate.parameterIndex === signature.parameters.length - 1) {
51710                         error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter);
51711                     }
51712                     else {
51713                         if (typePredicate.type) {
51714                             var leadingError = function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); };
51715                             checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, undefined, leadingError);
51716                         }
51717                     }
51718                 }
51719                 else if (parameterName) {
51720                     var hasReportedError = false;
51721                     for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) {
51722                         var name = _a[_i].name;
51723                         if (ts.isBindingPattern(name) &&
51724                             checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, parameterName, typePredicate.parameterName)) {
51725                             hasReportedError = true;
51726                             break;
51727                         }
51728                     }
51729                     if (!hasReportedError) {
51730                         error(node.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName);
51731                     }
51732                 }
51733             }
51734         }
51735         function getTypePredicateParent(node) {
51736             switch (node.parent.kind) {
51737                 case 202:
51738                 case 165:
51739                 case 244:
51740                 case 201:
51741                 case 170:
51742                 case 161:
51743                 case 160:
51744                     var parent = node.parent;
51745                     if (node === parent.type) {
51746                         return parent;
51747                     }
51748             }
51749         }
51750         function checkIfTypePredicateVariableIsDeclaredInBindingPattern(pattern, predicateVariableNode, predicateVariableName) {
51751             for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
51752                 var element = _a[_i];
51753                 if (ts.isOmittedExpression(element)) {
51754                     continue;
51755                 }
51756                 var name = element.name;
51757                 if (name.kind === 75 && name.escapedText === predicateVariableName) {
51758                     error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName);
51759                     return true;
51760                 }
51761                 else if (name.kind === 190 || name.kind === 189) {
51762                     if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) {
51763                         return true;
51764                     }
51765                 }
51766             }
51767         }
51768         function checkSignatureDeclaration(node) {
51769             if (node.kind === 167) {
51770                 checkGrammarIndexSignature(node);
51771             }
51772             else if (node.kind === 170 || node.kind === 244 || node.kind === 171 ||
51773                 node.kind === 165 || node.kind === 162 ||
51774                 node.kind === 166) {
51775                 checkGrammarFunctionLikeDeclaration(node);
51776             }
51777             var functionFlags = ts.getFunctionFlags(node);
51778             if (!(functionFlags & 4)) {
51779                 if ((functionFlags & 3) === 3 && languageVersion < 99) {
51780                     checkExternalEmitHelpers(node, 12288);
51781                 }
51782                 if ((functionFlags & 3) === 2 && languageVersion < 4) {
51783                     checkExternalEmitHelpers(node, 64);
51784                 }
51785                 if ((functionFlags & 3) !== 0 && languageVersion < 2) {
51786                     checkExternalEmitHelpers(node, 128);
51787                 }
51788             }
51789             checkTypeParameters(node.typeParameters);
51790             ts.forEach(node.parameters, checkParameter);
51791             if (node.type) {
51792                 checkSourceElement(node.type);
51793             }
51794             if (produceDiagnostics) {
51795                 checkCollisionWithArgumentsInGeneratedCode(node);
51796                 var returnTypeNode = ts.getEffectiveReturnTypeNode(node);
51797                 if (noImplicitAny && !returnTypeNode) {
51798                     switch (node.kind) {
51799                         case 166:
51800                             error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
51801                             break;
51802                         case 165:
51803                             error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
51804                             break;
51805                     }
51806                 }
51807                 if (returnTypeNode) {
51808                     var functionFlags_1 = ts.getFunctionFlags(node);
51809                     if ((functionFlags_1 & (4 | 1)) === 1) {
51810                         var returnType = getTypeFromTypeNode(returnTypeNode);
51811                         if (returnType === voidType) {
51812                             error(returnTypeNode, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation);
51813                         }
51814                         else {
51815                             var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0, returnType, (functionFlags_1 & 2) !== 0) || anyType;
51816                             var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1, returnType, (functionFlags_1 & 2) !== 0) || generatorYieldType;
51817                             var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2, returnType, (functionFlags_1 & 2) !== 0) || unknownType;
51818                             var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2));
51819                             checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeNode);
51820                         }
51821                     }
51822                     else if ((functionFlags_1 & 3) === 2) {
51823                         checkAsyncFunctionReturnType(node, returnTypeNode);
51824                     }
51825                 }
51826                 if (node.kind !== 167 && node.kind !== 300) {
51827                     registerForUnusedIdentifiersCheck(node);
51828                 }
51829             }
51830         }
51831         function checkClassForDuplicateDeclarations(node) {
51832             var instanceNames = ts.createUnderscoreEscapedMap();
51833             var staticNames = ts.createUnderscoreEscapedMap();
51834             var privateIdentifiers = ts.createUnderscoreEscapedMap();
51835             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
51836                 var member = _a[_i];
51837                 if (member.kind === 162) {
51838                     for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) {
51839                         var param = _c[_b];
51840                         if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) {
51841                             addName(instanceNames, param.name, param.name.escapedText, 3);
51842                         }
51843                     }
51844                 }
51845                 else {
51846                     var isStatic = ts.hasModifier(member, 32);
51847                     var name = member.name;
51848                     if (!name) {
51849                         return;
51850                     }
51851                     var names = ts.isPrivateIdentifier(name) ? privateIdentifiers :
51852                         isStatic ? staticNames :
51853                             instanceNames;
51854                     var memberName = name && ts.getPropertyNameForPropertyNameNode(name);
51855                     if (memberName) {
51856                         switch (member.kind) {
51857                             case 163:
51858                                 addName(names, name, memberName, 1);
51859                                 break;
51860                             case 164:
51861                                 addName(names, name, memberName, 2);
51862                                 break;
51863                             case 159:
51864                                 addName(names, name, memberName, 3);
51865                                 break;
51866                             case 161:
51867                                 addName(names, name, memberName, 8);
51868                                 break;
51869                         }
51870                     }
51871                 }
51872             }
51873             function addName(names, location, name, meaning) {
51874                 var prev = names.get(name);
51875                 if (prev) {
51876                     if (prev & 8) {
51877                         if (meaning !== 8) {
51878                             error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location));
51879                         }
51880                     }
51881                     else if (prev & meaning) {
51882                         error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location));
51883                     }
51884                     else {
51885                         names.set(name, prev | meaning);
51886                     }
51887                 }
51888                 else {
51889                     names.set(name, meaning);
51890                 }
51891             }
51892         }
51893         function checkClassForStaticPropertyNameConflicts(node) {
51894             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
51895                 var member = _a[_i];
51896                 var memberNameNode = member.name;
51897                 var isStatic = ts.hasModifier(member, 32);
51898                 if (isStatic && memberNameNode) {
51899                     var memberName = ts.getPropertyNameForPropertyNameNode(memberNameNode);
51900                     switch (memberName) {
51901                         case "name":
51902                         case "length":
51903                         case "caller":
51904                         case "arguments":
51905                         case "prototype":
51906                             var message = ts.Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1;
51907                             var className = getNameOfSymbolAsWritten(getSymbolOfNode(node));
51908                             error(memberNameNode, message, memberName, className);
51909                             break;
51910                     }
51911                 }
51912             }
51913         }
51914         function checkObjectTypeForDuplicateDeclarations(node) {
51915             var names = ts.createMap();
51916             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
51917                 var member = _a[_i];
51918                 if (member.kind === 158) {
51919                     var memberName = void 0;
51920                     var name = member.name;
51921                     switch (name.kind) {
51922                         case 10:
51923                         case 8:
51924                             memberName = name.text;
51925                             break;
51926                         case 75:
51927                             memberName = ts.idText(name);
51928                             break;
51929                         default:
51930                             continue;
51931                     }
51932                     if (names.get(memberName)) {
51933                         error(ts.getNameOfDeclaration(member.symbol.valueDeclaration), ts.Diagnostics.Duplicate_identifier_0, memberName);
51934                         error(member.name, ts.Diagnostics.Duplicate_identifier_0, memberName);
51935                     }
51936                     else {
51937                         names.set(memberName, true);
51938                     }
51939                 }
51940             }
51941         }
51942         function checkTypeForDuplicateIndexSignatures(node) {
51943             if (node.kind === 246) {
51944                 var nodeSymbol = getSymbolOfNode(node);
51945                 if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) {
51946                     return;
51947                 }
51948             }
51949             var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
51950             if (indexSymbol) {
51951                 var seenNumericIndexer = false;
51952                 var seenStringIndexer = false;
51953                 for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
51954                     var decl = _a[_i];
51955                     var declaration = decl;
51956                     if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
51957                         switch (declaration.parameters[0].type.kind) {
51958                             case 143:
51959                                 if (!seenStringIndexer) {
51960                                     seenStringIndexer = true;
51961                                 }
51962                                 else {
51963                                     error(declaration, ts.Diagnostics.Duplicate_string_index_signature);
51964                                 }
51965                                 break;
51966                             case 140:
51967                                 if (!seenNumericIndexer) {
51968                                     seenNumericIndexer = true;
51969                                 }
51970                                 else {
51971                                     error(declaration, ts.Diagnostics.Duplicate_number_index_signature);
51972                                 }
51973                                 break;
51974                         }
51975                     }
51976                 }
51977             }
51978         }
51979         function checkPropertyDeclaration(node) {
51980             if (!checkGrammarDecoratorsAndModifiers(node) && !checkGrammarProperty(node))
51981                 checkGrammarComputedPropertyName(node.name);
51982             checkVariableLikeDeclaration(node);
51983             if (ts.isPrivateIdentifier(node.name) && languageVersion < 99) {
51984                 for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) {
51985                     getNodeLinks(lexicalScope).flags |= 67108864;
51986                 }
51987             }
51988         }
51989         function checkPropertySignature(node) {
51990             if (ts.isPrivateIdentifier(node.name)) {
51991                 error(node, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
51992             }
51993             return checkPropertyDeclaration(node);
51994         }
51995         function checkMethodDeclaration(node) {
51996             if (!checkGrammarMethod(node))
51997                 checkGrammarComputedPropertyName(node.name);
51998             if (ts.isPrivateIdentifier(node.name)) {
51999                 error(node, ts.Diagnostics.A_method_cannot_be_named_with_a_private_identifier);
52000             }
52001             checkFunctionOrMethodDeclaration(node);
52002             if (ts.hasModifier(node, 128) && node.kind === 161 && node.body) {
52003                 error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name));
52004             }
52005         }
52006         function checkConstructorDeclaration(node) {
52007             checkSignatureDeclaration(node);
52008             if (!checkGrammarConstructorTypeParameters(node))
52009                 checkGrammarConstructorTypeAnnotation(node);
52010             checkSourceElement(node.body);
52011             var symbol = getSymbolOfNode(node);
52012             var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind);
52013             if (node === firstDeclaration) {
52014                 checkFunctionOrConstructorSymbol(symbol);
52015             }
52016             if (ts.nodeIsMissing(node.body)) {
52017                 return;
52018             }
52019             if (!produceDiagnostics) {
52020                 return;
52021             }
52022             function isInstancePropertyWithInitializerOrPrivateIdentifierProperty(n) {
52023                 if (ts.isPrivateIdentifierPropertyDeclaration(n)) {
52024                     return true;
52025                 }
52026                 return n.kind === 159 &&
52027                     !ts.hasModifier(n, 32) &&
52028                     !!n.initializer;
52029             }
52030             var containingClassDecl = node.parent;
52031             if (ts.getClassExtendsHeritageElement(containingClassDecl)) {
52032                 captureLexicalThis(node.parent, containingClassDecl);
52033                 var classExtendsNull = classDeclarationExtendsNull(containingClassDecl);
52034                 var superCall = getSuperCallInConstructor(node);
52035                 if (superCall) {
52036                     if (classExtendsNull) {
52037                         error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
52038                     }
52039                     var superCallShouldBeFirst = (compilerOptions.target !== 99 || !compilerOptions.useDefineForClassFields) &&
52040                         (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
52041                             ts.some(node.parameters, function (p) { return ts.hasModifier(p, 92); }));
52042                     if (superCallShouldBeFirst) {
52043                         var statements = node.body.statements;
52044                         var superCallStatement = void 0;
52045                         for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) {
52046                             var statement = statements_3[_i];
52047                             if (statement.kind === 226 && ts.isSuperCall(statement.expression)) {
52048                                 superCallStatement = statement;
52049                                 break;
52050                             }
52051                             if (!ts.isPrologueDirective(statement)) {
52052                                 break;
52053                             }
52054                         }
52055                         if (!superCallStatement) {
52056                             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);
52057                         }
52058                     }
52059                 }
52060                 else if (!classExtendsNull) {
52061                     error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call);
52062                 }
52063             }
52064         }
52065         function checkAccessorDeclaration(node) {
52066             if (produceDiagnostics) {
52067                 if (!checkGrammarFunctionLikeDeclaration(node) && !checkGrammarAccessor(node))
52068                     checkGrammarComputedPropertyName(node.name);
52069                 checkDecorators(node);
52070                 checkSignatureDeclaration(node);
52071                 if (node.kind === 163) {
52072                     if (!(node.flags & 8388608) && ts.nodeIsPresent(node.body) && (node.flags & 256)) {
52073                         if (!(node.flags & 512)) {
52074                             error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value);
52075                         }
52076                     }
52077                 }
52078                 if (node.name.kind === 154) {
52079                     checkComputedPropertyName(node.name);
52080                 }
52081                 if (ts.isPrivateIdentifier(node.name)) {
52082                     error(node.name, ts.Diagnostics.An_accessor_cannot_be_named_with_a_private_identifier);
52083                 }
52084                 if (!hasNonBindableDynamicName(node)) {
52085                     var otherKind = node.kind === 163 ? 164 : 163;
52086                     var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind);
52087                     if (otherAccessor) {
52088                         var nodeFlags = ts.getModifierFlags(node);
52089                         var otherFlags = ts.getModifierFlags(otherAccessor);
52090                         if ((nodeFlags & 28) !== (otherFlags & 28)) {
52091                             error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility);
52092                         }
52093                         if ((nodeFlags & 128) !== (otherFlags & 128)) {
52094                             error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract);
52095                         }
52096                         checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type);
52097                         checkAccessorDeclarationTypesIdentical(node, otherAccessor, getThisTypeOfDeclaration, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type);
52098                     }
52099                 }
52100                 var returnType = getTypeOfAccessors(getSymbolOfNode(node));
52101                 if (node.kind === 163) {
52102                     checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType);
52103                 }
52104             }
52105             checkSourceElement(node.body);
52106         }
52107         function checkAccessorDeclarationTypesIdentical(first, second, getAnnotatedType, message) {
52108             var firstType = getAnnotatedType(first);
52109             var secondType = getAnnotatedType(second);
52110             if (firstType && secondType && !isTypeIdenticalTo(firstType, secondType)) {
52111                 error(first, message);
52112             }
52113         }
52114         function checkMissingDeclaration(node) {
52115             checkDecorators(node);
52116         }
52117         function getEffectiveTypeArguments(node, typeParameters) {
52118             return fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(node));
52119         }
52120         function checkTypeArgumentConstraints(node, typeParameters) {
52121             var typeArguments;
52122             var mapper;
52123             var result = true;
52124             for (var i = 0; i < typeParameters.length; i++) {
52125                 var constraint = getConstraintOfTypeParameter(typeParameters[i]);
52126                 if (constraint) {
52127                     if (!typeArguments) {
52128                         typeArguments = getEffectiveTypeArguments(node, typeParameters);
52129                         mapper = createTypeMapper(typeParameters, typeArguments);
52130                     }
52131                     result = result && checkTypeAssignableTo(typeArguments[i], instantiateType(constraint, mapper), node.typeArguments[i], ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
52132                 }
52133             }
52134             return result;
52135         }
52136         function getTypeParametersForTypeReference(node) {
52137             var type = getTypeFromTypeReference(node);
52138             if (type !== errorType) {
52139                 var symbol = getNodeLinks(node).resolvedSymbol;
52140                 if (symbol) {
52141                     return symbol.flags & 524288 && getSymbolLinks(symbol).typeParameters ||
52142                         (ts.getObjectFlags(type) & 4 ? type.target.localTypeParameters : undefined);
52143                 }
52144             }
52145             return undefined;
52146         }
52147         function checkTypeReferenceNode(node) {
52148             checkGrammarTypeArguments(node, node.typeArguments);
52149             if (node.kind === 169 && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) {
52150                 grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments);
52151             }
52152             ts.forEach(node.typeArguments, checkSourceElement);
52153             var type = getTypeFromTypeReference(node);
52154             if (type !== errorType) {
52155                 if (node.typeArguments && produceDiagnostics) {
52156                     var typeParameters = getTypeParametersForTypeReference(node);
52157                     if (typeParameters) {
52158                         checkTypeArgumentConstraints(node, typeParameters);
52159                     }
52160                 }
52161                 if (type.flags & 32 && getNodeLinks(node).resolvedSymbol.flags & 8) {
52162                     error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type));
52163                 }
52164             }
52165         }
52166         function getTypeArgumentConstraint(node) {
52167             var typeReferenceNode = ts.tryCast(node.parent, ts.isTypeReferenceType);
52168             if (!typeReferenceNode)
52169                 return undefined;
52170             var typeParameters = getTypeParametersForTypeReference(typeReferenceNode);
52171             var constraint = getConstraintOfTypeParameter(typeParameters[typeReferenceNode.typeArguments.indexOf(node)]);
52172             return constraint && instantiateType(constraint, createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReferenceNode, typeParameters)));
52173         }
52174         function checkTypeQuery(node) {
52175             getTypeFromTypeQueryNode(node);
52176         }
52177         function checkTypeLiteral(node) {
52178             ts.forEach(node.members, checkSourceElement);
52179             if (produceDiagnostics) {
52180                 var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
52181                 checkIndexConstraints(type);
52182                 checkTypeForDuplicateIndexSignatures(node);
52183                 checkObjectTypeForDuplicateDeclarations(node);
52184             }
52185         }
52186         function checkArrayType(node) {
52187             checkSourceElement(node.elementType);
52188         }
52189         function checkTupleType(node) {
52190             var elementTypes = node.elementTypes;
52191             var seenOptionalElement = false;
52192             for (var i = 0; i < elementTypes.length; i++) {
52193                 var e = elementTypes[i];
52194                 if (e.kind === 177) {
52195                     if (i !== elementTypes.length - 1) {
52196                         grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type);
52197                         break;
52198                     }
52199                     if (!isArrayType(getTypeFromTypeNode(e.type))) {
52200                         error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type);
52201                     }
52202                 }
52203                 else if (e.kind === 176) {
52204                     seenOptionalElement = true;
52205                 }
52206                 else if (seenOptionalElement) {
52207                     grammarErrorOnNode(e, ts.Diagnostics.A_required_element_cannot_follow_an_optional_element);
52208                     break;
52209                 }
52210             }
52211             ts.forEach(node.elementTypes, checkSourceElement);
52212         }
52213         function checkUnionOrIntersectionType(node) {
52214             ts.forEach(node.types, checkSourceElement);
52215         }
52216         function checkIndexedAccessIndexType(type, accessNode) {
52217             if (!(type.flags & 8388608)) {
52218                 return type;
52219             }
52220             var objectType = type.objectType;
52221             var indexType = type.indexType;
52222             if (isTypeAssignableTo(indexType, getIndexType(objectType, false))) {
52223                 if (accessNode.kind === 195 && ts.isAssignmentTarget(accessNode) &&
52224                     ts.getObjectFlags(objectType) & 32 && getMappedTypeModifiers(objectType) & 1) {
52225                     error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
52226                 }
52227                 return type;
52228             }
52229             var apparentObjectType = getApparentType(objectType);
52230             if (getIndexInfoOfType(apparentObjectType, 1) && isTypeAssignableToKind(indexType, 296)) {
52231                 return type;
52232             }
52233             if (isGenericObjectType(objectType)) {
52234                 var propertyName_1 = getPropertyNameFromIndex(indexType, accessNode);
52235                 if (propertyName_1) {
52236                     var propertySymbol = forEachType(apparentObjectType, function (t) { return getPropertyOfType(t, propertyName_1); });
52237                     if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24) {
52238                         error(accessNode, ts.Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter, ts.unescapeLeadingUnderscores(propertyName_1));
52239                         return errorType;
52240                     }
52241                 }
52242             }
52243             error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType));
52244             return errorType;
52245         }
52246         function checkIndexedAccessType(node) {
52247             checkSourceElement(node.objectType);
52248             checkSourceElement(node.indexType);
52249             checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node);
52250         }
52251         function checkMappedType(node) {
52252             checkSourceElement(node.typeParameter);
52253             checkSourceElement(node.type);
52254             if (!node.type) {
52255                 reportImplicitAny(node, anyType);
52256             }
52257             var type = getTypeFromMappedTypeNode(node);
52258             var constraintType = getConstraintTypeFromMappedType(type);
52259             checkTypeAssignableTo(constraintType, keyofConstraintType, ts.getEffectiveConstraintOfTypeParameter(node.typeParameter));
52260         }
52261         function checkThisType(node) {
52262             getTypeFromThisTypeNode(node);
52263         }
52264         function checkTypeOperator(node) {
52265             checkGrammarTypeOperatorNode(node);
52266             checkSourceElement(node.type);
52267         }
52268         function checkConditionalType(node) {
52269             ts.forEachChild(node, checkSourceElement);
52270         }
52271         function checkInferType(node) {
52272             if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 180 && n.parent.extendsType === n; })) {
52273                 grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type);
52274             }
52275             checkSourceElement(node.typeParameter);
52276             registerForUnusedIdentifiersCheck(node);
52277         }
52278         function checkImportType(node) {
52279             checkSourceElement(node.argument);
52280             getTypeFromTypeNode(node);
52281         }
52282         function isPrivateWithinAmbient(node) {
52283             return (ts.hasModifier(node, 8) || ts.isPrivateIdentifierPropertyDeclaration(node)) && !!(node.flags & 8388608);
52284         }
52285         function getEffectiveDeclarationFlags(n, flagsToCheck) {
52286             var flags = ts.getCombinedModifierFlags(n);
52287             if (n.parent.kind !== 246 &&
52288                 n.parent.kind !== 245 &&
52289                 n.parent.kind !== 214 &&
52290                 n.flags & 8388608) {
52291                 if (!(flags & 2) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) {
52292                     flags |= 1;
52293                 }
52294                 flags |= 2;
52295             }
52296             return flags & flagsToCheck;
52297         }
52298         function checkFunctionOrConstructorSymbol(symbol) {
52299             if (!produceDiagnostics) {
52300                 return;
52301             }
52302             function getCanonicalOverload(overloads, implementation) {
52303                 var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent;
52304                 return implementationSharesContainerWithFirstOverload ? implementation : overloads[0];
52305             }
52306             function checkFlagAgreementBetweenOverloads(overloads, implementation, flagsToCheck, someOverloadFlags, allOverloadFlags) {
52307                 var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags;
52308                 if (someButNotAllOverloadFlags !== 0) {
52309                     var canonicalFlags_1 = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck);
52310                     ts.forEach(overloads, function (o) {
52311                         var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags_1;
52312                         if (deviation & 1) {
52313                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported);
52314                         }
52315                         else if (deviation & 2) {
52316                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient);
52317                         }
52318                         else if (deviation & (8 | 16)) {
52319                             error(ts.getNameOfDeclaration(o) || o, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected);
52320                         }
52321                         else if (deviation & 128) {
52322                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract);
52323                         }
52324                     });
52325                 }
52326             }
52327             function checkQuestionTokenAgreementBetweenOverloads(overloads, implementation, someHaveQuestionToken, allHaveQuestionToken) {
52328                 if (someHaveQuestionToken !== allHaveQuestionToken) {
52329                     var canonicalHasQuestionToken_1 = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation));
52330                     ts.forEach(overloads, function (o) {
52331                         var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken_1;
52332                         if (deviation) {
52333                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_optional_or_required);
52334                         }
52335                     });
52336                 }
52337             }
52338             var flagsToCheck = 1 | 2 | 8 | 16 | 128;
52339             var someNodeFlags = 0;
52340             var allNodeFlags = flagsToCheck;
52341             var someHaveQuestionToken = false;
52342             var allHaveQuestionToken = true;
52343             var hasOverloads = false;
52344             var bodyDeclaration;
52345             var lastSeenNonAmbientDeclaration;
52346             var previousDeclaration;
52347             var declarations = symbol.declarations;
52348             var isConstructor = (symbol.flags & 16384) !== 0;
52349             function reportImplementationExpectedError(node) {
52350                 if (node.name && ts.nodeIsMissing(node.name)) {
52351                     return;
52352                 }
52353                 var seen = false;
52354                 var subsequentNode = ts.forEachChild(node.parent, function (c) {
52355                     if (seen) {
52356                         return c;
52357                     }
52358                     else {
52359                         seen = c === node;
52360                     }
52361                 });
52362                 if (subsequentNode && subsequentNode.pos === node.end) {
52363                     if (subsequentNode.kind === node.kind) {
52364                         var errorNode_1 = subsequentNode.name || subsequentNode;
52365                         var subsequentName = subsequentNode.name;
52366                         if (node.name && subsequentName && (ts.isPrivateIdentifier(node.name) && ts.isPrivateIdentifier(subsequentName) && node.name.escapedText === subsequentName.escapedText ||
52367                             ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) ||
52368                             ts.isPropertyNameLiteral(node.name) && ts.isPropertyNameLiteral(subsequentName) &&
52369                                 ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) {
52370                             var reportError = (node.kind === 161 || node.kind === 160) &&
52371                                 ts.hasModifier(node, 32) !== ts.hasModifier(subsequentNode, 32);
52372                             if (reportError) {
52373                                 var diagnostic = ts.hasModifier(node, 32) ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static;
52374                                 error(errorNode_1, diagnostic);
52375                             }
52376                             return;
52377                         }
52378                         if (ts.nodeIsPresent(subsequentNode.body)) {
52379                             error(errorNode_1, ts.Diagnostics.Function_implementation_name_must_be_0, ts.declarationNameToString(node.name));
52380                             return;
52381                         }
52382                     }
52383                 }
52384                 var errorNode = node.name || node;
52385                 if (isConstructor) {
52386                     error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing);
52387                 }
52388                 else {
52389                     if (ts.hasModifier(node, 128)) {
52390                         error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive);
52391                     }
52392                     else {
52393                         error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration);
52394                     }
52395                 }
52396             }
52397             var duplicateFunctionDeclaration = false;
52398             var multipleConstructorImplementation = false;
52399             var hasNonAmbientClass = false;
52400             for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
52401                 var current = declarations_4[_i];
52402                 var node = current;
52403                 var inAmbientContext = node.flags & 8388608;
52404                 var inAmbientContextOrInterface = node.parent.kind === 246 || node.parent.kind === 173 || inAmbientContext;
52405                 if (inAmbientContextOrInterface) {
52406                     previousDeclaration = undefined;
52407                 }
52408                 if ((node.kind === 245 || node.kind === 214) && !inAmbientContext) {
52409                     hasNonAmbientClass = true;
52410                 }
52411                 if (node.kind === 244 || node.kind === 161 || node.kind === 160 || node.kind === 162) {
52412                     var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck);
52413                     someNodeFlags |= currentNodeFlags;
52414                     allNodeFlags &= currentNodeFlags;
52415                     someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node);
52416                     allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node);
52417                     if (ts.nodeIsPresent(node.body) && bodyDeclaration) {
52418                         if (isConstructor) {
52419                             multipleConstructorImplementation = true;
52420                         }
52421                         else {
52422                             duplicateFunctionDeclaration = true;
52423                         }
52424                     }
52425                     else if (previousDeclaration && previousDeclaration.parent === node.parent && previousDeclaration.end !== node.pos) {
52426                         reportImplementationExpectedError(previousDeclaration);
52427                     }
52428                     if (ts.nodeIsPresent(node.body)) {
52429                         if (!bodyDeclaration) {
52430                             bodyDeclaration = node;
52431                         }
52432                     }
52433                     else {
52434                         hasOverloads = true;
52435                     }
52436                     previousDeclaration = node;
52437                     if (!inAmbientContextOrInterface) {
52438                         lastSeenNonAmbientDeclaration = node;
52439                     }
52440                 }
52441             }
52442             if (multipleConstructorImplementation) {
52443                 ts.forEach(declarations, function (declaration) {
52444                     error(declaration, ts.Diagnostics.Multiple_constructor_implementations_are_not_allowed);
52445                 });
52446             }
52447             if (duplicateFunctionDeclaration) {
52448                 ts.forEach(declarations, function (declaration) {
52449                     error(ts.getNameOfDeclaration(declaration), ts.Diagnostics.Duplicate_function_implementation);
52450                 });
52451             }
52452             if (hasNonAmbientClass && !isConstructor && symbol.flags & 16) {
52453                 ts.forEach(declarations, function (declaration) {
52454                     addDuplicateDeclarationError(declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), declarations);
52455                 });
52456             }
52457             if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body &&
52458                 !ts.hasModifier(lastSeenNonAmbientDeclaration, 128) && !lastSeenNonAmbientDeclaration.questionToken) {
52459                 reportImplementationExpectedError(lastSeenNonAmbientDeclaration);
52460             }
52461             if (hasOverloads) {
52462                 checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags);
52463                 checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken);
52464                 if (bodyDeclaration) {
52465                     var signatures = getSignaturesOfSymbol(symbol);
52466                     var bodySignature = getSignatureFromDeclaration(bodyDeclaration);
52467                     for (var _a = 0, signatures_10 = signatures; _a < signatures_10.length; _a++) {
52468                         var signature = signatures_10[_a];
52469                         if (!isImplementationCompatibleWithOverload(bodySignature, signature)) {
52470                             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));
52471                             break;
52472                         }
52473                     }
52474                 }
52475             }
52476         }
52477         function checkExportsOnMergedDeclarations(node) {
52478             if (!produceDiagnostics) {
52479                 return;
52480             }
52481             var symbol = node.localSymbol;
52482             if (!symbol) {
52483                 symbol = getSymbolOfNode(node);
52484                 if (!symbol.exportSymbol) {
52485                     return;
52486                 }
52487             }
52488             if (ts.getDeclarationOfKind(symbol, node.kind) !== node) {
52489                 return;
52490             }
52491             var exportedDeclarationSpaces = 0;
52492             var nonExportedDeclarationSpaces = 0;
52493             var defaultExportedDeclarationSpaces = 0;
52494             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
52495                 var d = _a[_i];
52496                 var declarationSpaces = getDeclarationSpaces(d);
52497                 var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 | 512);
52498                 if (effectiveDeclarationFlags & 1) {
52499                     if (effectiveDeclarationFlags & 512) {
52500                         defaultExportedDeclarationSpaces |= declarationSpaces;
52501                     }
52502                     else {
52503                         exportedDeclarationSpaces |= declarationSpaces;
52504                     }
52505                 }
52506                 else {
52507                     nonExportedDeclarationSpaces |= declarationSpaces;
52508                 }
52509             }
52510             var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces;
52511             var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces;
52512             var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces;
52513             if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) {
52514                 for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) {
52515                     var d = _c[_b];
52516                     var declarationSpaces = getDeclarationSpaces(d);
52517                     var name = ts.getNameOfDeclaration(d);
52518                     if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) {
52519                         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));
52520                     }
52521                     else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) {
52522                         error(name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(name));
52523                     }
52524                 }
52525             }
52526             function getDeclarationSpaces(decl) {
52527                 var d = decl;
52528                 switch (d.kind) {
52529                     case 246:
52530                     case 247:
52531                     case 322:
52532                     case 315:
52533                     case 316:
52534                         return 2;
52535                     case 249:
52536                         return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0
52537                             ? 4 | 1
52538                             : 4;
52539                     case 245:
52540                     case 248:
52541                     case 284:
52542                         return 2 | 1;
52543                     case 290:
52544                         return 2 | 1 | 4;
52545                     case 259:
52546                         if (!ts.isEntityNameExpression(d.expression)) {
52547                             return 1;
52548                         }
52549                         d = d.expression;
52550                     case 253:
52551                     case 256:
52552                     case 255:
52553                         var result_10 = 0;
52554                         var target = resolveAlias(getSymbolOfNode(d));
52555                         ts.forEach(target.declarations, function (d) { result_10 |= getDeclarationSpaces(d); });
52556                         return result_10;
52557                     case 242:
52558                     case 191:
52559                     case 244:
52560                     case 258:
52561                     case 75:
52562                         return 1;
52563                     default:
52564                         return ts.Debug.failBadSyntaxKind(d);
52565                 }
52566             }
52567         }
52568         function getAwaitedTypeOfPromise(type, errorNode, diagnosticMessage, arg0) {
52569             var promisedType = getPromisedTypeOfPromise(type, errorNode);
52570             return promisedType && getAwaitedType(promisedType, errorNode, diagnosticMessage, arg0);
52571         }
52572         function getPromisedTypeOfPromise(type, errorNode) {
52573             if (isTypeAny(type)) {
52574                 return undefined;
52575             }
52576             var typeAsPromise = type;
52577             if (typeAsPromise.promisedTypeOfPromise) {
52578                 return typeAsPromise.promisedTypeOfPromise;
52579             }
52580             if (isReferenceToType(type, getGlobalPromiseType(false))) {
52581                 return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0];
52582             }
52583             var thenFunction = getTypeOfPropertyOfType(type, "then");
52584             if (isTypeAny(thenFunction)) {
52585                 return undefined;
52586             }
52587             var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0) : ts.emptyArray;
52588             if (thenSignatures.length === 0) {
52589                 if (errorNode) {
52590                     error(errorNode, ts.Diagnostics.A_promise_must_have_a_then_method);
52591                 }
52592                 return undefined;
52593             }
52594             var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152);
52595             if (isTypeAny(onfulfilledParameterType)) {
52596                 return undefined;
52597             }
52598             var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0);
52599             if (onfulfilledParameterSignatures.length === 0) {
52600                 if (errorNode) {
52601                     error(errorNode, ts.Diagnostics.The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback);
52602                 }
52603                 return undefined;
52604             }
52605             return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2);
52606         }
52607         function checkAwaitedType(type, errorNode, diagnosticMessage, arg0) {
52608             var awaitedType = getAwaitedType(type, errorNode, diagnosticMessage, arg0);
52609             return awaitedType || errorType;
52610         }
52611         function isThenableType(type) {
52612             var thenFunction = getTypeOfPropertyOfType(type, "then");
52613             return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152), 0).length > 0;
52614         }
52615         function getAwaitedType(type, errorNode, diagnosticMessage, arg0) {
52616             if (isTypeAny(type)) {
52617                 return type;
52618             }
52619             var typeAsAwaitable = type;
52620             if (typeAsAwaitable.awaitedTypeOfType) {
52621                 return typeAsAwaitable.awaitedTypeOfType;
52622             }
52623             return typeAsAwaitable.awaitedTypeOfType =
52624                 mapType(type, errorNode ? function (constituentType) { return getAwaitedTypeWorker(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeWorker);
52625         }
52626         function getAwaitedTypeWorker(type, errorNode, diagnosticMessage, arg0) {
52627             var typeAsAwaitable = type;
52628             if (typeAsAwaitable.awaitedTypeOfType) {
52629                 return typeAsAwaitable.awaitedTypeOfType;
52630             }
52631             var promisedType = getPromisedTypeOfPromise(type);
52632             if (promisedType) {
52633                 if (type.id === promisedType.id || awaitedTypeStack.lastIndexOf(promisedType.id) >= 0) {
52634                     if (errorNode) {
52635                         error(errorNode, ts.Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method);
52636                     }
52637                     return undefined;
52638                 }
52639                 awaitedTypeStack.push(type.id);
52640                 var awaitedType = getAwaitedType(promisedType, errorNode, diagnosticMessage, arg0);
52641                 awaitedTypeStack.pop();
52642                 if (!awaitedType) {
52643                     return undefined;
52644                 }
52645                 return typeAsAwaitable.awaitedTypeOfType = awaitedType;
52646             }
52647             if (isThenableType(type)) {
52648                 if (errorNode) {
52649                     if (!diagnosticMessage)
52650                         return ts.Debug.fail();
52651                     error(errorNode, diagnosticMessage, arg0);
52652                 }
52653                 return undefined;
52654             }
52655             return typeAsAwaitable.awaitedTypeOfType = type;
52656         }
52657         function checkAsyncFunctionReturnType(node, returnTypeNode) {
52658             var returnType = getTypeFromTypeNode(returnTypeNode);
52659             if (languageVersion >= 2) {
52660                 if (returnType === errorType) {
52661                     return;
52662                 }
52663                 var globalPromiseType = getGlobalPromiseType(true);
52664                 if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) {
52665                     error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type);
52666                     return;
52667                 }
52668             }
52669             else {
52670                 markTypeNodeAsReferenced(returnTypeNode);
52671                 if (returnType === errorType) {
52672                     return;
52673                 }
52674                 var promiseConstructorName = ts.getEntityNameFromTypeNode(returnTypeNode);
52675                 if (promiseConstructorName === undefined) {
52676                     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));
52677                     return;
52678                 }
52679                 var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551, true);
52680                 var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType;
52681                 if (promiseConstructorType === errorType) {
52682                     if (promiseConstructorName.kind === 75 && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(false)) {
52683                         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);
52684                     }
52685                     else {
52686                         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));
52687                     }
52688                     return;
52689                 }
52690                 var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(true);
52691                 if (globalPromiseConstructorLikeType === emptyObjectType) {
52692                     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));
52693                     return;
52694                 }
52695                 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)) {
52696                     return;
52697                 }
52698                 var rootName = promiseConstructorName && ts.getFirstIdentifier(promiseConstructorName);
52699                 var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551);
52700                 if (collidingSymbol) {
52701                     error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName));
52702                     return;
52703                 }
52704             }
52705             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);
52706         }
52707         function checkDecorator(node) {
52708             var signature = getResolvedSignature(node);
52709             var returnType = getReturnTypeOfSignature(signature);
52710             if (returnType.flags & 1) {
52711                 return;
52712             }
52713             var expectedReturnType;
52714             var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
52715             var errorInfo;
52716             switch (node.parent.kind) {
52717                 case 245:
52718                     var classSymbol = getSymbolOfNode(node.parent);
52719                     var classConstructorType = getTypeOfSymbol(classSymbol);
52720                     expectedReturnType = getUnionType([classConstructorType, voidType]);
52721                     break;
52722                 case 156:
52723                     expectedReturnType = voidType;
52724                     errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any);
52725                     break;
52726                 case 159:
52727                     expectedReturnType = voidType;
52728                     errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any);
52729                     break;
52730                 case 161:
52731                 case 163:
52732                 case 164:
52733                     var methodType = getTypeOfNode(node.parent);
52734                     var descriptorType = createTypedPropertyDescriptorType(methodType);
52735                     expectedReturnType = getUnionType([descriptorType, voidType]);
52736                     break;
52737                 default:
52738                     return ts.Debug.fail();
52739             }
52740             checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, function () { return errorInfo; });
52741         }
52742         function markTypeNodeAsReferenced(node) {
52743             markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node));
52744         }
52745         function markEntityNameOrEntityExpressionAsReference(typeName) {
52746             if (!typeName)
52747                 return;
52748             var rootName = ts.getFirstIdentifier(typeName);
52749             var meaning = (typeName.kind === 75 ? 788968 : 1920) | 2097152;
52750             var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, undefined, undefined, true);
52751             if (rootSymbol
52752                 && rootSymbol.flags & 2097152
52753                 && symbolIsValue(rootSymbol)
52754                 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))
52755                 && !getTypeOnlyAliasDeclaration(rootSymbol)) {
52756                 markAliasSymbolAsReferenced(rootSymbol);
52757             }
52758         }
52759         function markDecoratorMedataDataTypeNodeAsReferenced(node) {
52760             var entityName = getEntityNameForDecoratorMetadata(node);
52761             if (entityName && ts.isEntityName(entityName)) {
52762                 markEntityNameOrEntityExpressionAsReference(entityName);
52763             }
52764         }
52765         function getEntityNameForDecoratorMetadata(node) {
52766             if (node) {
52767                 switch (node.kind) {
52768                     case 179:
52769                     case 178:
52770                         return getEntityNameForDecoratorMetadataFromTypeList(node.types);
52771                     case 180:
52772                         return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]);
52773                     case 182:
52774                         return getEntityNameForDecoratorMetadata(node.type);
52775                     case 169:
52776                         return node.typeName;
52777                 }
52778             }
52779         }
52780         function getEntityNameForDecoratorMetadataFromTypeList(types) {
52781             var commonEntityName;
52782             for (var _i = 0, types_20 = types; _i < types_20.length; _i++) {
52783                 var typeNode = types_20[_i];
52784                 while (typeNode.kind === 182) {
52785                     typeNode = typeNode.type;
52786                 }
52787                 if (typeNode.kind === 137) {
52788                     continue;
52789                 }
52790                 if (!strictNullChecks && (typeNode.kind === 100 || typeNode.kind === 146)) {
52791                     continue;
52792                 }
52793                 var individualEntityName = getEntityNameForDecoratorMetadata(typeNode);
52794                 if (!individualEntityName) {
52795                     return undefined;
52796                 }
52797                 if (commonEntityName) {
52798                     if (!ts.isIdentifier(commonEntityName) ||
52799                         !ts.isIdentifier(individualEntityName) ||
52800                         commonEntityName.escapedText !== individualEntityName.escapedText) {
52801                         return undefined;
52802                     }
52803                 }
52804                 else {
52805                     commonEntityName = individualEntityName;
52806                 }
52807             }
52808             return commonEntityName;
52809         }
52810         function getParameterTypeNodeForDecoratorCheck(node) {
52811             var typeNode = ts.getEffectiveTypeAnnotationNode(node);
52812             return ts.isRestParameter(node) ? ts.getRestParameterElementType(typeNode) : typeNode;
52813         }
52814         function checkDecorators(node) {
52815             if (!node.decorators) {
52816                 return;
52817             }
52818             if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) {
52819                 return;
52820             }
52821             if (!compilerOptions.experimentalDecorators) {
52822                 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);
52823             }
52824             var firstDecorator = node.decorators[0];
52825             checkExternalEmitHelpers(firstDecorator, 8);
52826             if (node.kind === 156) {
52827                 checkExternalEmitHelpers(firstDecorator, 32);
52828             }
52829             if (compilerOptions.emitDecoratorMetadata) {
52830                 checkExternalEmitHelpers(firstDecorator, 16);
52831                 switch (node.kind) {
52832                     case 245:
52833                         var constructor = ts.getFirstConstructorWithBody(node);
52834                         if (constructor) {
52835                             for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) {
52836                                 var parameter = _a[_i];
52837                                 markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
52838                             }
52839                         }
52840                         break;
52841                     case 163:
52842                     case 164:
52843                         var otherKind = node.kind === 163 ? 164 : 163;
52844                         var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind);
52845                         markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor));
52846                         break;
52847                     case 161:
52848                         for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) {
52849                             var parameter = _c[_b];
52850                             markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
52851                         }
52852                         markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node));
52853                         break;
52854                     case 159:
52855                         markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node));
52856                         break;
52857                     case 156:
52858                         markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node));
52859                         var containingSignature = node.parent;
52860                         for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) {
52861                             var parameter = _e[_d];
52862                             markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
52863                         }
52864                         break;
52865                 }
52866             }
52867             ts.forEach(node.decorators, checkDecorator);
52868         }
52869         function checkFunctionDeclaration(node) {
52870             if (produceDiagnostics) {
52871                 checkFunctionOrMethodDeclaration(node);
52872                 checkGrammarForGenerator(node);
52873                 checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
52874                 checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
52875             }
52876         }
52877         function checkJSDocTypeAliasTag(node) {
52878             if (!node.typeExpression) {
52879                 error(node.name, ts.Diagnostics.JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags);
52880             }
52881             if (node.name) {
52882                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0);
52883             }
52884             checkSourceElement(node.typeExpression);
52885         }
52886         function checkJSDocTemplateTag(node) {
52887             checkSourceElement(node.constraint);
52888             for (var _i = 0, _a = node.typeParameters; _i < _a.length; _i++) {
52889                 var tp = _a[_i];
52890                 checkSourceElement(tp);
52891             }
52892         }
52893         function checkJSDocTypeTag(node) {
52894             checkSourceElement(node.typeExpression);
52895         }
52896         function checkJSDocParameterTag(node) {
52897             checkSourceElement(node.typeExpression);
52898             if (!ts.getParameterSymbolFromJSDoc(node)) {
52899                 var decl = ts.getHostSignatureFromJSDoc(node);
52900                 if (decl) {
52901                     var i = ts.getJSDocTags(decl).filter(ts.isJSDocParameterTag).indexOf(node);
52902                     if (i > -1 && i < decl.parameters.length && ts.isBindingPattern(decl.parameters[i].name)) {
52903                         return;
52904                     }
52905                     if (!containsArgumentsReference(decl)) {
52906                         if (ts.isQualifiedName(node.name)) {
52907                             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));
52908                         }
52909                         else {
52910                             error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name));
52911                         }
52912                     }
52913                     else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node &&
52914                         node.typeExpression && node.typeExpression.type &&
52915                         !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) {
52916                         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));
52917                     }
52918                 }
52919             }
52920         }
52921         function checkJSDocPropertyTag(node) {
52922             checkSourceElement(node.typeExpression);
52923         }
52924         function checkJSDocFunctionType(node) {
52925             if (produceDiagnostics && !node.type && !ts.isJSDocConstructSignature(node)) {
52926                 reportImplicitAny(node, anyType);
52927             }
52928             checkSignatureDeclaration(node);
52929         }
52930         function checkJSDocImplementsTag(node) {
52931             var classLike = ts.getEffectiveJSDocHost(node);
52932             if (!classLike || !ts.isClassDeclaration(classLike) && !ts.isClassExpression(classLike)) {
52933                 error(classLike, ts.Diagnostics.JSDoc_0_is_not_attached_to_a_class, ts.idText(node.tagName));
52934             }
52935         }
52936         function checkJSDocAugmentsTag(node) {
52937             var classLike = ts.getEffectiveJSDocHost(node);
52938             if (!classLike || !ts.isClassDeclaration(classLike) && !ts.isClassExpression(classLike)) {
52939                 error(classLike, ts.Diagnostics.JSDoc_0_is_not_attached_to_a_class, ts.idText(node.tagName));
52940                 return;
52941             }
52942             var augmentsTags = ts.getJSDocTags(classLike).filter(ts.isJSDocAugmentsTag);
52943             ts.Debug.assert(augmentsTags.length > 0);
52944             if (augmentsTags.length > 1) {
52945                 error(augmentsTags[1], ts.Diagnostics.Class_declarations_cannot_have_more_than_one_augments_or_extends_tag);
52946             }
52947             var name = getIdentifierFromEntityNameExpression(node.class.expression);
52948             var extend = ts.getClassExtendsHeritageElement(classLike);
52949             if (extend) {
52950                 var className = getIdentifierFromEntityNameExpression(extend.expression);
52951                 if (className && name.escapedText !== className.escapedText) {
52952                     error(name, ts.Diagnostics.JSDoc_0_1_does_not_match_the_extends_2_clause, ts.idText(node.tagName), ts.idText(name), ts.idText(className));
52953                 }
52954             }
52955         }
52956         function getIdentifierFromEntityNameExpression(node) {
52957             switch (node.kind) {
52958                 case 75:
52959                     return node;
52960                 case 194:
52961                     return node.name;
52962                 default:
52963                     return undefined;
52964             }
52965         }
52966         function checkFunctionOrMethodDeclaration(node) {
52967             checkDecorators(node);
52968             checkSignatureDeclaration(node);
52969             var functionFlags = ts.getFunctionFlags(node);
52970             if (node.name && node.name.kind === 154) {
52971                 checkComputedPropertyName(node.name);
52972             }
52973             if (!hasNonBindableDynamicName(node)) {
52974                 var symbol = getSymbolOfNode(node);
52975                 var localSymbol = node.localSymbol || symbol;
52976                 var firstDeclaration = ts.find(localSymbol.declarations, function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072); });
52977                 if (node === firstDeclaration) {
52978                     checkFunctionOrConstructorSymbol(localSymbol);
52979                 }
52980                 if (symbol.parent) {
52981                     if (ts.getDeclarationOfKind(symbol, node.kind) === node) {
52982                         checkFunctionOrConstructorSymbol(symbol);
52983                     }
52984                 }
52985             }
52986             var body = node.kind === 160 ? undefined : node.body;
52987             checkSourceElement(body);
52988             checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node));
52989             if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) {
52990                 if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) {
52991                     reportImplicitAny(node, anyType);
52992                 }
52993                 if (functionFlags & 1 && ts.nodeIsPresent(body)) {
52994                     getReturnTypeOfSignature(getSignatureFromDeclaration(node));
52995                 }
52996             }
52997             if (ts.isInJSFile(node)) {
52998                 var typeTag = ts.getJSDocTypeTag(node);
52999                 if (typeTag && typeTag.typeExpression && !getContextualCallSignature(getTypeFromTypeNode(typeTag.typeExpression), node)) {
53000                     error(typeTag, ts.Diagnostics.The_type_of_a_function_declaration_must_match_the_function_s_signature);
53001                 }
53002             }
53003         }
53004         function registerForUnusedIdentifiersCheck(node) {
53005             if (produceDiagnostics) {
53006                 var sourceFile = ts.getSourceFileOfNode(node);
53007                 var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path);
53008                 if (!potentiallyUnusedIdentifiers) {
53009                     potentiallyUnusedIdentifiers = [];
53010                     allPotentiallyUnusedIdentifiers.set(sourceFile.path, potentiallyUnusedIdentifiers);
53011                 }
53012                 potentiallyUnusedIdentifiers.push(node);
53013             }
53014         }
53015         function checkUnusedIdentifiers(potentiallyUnusedIdentifiers, addDiagnostic) {
53016             for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) {
53017                 var node = potentiallyUnusedIdentifiers_1[_i];
53018                 switch (node.kind) {
53019                     case 245:
53020                     case 214:
53021                         checkUnusedClassMembers(node, addDiagnostic);
53022                         checkUnusedTypeParameters(node, addDiagnostic);
53023                         break;
53024                     case 290:
53025                     case 249:
53026                     case 223:
53027                     case 251:
53028                     case 230:
53029                     case 231:
53030                     case 232:
53031                         checkUnusedLocalsAndParameters(node, addDiagnostic);
53032                         break;
53033                     case 162:
53034                     case 201:
53035                     case 244:
53036                     case 202:
53037                     case 161:
53038                     case 163:
53039                     case 164:
53040                         if (node.body) {
53041                             checkUnusedLocalsAndParameters(node, addDiagnostic);
53042                         }
53043                         checkUnusedTypeParameters(node, addDiagnostic);
53044                         break;
53045                     case 160:
53046                     case 165:
53047                     case 166:
53048                     case 170:
53049                     case 171:
53050                     case 247:
53051                     case 246:
53052                         checkUnusedTypeParameters(node, addDiagnostic);
53053                         break;
53054                     case 181:
53055                         checkUnusedInferTypeParameter(node, addDiagnostic);
53056                         break;
53057                     default:
53058                         ts.Debug.assertNever(node, "Node should not have been registered for unused identifiers check");
53059                 }
53060             }
53061         }
53062         function errorUnusedLocal(declaration, name, addDiagnostic) {
53063             var node = ts.getNameOfDeclaration(declaration) || declaration;
53064             var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
53065             addDiagnostic(declaration, 0, ts.createDiagnosticForNode(node, message, name));
53066         }
53067         function isIdentifierThatStartsWithUnderscore(node) {
53068             return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95;
53069         }
53070         function checkUnusedClassMembers(node, addDiagnostic) {
53071             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
53072                 var member = _a[_i];
53073                 switch (member.kind) {
53074                     case 161:
53075                     case 159:
53076                     case 163:
53077                     case 164:
53078                         if (member.kind === 164 && member.symbol.flags & 32768) {
53079                             break;
53080                         }
53081                         var symbol = getSymbolOfNode(member);
53082                         if (!symbol.isReferenced
53083                             && (ts.hasModifier(member, 8) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name))
53084                             && !(member.flags & 8388608)) {
53085                             addDiagnostic(member, 0, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol)));
53086                         }
53087                         break;
53088                     case 162:
53089                         for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) {
53090                             var parameter = _c[_b];
53091                             if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8)) {
53092                                 addDiagnostic(parameter, 0, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol)));
53093                             }
53094                         }
53095                         break;
53096                     case 167:
53097                     case 222:
53098                         break;
53099                     default:
53100                         ts.Debug.fail();
53101                 }
53102             }
53103         }
53104         function checkUnusedInferTypeParameter(node, addDiagnostic) {
53105             var typeParameter = node.typeParameter;
53106             if (isTypeParameterUnused(typeParameter)) {
53107                 addDiagnostic(node, 1, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name)));
53108             }
53109         }
53110         function checkUnusedTypeParameters(node, addDiagnostic) {
53111             if (ts.last(getSymbolOfNode(node).declarations) !== node)
53112                 return;
53113             var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
53114             var seenParentsWithEveryUnused = new ts.NodeSet();
53115             for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) {
53116                 var typeParameter = typeParameters_3[_i];
53117                 if (!isTypeParameterUnused(typeParameter))
53118                     continue;
53119                 var name = ts.idText(typeParameter.name);
53120                 var parent = typeParameter.parent;
53121                 if (parent.kind !== 181 && parent.typeParameters.every(isTypeParameterUnused)) {
53122                     if (seenParentsWithEveryUnused.tryAdd(parent)) {
53123                         var range = ts.isJSDocTemplateTag(parent)
53124                             ? ts.rangeOfNode(parent)
53125                             : ts.rangeOfTypeParameters(parent.typeParameters);
53126                         var only = parent.typeParameters.length === 1;
53127                         var message = only ? ts.Diagnostics._0_is_declared_but_its_value_is_never_read : ts.Diagnostics.All_type_parameters_are_unused;
53128                         var arg0 = only ? name : undefined;
53129                         addDiagnostic(typeParameter, 1, ts.createFileDiagnostic(ts.getSourceFileOfNode(parent), range.pos, range.end - range.pos, message, arg0));
53130                     }
53131                 }
53132                 else {
53133                     addDiagnostic(typeParameter, 1, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name));
53134                 }
53135             }
53136         }
53137         function isTypeParameterUnused(typeParameter) {
53138             return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144) && !isIdentifierThatStartsWithUnderscore(typeParameter.name);
53139         }
53140         function addToGroup(map, key, value, getKey) {
53141             var keyString = String(getKey(key));
53142             var group = map.get(keyString);
53143             if (group) {
53144                 group[1].push(value);
53145             }
53146             else {
53147                 map.set(keyString, [key, [value]]);
53148             }
53149         }
53150         function tryGetRootParameterDeclaration(node) {
53151             return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter);
53152         }
53153         function isValidUnusedLocalDeclaration(declaration) {
53154             if (ts.isBindingElement(declaration) && isIdentifierThatStartsWithUnderscore(declaration.name)) {
53155                 return !!ts.findAncestor(declaration.parent, function (ancestor) {
53156                     return ts.isArrayBindingPattern(ancestor) || ts.isVariableDeclaration(ancestor) || ts.isVariableDeclarationList(ancestor) ? false :
53157                         ts.isForOfStatement(ancestor) ? true : "quit";
53158                 });
53159             }
53160             return ts.isAmbientModule(declaration) ||
53161                 (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderscore(declaration.name);
53162         }
53163         function checkUnusedLocalsAndParameters(nodeWithLocals, addDiagnostic) {
53164             var unusedImports = ts.createMap();
53165             var unusedDestructures = ts.createMap();
53166             var unusedVariables = ts.createMap();
53167             nodeWithLocals.locals.forEach(function (local) {
53168                 if (local.flags & 262144 ? !(local.flags & 3 && !(local.isReferenced & 3)) : local.isReferenced || local.exportSymbol) {
53169                     return;
53170                 }
53171                 for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) {
53172                     var declaration = _a[_i];
53173                     if (isValidUnusedLocalDeclaration(declaration)) {
53174                         continue;
53175                     }
53176                     if (isImportedDeclaration(declaration)) {
53177                         addToGroup(unusedImports, importClauseFromImported(declaration), declaration, getNodeId);
53178                     }
53179                     else if (ts.isBindingElement(declaration) && ts.isObjectBindingPattern(declaration.parent)) {
53180                         var lastElement = ts.last(declaration.parent.elements);
53181                         if (declaration === lastElement || !ts.last(declaration.parent.elements).dotDotDotToken) {
53182                             addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId);
53183                         }
53184                     }
53185                     else if (ts.isVariableDeclaration(declaration)) {
53186                         addToGroup(unusedVariables, declaration.parent, declaration, getNodeId);
53187                     }
53188                     else {
53189                         var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration);
53190                         var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration);
53191                         if (parameter && name) {
53192                             if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) {
53193                                 addDiagnostic(parameter, 1, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local)));
53194                             }
53195                         }
53196                         else {
53197                             errorUnusedLocal(declaration, ts.symbolName(local), addDiagnostic);
53198                         }
53199                     }
53200                 }
53201             });
53202             unusedImports.forEach(function (_a) {
53203                 var importClause = _a[0], unuseds = _a[1];
53204                 var importDecl = importClause.parent;
53205                 var nDeclarations = (importClause.name ? 1 : 0) +
53206                     (importClause.namedBindings ?
53207                         (importClause.namedBindings.kind === 256 ? 1 : importClause.namedBindings.elements.length)
53208                         : 0);
53209                 if (nDeclarations === unuseds.length) {
53210                     addDiagnostic(importDecl, 0, unuseds.length === 1
53211                         ? ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name))
53212                         : ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused));
53213                 }
53214                 else {
53215                     for (var _i = 0, unuseds_1 = unuseds; _i < unuseds_1.length; _i++) {
53216                         var unused = unuseds_1[_i];
53217                         errorUnusedLocal(unused, ts.idText(unused.name), addDiagnostic);
53218                     }
53219                 }
53220             });
53221             unusedDestructures.forEach(function (_a) {
53222                 var bindingPattern = _a[0], bindingElements = _a[1];
53223                 var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 : 0;
53224                 if (bindingPattern.elements.length === bindingElements.length) {
53225                     if (bindingElements.length === 1 && bindingPattern.parent.kind === 242 && bindingPattern.parent.parent.kind === 243) {
53226                         addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId);
53227                     }
53228                     else {
53229                         addDiagnostic(bindingPattern, kind, bindingElements.length === 1
53230                             ? ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(bindingElements).name))
53231                             : ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics.All_destructured_elements_are_unused));
53232                     }
53233                 }
53234                 else {
53235                     for (var _i = 0, bindingElements_1 = bindingElements; _i < bindingElements_1.length; _i++) {
53236                         var e = bindingElements_1[_i];
53237                         addDiagnostic(e, kind, ts.createDiagnosticForNode(e, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(e.name)));
53238                     }
53239                 }
53240             });
53241             unusedVariables.forEach(function (_a) {
53242                 var declarationList = _a[0], declarations = _a[1];
53243                 if (declarationList.declarations.length === declarations.length) {
53244                     addDiagnostic(declarationList, 0, declarations.length === 1
53245                         ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name))
53246                         : ts.createDiagnosticForNode(declarationList.parent.kind === 225 ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused));
53247                 }
53248                 else {
53249                     for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
53250                         var decl = declarations_5[_i];
53251                         addDiagnostic(decl, 0, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name)));
53252                     }
53253                 }
53254             });
53255         }
53256         function bindingNameText(name) {
53257             switch (name.kind) {
53258                 case 75:
53259                     return ts.idText(name);
53260                 case 190:
53261                 case 189:
53262                     return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name);
53263                 default:
53264                     return ts.Debug.assertNever(name);
53265             }
53266         }
53267         function isImportedDeclaration(node) {
53268             return node.kind === 255 || node.kind === 258 || node.kind === 256;
53269         }
53270         function importClauseFromImported(decl) {
53271             return decl.kind === 255 ? decl : decl.kind === 256 ? decl.parent : decl.parent.parent;
53272         }
53273         function checkBlock(node) {
53274             if (node.kind === 223) {
53275                 checkGrammarStatementInAmbientContext(node);
53276             }
53277             if (ts.isFunctionOrModuleBlock(node)) {
53278                 var saveFlowAnalysisDisabled = flowAnalysisDisabled;
53279                 ts.forEach(node.statements, checkSourceElement);
53280                 flowAnalysisDisabled = saveFlowAnalysisDisabled;
53281             }
53282             else {
53283                 ts.forEach(node.statements, checkSourceElement);
53284             }
53285             if (node.locals) {
53286                 registerForUnusedIdentifiersCheck(node);
53287             }
53288         }
53289         function checkCollisionWithArgumentsInGeneratedCode(node) {
53290             if (languageVersion >= 2 || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 8388608 || ts.nodeIsMissing(node.body)) {
53291                 return;
53292             }
53293             ts.forEach(node.parameters, function (p) {
53294                 if (p.name && !ts.isBindingPattern(p.name) && p.name.escapedText === argumentsSymbol.escapedName) {
53295                     error(p, ts.Diagnostics.Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters);
53296                 }
53297             });
53298         }
53299         function needCollisionCheckForIdentifier(node, identifier, name) {
53300             if (!(identifier && identifier.escapedText === name)) {
53301                 return false;
53302             }
53303             if (node.kind === 159 ||
53304                 node.kind === 158 ||
53305                 node.kind === 161 ||
53306                 node.kind === 160 ||
53307                 node.kind === 163 ||
53308                 node.kind === 164) {
53309                 return false;
53310             }
53311             if (node.flags & 8388608) {
53312                 return false;
53313             }
53314             var root = ts.getRootDeclaration(node);
53315             if (root.kind === 156 && ts.nodeIsMissing(root.parent.body)) {
53316                 return false;
53317             }
53318             return true;
53319         }
53320         function checkIfThisIsCapturedInEnclosingScope(node) {
53321             ts.findAncestor(node, function (current) {
53322                 if (getNodeCheckFlags(current) & 4) {
53323                     var isDeclaration_1 = node.kind !== 75;
53324                     if (isDeclaration_1) {
53325                         error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference);
53326                     }
53327                     else {
53328                         error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference);
53329                     }
53330                     return true;
53331                 }
53332                 return false;
53333             });
53334         }
53335         function checkIfNewTargetIsCapturedInEnclosingScope(node) {
53336             ts.findAncestor(node, function (current) {
53337                 if (getNodeCheckFlags(current) & 8) {
53338                     var isDeclaration_2 = node.kind !== 75;
53339                     if (isDeclaration_2) {
53340                         error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference);
53341                     }
53342                     else {
53343                         error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference);
53344                     }
53345                     return true;
53346                 }
53347                 return false;
53348             });
53349         }
53350         function checkWeakMapCollision(node) {
53351             var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node);
53352             if (getNodeCheckFlags(enclosingBlockScope) & 67108864) {
53353                 error(node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, "WeakMap");
53354             }
53355         }
53356         function checkCollisionWithRequireExportsInGeneratedCode(node, name) {
53357             if (moduleKind >= ts.ModuleKind.ES2015 || compilerOptions.noEmit) {
53358                 return;
53359             }
53360             if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) {
53361                 return;
53362             }
53363             if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1) {
53364                 return;
53365             }
53366             var parent = getDeclarationContainer(node);
53367             if (parent.kind === 290 && ts.isExternalOrCommonJsModule(parent)) {
53368                 error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name));
53369             }
53370         }
53371         function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) {
53372             if (languageVersion >= 4 || compilerOptions.noEmit || !needCollisionCheckForIdentifier(node, name, "Promise")) {
53373                 return;
53374             }
53375             if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1) {
53376                 return;
53377             }
53378             var parent = getDeclarationContainer(node);
53379             if (parent.kind === 290 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048) {
53380                 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));
53381             }
53382         }
53383         function checkVarDeclaredNamesNotShadowed(node) {
53384             if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) {
53385                 return;
53386             }
53387             if (node.kind === 242 && !node.initializer) {
53388                 return;
53389             }
53390             var symbol = getSymbolOfNode(node);
53391             if (symbol.flags & 1) {
53392                 if (!ts.isIdentifier(node.name))
53393                     return ts.Debug.fail();
53394                 var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3, undefined, undefined, false);
53395                 if (localDeclarationSymbol &&
53396                     localDeclarationSymbol !== symbol &&
53397                     localDeclarationSymbol.flags & 2) {
53398                     if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) {
53399                         var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 243);
53400                         var container = varDeclList.parent.kind === 225 && varDeclList.parent.parent
53401                             ? varDeclList.parent.parent
53402                             : undefined;
53403                         var namesShareScope = container &&
53404                             (container.kind === 223 && ts.isFunctionLike(container.parent) ||
53405                                 container.kind === 250 ||
53406                                 container.kind === 249 ||
53407                                 container.kind === 290);
53408                         if (!namesShareScope) {
53409                             var name = symbolToString(localDeclarationSymbol);
53410                             error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name);
53411                         }
53412                     }
53413                 }
53414             }
53415         }
53416         function convertAutoToAny(type) {
53417             return type === autoType ? anyType : type === autoArrayType ? anyArrayType : type;
53418         }
53419         function checkVariableLikeDeclaration(node) {
53420             checkDecorators(node);
53421             if (!ts.isBindingElement(node)) {
53422                 checkSourceElement(node.type);
53423             }
53424             if (!node.name) {
53425                 return;
53426             }
53427             if (node.name.kind === 154) {
53428                 checkComputedPropertyName(node.name);
53429                 if (node.initializer) {
53430                     checkExpressionCached(node.initializer);
53431                 }
53432             }
53433             if (node.kind === 191) {
53434                 if (node.parent.kind === 189 && languageVersion < 99) {
53435                     checkExternalEmitHelpers(node, 4);
53436                 }
53437                 if (node.propertyName && node.propertyName.kind === 154) {
53438                     checkComputedPropertyName(node.propertyName);
53439                 }
53440                 var parent = node.parent.parent;
53441                 var parentType = getTypeForBindingElementParent(parent);
53442                 var name = node.propertyName || node.name;
53443                 if (parentType && !ts.isBindingPattern(name)) {
53444                     var exprType = getLiteralTypeFromPropertyName(name);
53445                     if (isTypeUsableAsPropertyName(exprType)) {
53446                         var nameText = getPropertyNameFromType(exprType);
53447                         var property = getPropertyOfType(parentType, nameText);
53448                         if (property) {
53449                             markPropertyAsReferenced(property, undefined, false);
53450                             checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 102, parentType, property);
53451                         }
53452                     }
53453                 }
53454             }
53455             if (ts.isBindingPattern(node.name)) {
53456                 if (node.name.kind === 190 && languageVersion < 2 && compilerOptions.downlevelIteration) {
53457                     checkExternalEmitHelpers(node, 512);
53458                 }
53459                 ts.forEach(node.name.elements, checkSourceElement);
53460             }
53461             if (node.initializer && ts.getRootDeclaration(node).kind === 156 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) {
53462                 error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation);
53463                 return;
53464             }
53465             if (ts.isBindingPattern(node.name)) {
53466                 var needCheckInitializer = node.initializer && node.parent.parent.kind !== 231;
53467                 var needCheckWidenedType = node.name.elements.length === 0;
53468                 if (needCheckInitializer || needCheckWidenedType) {
53469                     var widenedType = getWidenedTypeForVariableLikeDeclaration(node);
53470                     if (needCheckInitializer) {
53471                         var initializerType = checkExpressionCached(node.initializer);
53472                         if (strictNullChecks && needCheckWidenedType) {
53473                             checkNonNullNonVoidType(initializerType, node);
53474                         }
53475                         else {
53476                             checkTypeAssignableToAndOptionallyElaborate(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, node.initializer);
53477                         }
53478                     }
53479                     if (needCheckWidenedType) {
53480                         if (ts.isArrayBindingPattern(node.name)) {
53481                             checkIteratedTypeOrElementType(65, widenedType, undefinedType, node);
53482                         }
53483                         else if (strictNullChecks) {
53484                             checkNonNullNonVoidType(widenedType, node);
53485                         }
53486                     }
53487                 }
53488                 return;
53489             }
53490             var symbol = getSymbolOfNode(node);
53491             var type = convertAutoToAny(getTypeOfSymbol(symbol));
53492             if (node === symbol.valueDeclaration) {
53493                 var initializer = ts.getEffectiveInitializer(node);
53494                 if (initializer) {
53495                     var isJSObjectLiteralInitializer = ts.isInJSFile(node) &&
53496                         ts.isObjectLiteralExpression(initializer) &&
53497                         (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) &&
53498                         ts.hasEntries(symbol.exports);
53499                     if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 231) {
53500                         checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, undefined);
53501                     }
53502                 }
53503                 if (symbol.declarations.length > 1) {
53504                     if (ts.some(symbol.declarations, function (d) { return d !== node && ts.isVariableLike(d) && !areDeclarationFlagsIdentical(d, node); })) {
53505                         error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name));
53506                     }
53507                 }
53508             }
53509             else {
53510                 var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node));
53511                 if (type !== errorType && declarationType !== errorType &&
53512                     !isTypeIdenticalTo(type, declarationType) &&
53513                     !(symbol.flags & 67108864)) {
53514                     errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType);
53515                 }
53516                 if (node.initializer) {
53517                     checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, undefined);
53518                 }
53519                 if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) {
53520                     error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name));
53521                 }
53522             }
53523             if (node.kind !== 159 && node.kind !== 158) {
53524                 checkExportsOnMergedDeclarations(node);
53525                 if (node.kind === 242 || node.kind === 191) {
53526                     checkVarDeclaredNamesNotShadowed(node);
53527                 }
53528                 checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
53529                 checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
53530                 if (!compilerOptions.noEmit && languageVersion < 99 && needCollisionCheckForIdentifier(node, node.name, "WeakMap")) {
53531                     potentialWeakMapCollisions.push(node);
53532                 }
53533             }
53534         }
53535         function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) {
53536             var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration);
53537             var message = nextDeclaration.kind === 159 || nextDeclaration.kind === 158
53538                 ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2
53539                 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2;
53540             var declName = ts.declarationNameToString(nextDeclarationName);
53541             var err = error(nextDeclarationName, message, declName, typeToString(firstType), typeToString(nextType));
53542             if (firstDeclaration) {
53543                 ts.addRelatedInfo(err, ts.createDiagnosticForNode(firstDeclaration, ts.Diagnostics._0_was_also_declared_here, declName));
53544             }
53545         }
53546         function areDeclarationFlagsIdentical(left, right) {
53547             if ((left.kind === 156 && right.kind === 242) ||
53548                 (left.kind === 242 && right.kind === 156)) {
53549                 return true;
53550             }
53551             if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) {
53552                 return false;
53553             }
53554             var interestingFlags = 8 |
53555                 16 |
53556                 256 |
53557                 128 |
53558                 64 |
53559                 32;
53560             return ts.getSelectedModifierFlags(left, interestingFlags) === ts.getSelectedModifierFlags(right, interestingFlags);
53561         }
53562         function checkVariableDeclaration(node) {
53563             checkGrammarVariableDeclaration(node);
53564             return checkVariableLikeDeclaration(node);
53565         }
53566         function checkBindingElement(node) {
53567             checkGrammarBindingElement(node);
53568             return checkVariableLikeDeclaration(node);
53569         }
53570         function checkVariableStatement(node) {
53571             if (!checkGrammarDecoratorsAndModifiers(node) && !checkGrammarVariableDeclarationList(node.declarationList))
53572                 checkGrammarForDisallowedLetOrConstStatement(node);
53573             ts.forEach(node.declarationList.declarations, checkSourceElement);
53574         }
53575         function checkExpressionStatement(node) {
53576             checkGrammarStatementInAmbientContext(node);
53577             checkExpression(node.expression);
53578         }
53579         function checkIfStatement(node) {
53580             checkGrammarStatementInAmbientContext(node);
53581             var type = checkTruthinessExpression(node.expression);
53582             checkTestingKnownTruthyCallableType(node.expression, node.thenStatement, type);
53583             checkSourceElement(node.thenStatement);
53584             if (node.thenStatement.kind === 224) {
53585                 error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement);
53586             }
53587             checkSourceElement(node.elseStatement);
53588         }
53589         function checkTestingKnownTruthyCallableType(condExpr, body, type) {
53590             if (!strictNullChecks) {
53591                 return;
53592             }
53593             var testedNode = ts.isIdentifier(condExpr)
53594                 ? condExpr
53595                 : ts.isPropertyAccessExpression(condExpr)
53596                     ? condExpr.name
53597                     : undefined;
53598             if (!testedNode) {
53599                 return;
53600             }
53601             var possiblyFalsy = getFalsyFlags(type);
53602             if (possiblyFalsy) {
53603                 return;
53604             }
53605             var callSignatures = getSignaturesOfType(type, 0);
53606             if (callSignatures.length === 0) {
53607                 return;
53608             }
53609             var testedFunctionSymbol = getSymbolAtLocation(testedNode);
53610             if (!testedFunctionSymbol) {
53611                 return;
53612             }
53613             var functionIsUsedInBody = ts.forEachChild(body, function check(childNode) {
53614                 if (ts.isIdentifier(childNode)) {
53615                     var childSymbol = getSymbolAtLocation(childNode);
53616                     if (childSymbol && childSymbol === testedFunctionSymbol) {
53617                         if (ts.isIdentifier(condExpr)) {
53618                             return true;
53619                         }
53620                         var testedExpression = testedNode.parent;
53621                         var childExpression = childNode.parent;
53622                         while (testedExpression && childExpression) {
53623                             if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) ||
53624                                 testedExpression.kind === 104 && childExpression.kind === 104) {
53625                                 return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression);
53626                             }
53627                             if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) {
53628                                 if (getSymbolAtLocation(testedExpression.name) !== getSymbolAtLocation(childExpression.name)) {
53629                                     return false;
53630                                 }
53631                                 childExpression = childExpression.expression;
53632                                 testedExpression = testedExpression.expression;
53633                             }
53634                             else {
53635                                 return false;
53636                             }
53637                         }
53638                     }
53639                 }
53640                 return ts.forEachChild(childNode, check);
53641             });
53642             if (!functionIsUsedInBody) {
53643                 error(condExpr, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead);
53644             }
53645         }
53646         function checkDoStatement(node) {
53647             checkGrammarStatementInAmbientContext(node);
53648             checkSourceElement(node.statement);
53649             checkTruthinessExpression(node.expression);
53650         }
53651         function checkWhileStatement(node) {
53652             checkGrammarStatementInAmbientContext(node);
53653             checkTruthinessExpression(node.expression);
53654             checkSourceElement(node.statement);
53655         }
53656         function checkTruthinessOfType(type, node) {
53657             if (type.flags & 16384) {
53658                 error(node, ts.Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness);
53659             }
53660             return type;
53661         }
53662         function checkTruthinessExpression(node, checkMode) {
53663             return checkTruthinessOfType(checkExpression(node, checkMode), node);
53664         }
53665         function checkForStatement(node) {
53666             if (!checkGrammarStatementInAmbientContext(node)) {
53667                 if (node.initializer && node.initializer.kind === 243) {
53668                     checkGrammarVariableDeclarationList(node.initializer);
53669                 }
53670             }
53671             if (node.initializer) {
53672                 if (node.initializer.kind === 243) {
53673                     ts.forEach(node.initializer.declarations, checkVariableDeclaration);
53674                 }
53675                 else {
53676                     checkExpression(node.initializer);
53677                 }
53678             }
53679             if (node.condition)
53680                 checkTruthinessExpression(node.condition);
53681             if (node.incrementor)
53682                 checkExpression(node.incrementor);
53683             checkSourceElement(node.statement);
53684             if (node.locals) {
53685                 registerForUnusedIdentifiersCheck(node);
53686             }
53687         }
53688         function checkForOfStatement(node) {
53689             checkGrammarForInOrForOfStatement(node);
53690             if (node.awaitModifier) {
53691                 var functionFlags = ts.getFunctionFlags(ts.getContainingFunction(node));
53692                 if ((functionFlags & (4 | 2)) === 2 && languageVersion < 99) {
53693                     checkExternalEmitHelpers(node, 32768);
53694                 }
53695             }
53696             else if (compilerOptions.downlevelIteration && languageVersion < 2) {
53697                 checkExternalEmitHelpers(node, 256);
53698             }
53699             if (node.initializer.kind === 243) {
53700                 checkForInOrForOfVariableDeclaration(node);
53701             }
53702             else {
53703                 var varExpr = node.initializer;
53704                 var iteratedType = checkRightHandSideOfForOf(node);
53705                 if (varExpr.kind === 192 || varExpr.kind === 193) {
53706                     checkDestructuringAssignment(varExpr, iteratedType || errorType);
53707                 }
53708                 else {
53709                     var leftType = checkExpression(varExpr);
53710                     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);
53711                     if (iteratedType) {
53712                         checkTypeAssignableToAndOptionallyElaborate(iteratedType, leftType, varExpr, node.expression);
53713                     }
53714                 }
53715             }
53716             checkSourceElement(node.statement);
53717             if (node.locals) {
53718                 registerForUnusedIdentifiersCheck(node);
53719             }
53720         }
53721         function checkForInStatement(node) {
53722             checkGrammarForInOrForOfStatement(node);
53723             var rightType = getNonNullableTypeIfNeeded(checkExpression(node.expression));
53724             if (node.initializer.kind === 243) {
53725                 var variable = node.initializer.declarations[0];
53726                 if (variable && ts.isBindingPattern(variable.name)) {
53727                     error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern);
53728                 }
53729                 checkForInOrForOfVariableDeclaration(node);
53730             }
53731             else {
53732                 var varExpr = node.initializer;
53733                 var leftType = checkExpression(varExpr);
53734                 if (varExpr.kind === 192 || varExpr.kind === 193) {
53735                     error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern);
53736                 }
53737                 else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) {
53738                     error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any);
53739                 }
53740                 else {
53741                     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);
53742                 }
53743             }
53744             if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 | 58982400)) {
53745                 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));
53746             }
53747             checkSourceElement(node.statement);
53748             if (node.locals) {
53749                 registerForUnusedIdentifiersCheck(node);
53750             }
53751         }
53752         function checkForInOrForOfVariableDeclaration(iterationStatement) {
53753             var variableDeclarationList = iterationStatement.initializer;
53754             if (variableDeclarationList.declarations.length >= 1) {
53755                 var decl = variableDeclarationList.declarations[0];
53756                 checkVariableDeclaration(decl);
53757             }
53758         }
53759         function checkRightHandSideOfForOf(statement) {
53760             var use = statement.awaitModifier ? 15 : 13;
53761             return checkIteratedTypeOrElementType(use, checkNonNullExpression(statement.expression), undefinedType, statement.expression);
53762         }
53763         function checkIteratedTypeOrElementType(use, inputType, sentType, errorNode) {
53764             if (isTypeAny(inputType)) {
53765                 return inputType;
53766             }
53767             return getIteratedTypeOrElementType(use, inputType, sentType, errorNode, true) || anyType;
53768         }
53769         function getIteratedTypeOrElementType(use, inputType, sentType, errorNode, checkAssignability) {
53770             var allowAsyncIterables = (use & 2) !== 0;
53771             if (inputType === neverType) {
53772                 reportTypeNotIterableError(errorNode, inputType, allowAsyncIterables);
53773                 return undefined;
53774             }
53775             var uplevelIteration = languageVersion >= 2;
53776             var downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration;
53777             if (uplevelIteration || downlevelIteration || allowAsyncIterables) {
53778                 var iterationTypes = getIterationTypesOfIterable(inputType, use, uplevelIteration ? errorNode : undefined);
53779                 if (checkAssignability) {
53780                     if (iterationTypes) {
53781                         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 :
53782                             use & 32 ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 :
53783                                 use & 64 ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 :
53784                                     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 :
53785                                         undefined;
53786                         if (diagnostic) {
53787                             checkTypeAssignableTo(sentType, iterationTypes.nextType, errorNode, diagnostic);
53788                         }
53789                     }
53790                 }
53791                 if (iterationTypes || uplevelIteration) {
53792                     return iterationTypes && iterationTypes.yieldType;
53793                 }
53794             }
53795             var arrayType = inputType;
53796             var reportedError = false;
53797             var hasStringConstituent = false;
53798             if (use & 4) {
53799                 if (arrayType.flags & 1048576) {
53800                     var arrayTypes = inputType.types;
53801                     var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 132); });
53802                     if (filteredTypes !== arrayTypes) {
53803                         arrayType = getUnionType(filteredTypes, 2);
53804                     }
53805                 }
53806                 else if (arrayType.flags & 132) {
53807                     arrayType = neverType;
53808                 }
53809                 hasStringConstituent = arrayType !== inputType;
53810                 if (hasStringConstituent) {
53811                     if (languageVersion < 1) {
53812                         if (errorNode) {
53813                             error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher);
53814                             reportedError = true;
53815                         }
53816                     }
53817                     if (arrayType.flags & 131072) {
53818                         return stringType;
53819                     }
53820                 }
53821             }
53822             if (!isArrayLikeType(arrayType)) {
53823                 if (errorNode && !reportedError) {
53824                     var yieldType = getIterationTypeOfIterable(use, 0, inputType, undefined);
53825                     var _a = !(use & 4) || hasStringConstituent
53826                         ? downlevelIteration
53827                             ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true]
53828                             : yieldType
53829                                 ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]
53830                                 : [ts.Diagnostics.Type_0_is_not_an_array_type, true]
53831                         : downlevelIteration
53832                             ? [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]
53833                             : yieldType
53834                                 ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]
53835                                 : [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, true], defaultDiagnostic = _a[0], maybeMissingAwait = _a[1];
53836                     errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType));
53837                 }
53838                 return hasStringConstituent ? stringType : undefined;
53839             }
53840             var arrayElementType = getIndexTypeOfType(arrayType, 1);
53841             if (hasStringConstituent && arrayElementType) {
53842                 if (arrayElementType.flags & 132) {
53843                     return stringType;
53844                 }
53845                 return getUnionType([arrayElementType, stringType], 2);
53846             }
53847             return arrayElementType;
53848         }
53849         function getIterationTypeOfIterable(use, typeKind, inputType, errorNode) {
53850             if (isTypeAny(inputType)) {
53851                 return undefined;
53852             }
53853             var iterationTypes = getIterationTypesOfIterable(inputType, use, errorNode);
53854             return iterationTypes && iterationTypes[getIterationTypesKeyFromIterationTypeKind(typeKind)];
53855         }
53856         function createIterationTypes(yieldType, returnType, nextType) {
53857             if (yieldType === void 0) { yieldType = neverType; }
53858             if (returnType === void 0) { returnType = neverType; }
53859             if (nextType === void 0) { nextType = unknownType; }
53860             if (yieldType.flags & 67359327 &&
53861                 returnType.flags & (1 | 131072 | 2 | 16384 | 32768) &&
53862                 nextType.flags & (1 | 131072 | 2 | 16384 | 32768)) {
53863                 var id = getTypeListId([yieldType, returnType, nextType]);
53864                 var iterationTypes = iterationTypesCache.get(id);
53865                 if (!iterationTypes) {
53866                     iterationTypes = { yieldType: yieldType, returnType: returnType, nextType: nextType };
53867                     iterationTypesCache.set(id, iterationTypes);
53868                 }
53869                 return iterationTypes;
53870             }
53871             return { yieldType: yieldType, returnType: returnType, nextType: nextType };
53872         }
53873         function combineIterationTypes(array) {
53874             var yieldTypes;
53875             var returnTypes;
53876             var nextTypes;
53877             for (var _i = 0, array_10 = array; _i < array_10.length; _i++) {
53878                 var iterationTypes = array_10[_i];
53879                 if (iterationTypes === undefined || iterationTypes === noIterationTypes) {
53880                     continue;
53881                 }
53882                 if (iterationTypes === anyIterationTypes) {
53883                     return anyIterationTypes;
53884                 }
53885                 yieldTypes = ts.append(yieldTypes, iterationTypes.yieldType);
53886                 returnTypes = ts.append(returnTypes, iterationTypes.returnType);
53887                 nextTypes = ts.append(nextTypes, iterationTypes.nextType);
53888             }
53889             if (yieldTypes || returnTypes || nextTypes) {
53890                 return createIterationTypes(yieldTypes && getUnionType(yieldTypes), returnTypes && getUnionType(returnTypes), nextTypes && getIntersectionType(nextTypes));
53891             }
53892             return noIterationTypes;
53893         }
53894         function getCachedIterationTypes(type, cacheKey) {
53895             return type[cacheKey];
53896         }
53897         function setCachedIterationTypes(type, cacheKey, cachedTypes) {
53898             return type[cacheKey] = cachedTypes;
53899         }
53900         function getIterationTypesOfIterable(type, use, errorNode) {
53901             if (isTypeAny(type)) {
53902                 return anyIterationTypes;
53903             }
53904             if (!(type.flags & 1048576)) {
53905                 var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode);
53906                 if (iterationTypes_1 === noIterationTypes) {
53907                     if (errorNode) {
53908                         reportTypeNotIterableError(errorNode, type, !!(use & 2));
53909                     }
53910                     return undefined;
53911                 }
53912                 return iterationTypes_1;
53913             }
53914             var cacheKey = use & 2 ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable";
53915             var cachedTypes = getCachedIterationTypes(type, cacheKey);
53916             if (cachedTypes)
53917                 return cachedTypes === noIterationTypes ? undefined : cachedTypes;
53918             var allIterationTypes;
53919             for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
53920                 var constituent = _a[_i];
53921                 var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode);
53922                 if (iterationTypes_2 === noIterationTypes) {
53923                     if (errorNode) {
53924                         reportTypeNotIterableError(errorNode, type, !!(use & 2));
53925                         errorNode = undefined;
53926                     }
53927                 }
53928                 else {
53929                     allIterationTypes = ts.append(allIterationTypes, iterationTypes_2);
53930                 }
53931             }
53932             var iterationTypes = allIterationTypes ? combineIterationTypes(allIterationTypes) : noIterationTypes;
53933             setCachedIterationTypes(type, cacheKey, iterationTypes);
53934             return iterationTypes === noIterationTypes ? undefined : iterationTypes;
53935         }
53936         function getAsyncFromSyncIterationTypes(iterationTypes, errorNode) {
53937             if (iterationTypes === noIterationTypes)
53938                 return noIterationTypes;
53939             if (iterationTypes === anyIterationTypes)
53940                 return anyIterationTypes;
53941             var yieldType = iterationTypes.yieldType, returnType = iterationTypes.returnType, nextType = iterationTypes.nextType;
53942             return createIterationTypes(getAwaitedType(yieldType, errorNode) || anyType, getAwaitedType(returnType, errorNode) || anyType, nextType);
53943         }
53944         function getIterationTypesOfIterableWorker(type, use, errorNode) {
53945             if (isTypeAny(type)) {
53946                 return anyIterationTypes;
53947             }
53948             if (use & 2) {
53949                 var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) ||
53950                     getIterationTypesOfIterableFast(type, asyncIterationTypesResolver);
53951                 if (iterationTypes) {
53952                     return iterationTypes;
53953                 }
53954             }
53955             if (use & 1) {
53956                 var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) ||
53957                     getIterationTypesOfIterableFast(type, syncIterationTypesResolver);
53958                 if (iterationTypes) {
53959                     if (use & 2) {
53960                         if (iterationTypes !== noIterationTypes) {
53961                             return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode));
53962                         }
53963                     }
53964                     else {
53965                         return iterationTypes;
53966                     }
53967                 }
53968             }
53969             if (use & 2) {
53970                 var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode);
53971                 if (iterationTypes !== noIterationTypes) {
53972                     return iterationTypes;
53973                 }
53974             }
53975             if (use & 1) {
53976                 var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode);
53977                 if (iterationTypes !== noIterationTypes) {
53978                     if (use & 2) {
53979                         return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes
53980                             ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode)
53981                             : noIterationTypes);
53982                     }
53983                     else {
53984                         return iterationTypes;
53985                     }
53986                 }
53987             }
53988             return noIterationTypes;
53989         }
53990         function getIterationTypesOfIterableCached(type, resolver) {
53991             return getCachedIterationTypes(type, resolver.iterableCacheKey);
53992         }
53993         function getIterationTypesOfGlobalIterableType(globalType, resolver) {
53994             var globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) ||
53995                 getIterationTypesOfIterableSlow(globalType, resolver, undefined);
53996             return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes;
53997         }
53998         function getIterationTypesOfIterableFast(type, resolver) {
53999             var globalType;
54000             if (isReferenceToType(type, globalType = resolver.getGlobalIterableType(false)) ||
54001                 isReferenceToType(type, globalType = resolver.getGlobalIterableIteratorType(false))) {
54002                 var yieldType = getTypeArguments(type)[0];
54003                 var _a = getIterationTypesOfGlobalIterableType(globalType, resolver), returnType = _a.returnType, nextType = _a.nextType;
54004                 return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(yieldType, returnType, nextType));
54005             }
54006             if (isReferenceToType(type, resolver.getGlobalGeneratorType(false))) {
54007                 var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2];
54008                 return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(yieldType, returnType, nextType));
54009             }
54010         }
54011         function getIterationTypesOfIterableSlow(type, resolver, errorNode) {
54012             var _a;
54013             var method = getPropertyOfType(type, ts.getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName));
54014             var methodType = method && !(method.flags & 16777216) ? getTypeOfSymbol(method) : undefined;
54015             if (isTypeAny(methodType)) {
54016                 return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
54017             }
54018             var signatures = methodType ? getSignaturesOfType(methodType, 0) : undefined;
54019             if (!ts.some(signatures)) {
54020                 return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
54021             }
54022             var iteratorType = getUnionType(ts.map(signatures, getReturnTypeOfSignature), 2);
54023             var iterationTypes = (_a = getIterationTypesOfIterator(iteratorType, resolver, errorNode)) !== null && _a !== void 0 ? _a : noIterationTypes;
54024             return setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
54025         }
54026         function reportTypeNotIterableError(errorNode, type, allowAsyncIterables) {
54027             var message = allowAsyncIterables
54028                 ? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
54029                 : ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
54030             errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
54031         }
54032         function getIterationTypesOfIterator(type, resolver, errorNode) {
54033             if (isTypeAny(type)) {
54034                 return anyIterationTypes;
54035             }
54036             var iterationTypes = getIterationTypesOfIteratorCached(type, resolver) ||
54037                 getIterationTypesOfIteratorFast(type, resolver) ||
54038                 getIterationTypesOfIteratorSlow(type, resolver, errorNode);
54039             return iterationTypes === noIterationTypes ? undefined : iterationTypes;
54040         }
54041         function getIterationTypesOfIteratorCached(type, resolver) {
54042             return getCachedIterationTypes(type, resolver.iteratorCacheKey);
54043         }
54044         function getIterationTypesOfIteratorFast(type, resolver) {
54045             var globalType = resolver.getGlobalIterableIteratorType(false);
54046             if (isReferenceToType(type, globalType)) {
54047                 var yieldType = getTypeArguments(type)[0];
54048                 var globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) ||
54049                     getIterationTypesOfIteratorSlow(globalType, resolver, undefined);
54050                 var _a = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes, returnType = _a.returnType, nextType = _a.nextType;
54051                 return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
54052             }
54053             if (isReferenceToType(type, resolver.getGlobalIteratorType(false)) ||
54054                 isReferenceToType(type, resolver.getGlobalGeneratorType(false))) {
54055                 var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2];
54056                 return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
54057             }
54058         }
54059         function isIteratorResult(type, kind) {
54060             var doneType = getTypeOfPropertyOfType(type, "done") || falseType;
54061             return isTypeAssignableTo(kind === 0 ? falseType : trueType, doneType);
54062         }
54063         function isYieldIteratorResult(type) {
54064             return isIteratorResult(type, 0);
54065         }
54066         function isReturnIteratorResult(type) {
54067             return isIteratorResult(type, 1);
54068         }
54069         function getIterationTypesOfIteratorResult(type) {
54070             if (isTypeAny(type)) {
54071                 return anyIterationTypes;
54072             }
54073             var cachedTypes = getCachedIterationTypes(type, "iterationTypesOfIteratorResult");
54074             if (cachedTypes) {
54075                 return cachedTypes;
54076             }
54077             if (isReferenceToType(type, getGlobalIteratorYieldResultType(false))) {
54078                 var yieldType_1 = getTypeArguments(type)[0];
54079                 return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", createIterationTypes(yieldType_1, undefined, undefined));
54080             }
54081             if (isReferenceToType(type, getGlobalIteratorReturnResultType(false))) {
54082                 var returnType_1 = getTypeArguments(type)[0];
54083                 return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", createIterationTypes(undefined, returnType_1, undefined));
54084             }
54085             var yieldIteratorResult = filterType(type, isYieldIteratorResult);
54086             var yieldType = yieldIteratorResult !== neverType ? getTypeOfPropertyOfType(yieldIteratorResult, "value") : undefined;
54087             var returnIteratorResult = filterType(type, isReturnIteratorResult);
54088             var returnType = returnIteratorResult !== neverType ? getTypeOfPropertyOfType(returnIteratorResult, "value") : undefined;
54089             if (!yieldType && !returnType) {
54090                 return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", noIterationTypes);
54091             }
54092             return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", createIterationTypes(yieldType, returnType || voidType, undefined));
54093         }
54094         function getIterationTypesOfMethod(type, resolver, methodName, errorNode) {
54095             var method = getPropertyOfType(type, methodName);
54096             if (!method && methodName !== "next") {
54097                 return undefined;
54098             }
54099             var methodType = method && !(methodName === "next" && (method.flags & 16777216))
54100                 ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152)
54101                 : undefined;
54102             if (isTypeAny(methodType)) {
54103                 return methodName === "next" ? anyIterationTypes : anyIterationTypesExceptNext;
54104             }
54105             var methodSignatures = methodType ? getSignaturesOfType(methodType, 0) : ts.emptyArray;
54106             if (methodSignatures.length === 0) {
54107                 if (errorNode) {
54108                     var diagnostic = methodName === "next"
54109                         ? resolver.mustHaveANextMethodDiagnostic
54110                         : resolver.mustBeAMethodDiagnostic;
54111                     error(errorNode, diagnostic, methodName);
54112                 }
54113                 return methodName === "next" ? anyIterationTypes : undefined;
54114             }
54115             var methodParameterTypes;
54116             var methodReturnTypes;
54117             for (var _i = 0, methodSignatures_1 = methodSignatures; _i < methodSignatures_1.length; _i++) {
54118                 var signature = methodSignatures_1[_i];
54119                 if (methodName !== "throw" && ts.some(signature.parameters)) {
54120                     methodParameterTypes = ts.append(methodParameterTypes, getTypeAtPosition(signature, 0));
54121                 }
54122                 methodReturnTypes = ts.append(methodReturnTypes, getReturnTypeOfSignature(signature));
54123             }
54124             var returnTypes;
54125             var nextType;
54126             if (methodName !== "throw") {
54127                 var methodParameterType = methodParameterTypes ? getUnionType(methodParameterTypes) : unknownType;
54128                 if (methodName === "next") {
54129                     nextType = methodParameterType;
54130                 }
54131                 else if (methodName === "return") {
54132                     var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType;
54133                     returnTypes = ts.append(returnTypes, resolvedMethodParameterType);
54134                 }
54135             }
54136             var yieldType;
54137             var methodReturnType = methodReturnTypes ? getUnionType(methodReturnTypes, 2) : neverType;
54138             var resolvedMethodReturnType = resolver.resolveIterationType(methodReturnType, errorNode) || anyType;
54139             var iterationTypes = getIterationTypesOfIteratorResult(resolvedMethodReturnType);
54140             if (iterationTypes === noIterationTypes) {
54141                 if (errorNode) {
54142                     error(errorNode, resolver.mustHaveAValueDiagnostic, methodName);
54143                 }
54144                 yieldType = anyType;
54145                 returnTypes = ts.append(returnTypes, anyType);
54146             }
54147             else {
54148                 yieldType = iterationTypes.yieldType;
54149                 returnTypes = ts.append(returnTypes, iterationTypes.returnType);
54150             }
54151             return createIterationTypes(yieldType, getUnionType(returnTypes), nextType);
54152         }
54153         function getIterationTypesOfIteratorSlow(type, resolver, errorNode) {
54154             var iterationTypes = combineIterationTypes([
54155                 getIterationTypesOfMethod(type, resolver, "next", errorNode),
54156                 getIterationTypesOfMethod(type, resolver, "return", errorNode),
54157                 getIterationTypesOfMethod(type, resolver, "throw", errorNode),
54158             ]);
54159             return setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes);
54160         }
54161         function getIterationTypeOfGeneratorFunctionReturnType(kind, returnType, isAsyncGenerator) {
54162             if (isTypeAny(returnType)) {
54163                 return undefined;
54164             }
54165             var iterationTypes = getIterationTypesOfGeneratorFunctionReturnType(returnType, isAsyncGenerator);
54166             return iterationTypes && iterationTypes[getIterationTypesKeyFromIterationTypeKind(kind)];
54167         }
54168         function getIterationTypesOfGeneratorFunctionReturnType(type, isAsyncGenerator) {
54169             if (isTypeAny(type)) {
54170                 return anyIterationTypes;
54171             }
54172             var use = isAsyncGenerator ? 2 : 1;
54173             var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
54174             return getIterationTypesOfIterable(type, use, undefined) ||
54175                 getIterationTypesOfIterator(type, resolver, undefined);
54176         }
54177         function checkBreakOrContinueStatement(node) {
54178             if (!checkGrammarStatementInAmbientContext(node))
54179                 checkGrammarBreakOrContinueStatement(node);
54180         }
54181         function unwrapReturnType(returnType, functionFlags) {
54182             var _a, _b;
54183             var isGenerator = !!(functionFlags & 1);
54184             var isAsync = !!(functionFlags & 2);
54185             return isGenerator ? (_a = getIterationTypeOfGeneratorFunctionReturnType(1, returnType, isAsync)) !== null && _a !== void 0 ? _a : errorType :
54186                 isAsync ? (_b = getAwaitedType(returnType)) !== null && _b !== void 0 ? _b : errorType :
54187                     returnType;
54188         }
54189         function isUnwrappedReturnTypeVoidOrAny(func, returnType) {
54190             var unwrappedReturnType = unwrapReturnType(returnType, ts.getFunctionFlags(func));
54191             return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 | 3);
54192         }
54193         function checkReturnStatement(node) {
54194             var _a;
54195             if (checkGrammarStatementInAmbientContext(node)) {
54196                 return;
54197             }
54198             var func = ts.getContainingFunction(node);
54199             if (!func) {
54200                 grammarErrorOnFirstToken(node, ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body);
54201                 return;
54202             }
54203             var signature = getSignatureFromDeclaration(func);
54204             var returnType = getReturnTypeOfSignature(signature);
54205             var functionFlags = ts.getFunctionFlags(func);
54206             if (strictNullChecks || node.expression || returnType.flags & 131072) {
54207                 var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
54208                 if (func.kind === 164) {
54209                     if (node.expression) {
54210                         error(node, ts.Diagnostics.Setters_cannot_return_a_value);
54211                     }
54212                 }
54213                 else if (func.kind === 162) {
54214                     if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) {
54215                         error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
54216                     }
54217                 }
54218                 else if (getReturnTypeFromAnnotation(func)) {
54219                     var unwrappedReturnType = (_a = unwrapReturnType(returnType, functionFlags)) !== null && _a !== void 0 ? _a : returnType;
54220                     var unwrappedExprType = functionFlags & 2
54221                         ? 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)
54222                         : exprType;
54223                     if (unwrappedReturnType) {
54224                         checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, node, node.expression);
54225                     }
54226                 }
54227             }
54228             else if (func.kind !== 162 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) {
54229                 error(node, ts.Diagnostics.Not_all_code_paths_return_a_value);
54230             }
54231         }
54232         function checkWithStatement(node) {
54233             if (!checkGrammarStatementInAmbientContext(node)) {
54234                 if (node.flags & 32768) {
54235                     grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block);
54236                 }
54237             }
54238             checkExpression(node.expression);
54239             var sourceFile = ts.getSourceFileOfNode(node);
54240             if (!hasParseDiagnostics(sourceFile)) {
54241                 var start = ts.getSpanOfTokenAtPosition(sourceFile, node.pos).start;
54242                 var end = node.statement.pos;
54243                 grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any);
54244             }
54245         }
54246         function checkSwitchStatement(node) {
54247             checkGrammarStatementInAmbientContext(node);
54248             var firstDefaultClause;
54249             var hasDuplicateDefaultClause = false;
54250             var expressionType = checkExpression(node.expression);
54251             var expressionIsLiteral = isLiteralType(expressionType);
54252             ts.forEach(node.caseBlock.clauses, function (clause) {
54253                 if (clause.kind === 278 && !hasDuplicateDefaultClause) {
54254                     if (firstDefaultClause === undefined) {
54255                         firstDefaultClause = clause;
54256                     }
54257                     else {
54258                         grammarErrorOnNode(clause, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement);
54259                         hasDuplicateDefaultClause = true;
54260                     }
54261                 }
54262                 if (produceDiagnostics && clause.kind === 277) {
54263                     var caseType = checkExpression(clause.expression);
54264                     var caseIsLiteral = isLiteralType(caseType);
54265                     var comparedExpressionType = expressionType;
54266                     if (!caseIsLiteral || !expressionIsLiteral) {
54267                         caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
54268                         comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
54269                     }
54270                     if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
54271                         checkTypeComparableTo(caseType, comparedExpressionType, clause.expression, undefined);
54272                     }
54273                 }
54274                 ts.forEach(clause.statements, checkSourceElement);
54275                 if (compilerOptions.noFallthroughCasesInSwitch && clause.fallthroughFlowNode && isReachableFlowNode(clause.fallthroughFlowNode)) {
54276                     error(clause, ts.Diagnostics.Fallthrough_case_in_switch);
54277                 }
54278             });
54279             if (node.caseBlock.locals) {
54280                 registerForUnusedIdentifiersCheck(node.caseBlock);
54281             }
54282         }
54283         function checkLabeledStatement(node) {
54284             if (!checkGrammarStatementInAmbientContext(node)) {
54285                 ts.findAncestor(node.parent, function (current) {
54286                     if (ts.isFunctionLike(current)) {
54287                         return "quit";
54288                     }
54289                     if (current.kind === 238 && current.label.escapedText === node.label.escapedText) {
54290                         grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label));
54291                         return true;
54292                     }
54293                     return false;
54294                 });
54295             }
54296             checkSourceElement(node.statement);
54297         }
54298         function checkThrowStatement(node) {
54299             if (!checkGrammarStatementInAmbientContext(node)) {
54300                 if (node.expression === undefined) {
54301                     grammarErrorAfterFirstToken(node, ts.Diagnostics.Line_break_not_permitted_here);
54302                 }
54303             }
54304             if (node.expression) {
54305                 checkExpression(node.expression);
54306             }
54307         }
54308         function checkTryStatement(node) {
54309             checkGrammarStatementInAmbientContext(node);
54310             checkBlock(node.tryBlock);
54311             var catchClause = node.catchClause;
54312             if (catchClause) {
54313                 if (catchClause.variableDeclaration) {
54314                     if (catchClause.variableDeclaration.type) {
54315                         grammarErrorOnFirstToken(catchClause.variableDeclaration.type, ts.Diagnostics.Catch_clause_variable_cannot_have_a_type_annotation);
54316                     }
54317                     else if (catchClause.variableDeclaration.initializer) {
54318                         grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer);
54319                     }
54320                     else {
54321                         var blockLocals_1 = catchClause.block.locals;
54322                         if (blockLocals_1) {
54323                             ts.forEachKey(catchClause.locals, function (caughtName) {
54324                                 var blockLocal = blockLocals_1.get(caughtName);
54325                                 if (blockLocal && (blockLocal.flags & 2) !== 0) {
54326                                     grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName);
54327                                 }
54328                             });
54329                         }
54330                     }
54331                 }
54332                 checkBlock(catchClause.block);
54333             }
54334             if (node.finallyBlock) {
54335                 checkBlock(node.finallyBlock);
54336             }
54337         }
54338         function checkIndexConstraints(type) {
54339             var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1);
54340             var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0);
54341             var stringIndexType = getIndexTypeOfType(type, 0);
54342             var numberIndexType = getIndexTypeOfType(type, 1);
54343             if (stringIndexType || numberIndexType) {
54344                 ts.forEach(getPropertiesOfObjectType(type), function (prop) {
54345                     var propType = getTypeOfSymbol(prop);
54346                     checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0);
54347                     checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1);
54348                 });
54349                 var classDeclaration = type.symbol.valueDeclaration;
54350                 if (ts.getObjectFlags(type) & 1 && ts.isClassLike(classDeclaration)) {
54351                     for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) {
54352                         var member = _a[_i];
54353                         if (!ts.hasModifier(member, 32) && hasNonBindableDynamicName(member)) {
54354                             var symbol = getSymbolOfNode(member);
54355                             var propType = getTypeOfSymbol(symbol);
54356                             checkIndexConstraintForProperty(symbol, propType, type, declaredStringIndexer, stringIndexType, 0);
54357                             checkIndexConstraintForProperty(symbol, propType, type, declaredNumberIndexer, numberIndexType, 1);
54358                         }
54359                     }
54360                 }
54361             }
54362             var errorNode;
54363             if (stringIndexType && numberIndexType) {
54364                 errorNode = declaredNumberIndexer || declaredStringIndexer;
54365                 if (!errorNode && (ts.getObjectFlags(type) & 2)) {
54366                     var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0) && getIndexTypeOfType(base, 1); });
54367                     errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0];
54368                 }
54369             }
54370             if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) {
54371                 error(errorNode, ts.Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, typeToString(numberIndexType), typeToString(stringIndexType));
54372             }
54373             function checkIndexConstraintForProperty(prop, propertyType, containingType, indexDeclaration, indexType, indexKind) {
54374                 if (!indexType || ts.isKnownSymbol(prop)) {
54375                     return;
54376                 }
54377                 var propDeclaration = prop.valueDeclaration;
54378                 var name = propDeclaration && ts.getNameOfDeclaration(propDeclaration);
54379                 if (name && ts.isPrivateIdentifier(name)) {
54380                     return;
54381                 }
54382                 if (indexKind === 1 && !(name ? isNumericName(name) : isNumericLiteralName(prop.escapedName))) {
54383                     return;
54384                 }
54385                 var errorNode;
54386                 if (propDeclaration && name &&
54387                     (propDeclaration.kind === 209 ||
54388                         name.kind === 154 ||
54389                         prop.parent === containingType.symbol)) {
54390                     errorNode = propDeclaration;
54391                 }
54392                 else if (indexDeclaration) {
54393                     errorNode = indexDeclaration;
54394                 }
54395                 else if (ts.getObjectFlags(containingType) & 2) {
54396                     var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.escapedName) && getIndexTypeOfType(base, indexKind); });
54397                     errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0];
54398                 }
54399                 if (errorNode && !isTypeAssignableTo(propertyType, indexType)) {
54400                     var errorMessage = indexKind === 0
54401                         ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2
54402                         : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2;
54403                     error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType));
54404                 }
54405             }
54406         }
54407         function checkTypeNameIsReserved(name, message) {
54408             switch (name.escapedText) {
54409                 case "any":
54410                 case "unknown":
54411                 case "number":
54412                 case "bigint":
54413                 case "boolean":
54414                 case "string":
54415                 case "symbol":
54416                 case "void":
54417                 case "object":
54418                     error(name, message, name.escapedText);
54419             }
54420         }
54421         function checkClassNameCollisionWithObject(name) {
54422             if (languageVersion === 1 && name.escapedText === "Object"
54423                 && moduleKind < ts.ModuleKind.ES2015) {
54424                 error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]);
54425             }
54426         }
54427         function checkTypeParameters(typeParameterDeclarations) {
54428             if (typeParameterDeclarations) {
54429                 var seenDefault = false;
54430                 for (var i = 0; i < typeParameterDeclarations.length; i++) {
54431                     var node = typeParameterDeclarations[i];
54432                     checkTypeParameter(node);
54433                     if (produceDiagnostics) {
54434                         if (node.default) {
54435                             seenDefault = true;
54436                             checkTypeParametersNotReferenced(node.default, typeParameterDeclarations, i);
54437                         }
54438                         else if (seenDefault) {
54439                             error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters);
54440                         }
54441                         for (var j = 0; j < i; j++) {
54442                             if (typeParameterDeclarations[j].symbol === node.symbol) {
54443                                 error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name));
54444                             }
54445                         }
54446                     }
54447                 }
54448             }
54449         }
54450         function checkTypeParametersNotReferenced(root, typeParameters, index) {
54451             visit(root);
54452             function visit(node) {
54453                 if (node.kind === 169) {
54454                     var type = getTypeFromTypeReference(node);
54455                     if (type.flags & 262144) {
54456                         for (var i = index; i < typeParameters.length; i++) {
54457                             if (type.symbol === getSymbolOfNode(typeParameters[i])) {
54458                                 error(node, ts.Diagnostics.Type_parameter_defaults_can_only_reference_previously_declared_type_parameters);
54459                             }
54460                         }
54461                     }
54462                 }
54463                 ts.forEachChild(node, visit);
54464             }
54465         }
54466         function checkTypeParameterListsIdentical(symbol) {
54467             if (symbol.declarations.length === 1) {
54468                 return;
54469             }
54470             var links = getSymbolLinks(symbol);
54471             if (!links.typeParametersChecked) {
54472                 links.typeParametersChecked = true;
54473                 var declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol);
54474                 if (declarations.length <= 1) {
54475                     return;
54476                 }
54477                 var type = getDeclaredTypeOfSymbol(symbol);
54478                 if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) {
54479                     var name = symbolToString(symbol);
54480                     for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
54481                         var declaration = declarations_6[_i];
54482                         error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name);
54483                     }
54484                 }
54485             }
54486         }
54487         function areTypeParametersIdentical(declarations, targetParameters) {
54488             var maxTypeArgumentCount = ts.length(targetParameters);
54489             var minTypeArgumentCount = getMinTypeArgumentCount(targetParameters);
54490             for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
54491                 var declaration = declarations_7[_i];
54492                 var sourceParameters = ts.getEffectiveTypeParameterDeclarations(declaration);
54493                 var numTypeParameters = sourceParameters.length;
54494                 if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) {
54495                     return false;
54496                 }
54497                 for (var i = 0; i < numTypeParameters; i++) {
54498                     var source = sourceParameters[i];
54499                     var target = targetParameters[i];
54500                     if (source.name.escapedText !== target.symbol.escapedName) {
54501                         return false;
54502                     }
54503                     var constraint = ts.getEffectiveConstraintOfTypeParameter(source);
54504                     var sourceConstraint = constraint && getTypeFromTypeNode(constraint);
54505                     var targetConstraint = getConstraintOfTypeParameter(target);
54506                     if (sourceConstraint && targetConstraint && !isTypeIdenticalTo(sourceConstraint, targetConstraint)) {
54507                         return false;
54508                     }
54509                     var sourceDefault = source.default && getTypeFromTypeNode(source.default);
54510                     var targetDefault = getDefaultFromTypeParameter(target);
54511                     if (sourceDefault && targetDefault && !isTypeIdenticalTo(sourceDefault, targetDefault)) {
54512                         return false;
54513                     }
54514                 }
54515             }
54516             return true;
54517         }
54518         function checkClassExpression(node) {
54519             checkClassLikeDeclaration(node);
54520             checkNodeDeferred(node);
54521             return getTypeOfSymbol(getSymbolOfNode(node));
54522         }
54523         function checkClassExpressionDeferred(node) {
54524             ts.forEach(node.members, checkSourceElement);
54525             registerForUnusedIdentifiersCheck(node);
54526         }
54527         function checkClassDeclaration(node) {
54528             if (!node.name && !ts.hasModifier(node, 512)) {
54529                 grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name);
54530             }
54531             checkClassLikeDeclaration(node);
54532             ts.forEach(node.members, checkSourceElement);
54533             registerForUnusedIdentifiersCheck(node);
54534         }
54535         function checkClassLikeDeclaration(node) {
54536             checkGrammarClassLikeDeclaration(node);
54537             checkDecorators(node);
54538             if (node.name) {
54539                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0);
54540                 checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
54541                 checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
54542                 if (!(node.flags & 8388608)) {
54543                     checkClassNameCollisionWithObject(node.name);
54544                 }
54545             }
54546             checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node));
54547             checkExportsOnMergedDeclarations(node);
54548             var symbol = getSymbolOfNode(node);
54549             var type = getDeclaredTypeOfSymbol(symbol);
54550             var typeWithThis = getTypeWithThisArgument(type);
54551             var staticType = getTypeOfSymbol(symbol);
54552             checkTypeParameterListsIdentical(symbol);
54553             checkClassForDuplicateDeclarations(node);
54554             if (!(node.flags & 8388608)) {
54555                 checkClassForStaticPropertyNameConflicts(node);
54556             }
54557             var baseTypeNode = ts.getEffectiveBaseTypeNode(node);
54558             if (baseTypeNode) {
54559                 ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
54560                 if (languageVersion < 2) {
54561                     checkExternalEmitHelpers(baseTypeNode.parent, 1);
54562                 }
54563                 var extendsNode = ts.getClassExtendsHeritageElement(node);
54564                 if (extendsNode && extendsNode !== baseTypeNode) {
54565                     checkExpression(extendsNode.expression);
54566                 }
54567                 var baseTypes = getBaseTypes(type);
54568                 if (baseTypes.length && produceDiagnostics) {
54569                     var baseType_1 = baseTypes[0];
54570                     var baseConstructorType = getBaseConstructorTypeOfClass(type);
54571                     var staticBaseType = getApparentType(baseConstructorType);
54572                     checkBaseTypeAccessibility(staticBaseType, baseTypeNode);
54573                     checkSourceElement(baseTypeNode.expression);
54574                     if (ts.some(baseTypeNode.typeArguments)) {
54575                         ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
54576                         for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) {
54577                             var constructor = _a[_i];
54578                             if (!checkTypeArgumentConstraints(baseTypeNode, constructor.typeParameters)) {
54579                                 break;
54580                             }
54581                         }
54582                     }
54583                     var baseWithThis = getTypeWithThisArgument(baseType_1, type.thisType);
54584                     if (!checkTypeAssignableTo(typeWithThis, baseWithThis, undefined)) {
54585                         issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1);
54586                     }
54587                     else {
54588                         checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
54589                     }
54590                     if (baseConstructorType.flags & 8650752 && !isMixinConstructorType(staticType)) {
54591                         error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any);
54592                     }
54593                     if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 8650752)) {
54594                         var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode);
54595                         if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType_1); })) {
54596                             error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type);
54597                         }
54598                     }
54599                     checkKindsOfPropertyMemberOverrides(type, baseType_1);
54600                 }
54601             }
54602             var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node);
54603             if (implementedTypeNodes) {
54604                 for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) {
54605                     var typeRefNode = implementedTypeNodes_1[_b];
54606                     if (!ts.isEntityNameExpression(typeRefNode.expression)) {
54607                         error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments);
54608                     }
54609                     checkTypeReferenceNode(typeRefNode);
54610                     if (produceDiagnostics) {
54611                         var t = getReducedType(getTypeFromTypeNode(typeRefNode));
54612                         if (t !== errorType) {
54613                             if (isValidBaseType(t)) {
54614                                 var genericDiag = t.symbol && t.symbol.flags & 32 ?
54615                                     ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
54616                                     ts.Diagnostics.Class_0_incorrectly_implements_interface_1;
54617                                 var baseWithThis = getTypeWithThisArgument(t, type.thisType);
54618                                 if (!checkTypeAssignableTo(typeWithThis, baseWithThis, undefined)) {
54619                                     issueMemberSpecificError(node, typeWithThis, baseWithThis, genericDiag);
54620                                 }
54621                             }
54622                             else {
54623                                 error(typeRefNode, ts.Diagnostics.A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members);
54624                             }
54625                         }
54626                     }
54627                 }
54628             }
54629             if (produceDiagnostics) {
54630                 checkIndexConstraints(type);
54631                 checkTypeForDuplicateIndexSignatures(node);
54632                 checkPropertyInitialization(node);
54633             }
54634         }
54635         function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
54636             var issuedMemberError = false;
54637             var _loop_19 = function (member) {
54638                 if (ts.hasStaticModifier(member)) {
54639                     return "continue";
54640                 }
54641                 var declaredProp = member.name && getSymbolAtLocation(member.name) || getSymbolAtLocation(member);
54642                 if (declaredProp) {
54643                     var prop = getPropertyOfType(typeWithThis, declaredProp.escapedName);
54644                     var baseProp = getPropertyOfType(baseWithThis, declaredProp.escapedName);
54645                     if (prop && baseProp) {
54646                         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)); };
54647                         if (!checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(baseProp), member.name || member, undefined, rootChain)) {
54648                             issuedMemberError = true;
54649                         }
54650                     }
54651                 }
54652             };
54653             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
54654                 var member = _a[_i];
54655                 _loop_19(member);
54656             }
54657             if (!issuedMemberError) {
54658                 checkTypeAssignableTo(typeWithThis, baseWithThis, node.name || node, broadDiag);
54659             }
54660         }
54661         function checkBaseTypeAccessibility(type, node) {
54662             var signatures = getSignaturesOfType(type, 1);
54663             if (signatures.length) {
54664                 var declaration = signatures[0].declaration;
54665                 if (declaration && ts.hasModifier(declaration, 8)) {
54666                     var typeClassDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol);
54667                     if (!isNodeWithinClass(node, typeClassDeclaration)) {
54668                         error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol));
54669                     }
54670                 }
54671             }
54672         }
54673         function getTargetSymbol(s) {
54674             return ts.getCheckFlags(s) & 1 ? s.target : s;
54675         }
54676         function getClassOrInterfaceDeclarationsOfSymbol(symbol) {
54677             return ts.filter(symbol.declarations, function (d) {
54678                 return d.kind === 245 || d.kind === 246;
54679             });
54680         }
54681         function checkKindsOfPropertyMemberOverrides(type, baseType) {
54682             var baseProperties = getPropertiesOfType(baseType);
54683             basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
54684                 var baseProperty = baseProperties_1[_i];
54685                 var base = getTargetSymbol(baseProperty);
54686                 if (base.flags & 4194304) {
54687                     continue;
54688                 }
54689                 var baseSymbol = getPropertyOfObjectType(type, base.escapedName);
54690                 if (!baseSymbol) {
54691                     continue;
54692                 }
54693                 var derived = getTargetSymbol(baseSymbol);
54694                 var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base);
54695                 ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration.");
54696                 if (derived === base) {
54697                     var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol);
54698                     if (baseDeclarationFlags & 128 && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128))) {
54699                         for (var _a = 0, _b = getBaseTypes(type); _a < _b.length; _a++) {
54700                             var otherBaseType = _b[_a];
54701                             if (otherBaseType === baseType)
54702                                 continue;
54703                             var baseSymbol_1 = getPropertyOfObjectType(otherBaseType, base.escapedName);
54704                             var derivedElsewhere = baseSymbol_1 && getTargetSymbol(baseSymbol_1);
54705                             if (derivedElsewhere && derivedElsewhere !== base) {
54706                                 continue basePropertyCheck;
54707                             }
54708                         }
54709                         if (derivedClassDecl.kind === 214) {
54710                             error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType));
54711                         }
54712                         else {
54713                             error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType));
54714                         }
54715                     }
54716                 }
54717                 else {
54718                     var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived);
54719                     if (baseDeclarationFlags & 8 || derivedDeclarationFlags & 8) {
54720                         continue;
54721                     }
54722                     var errorMessage = void 0;
54723                     var basePropertyFlags = base.flags & 98308;
54724                     var derivedPropertyFlags = derived.flags & 98308;
54725                     if (basePropertyFlags && derivedPropertyFlags) {
54726                         if (!compilerOptions.useDefineForClassFields
54727                             || baseDeclarationFlags & 128 && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer)
54728                             || base.valueDeclaration && base.valueDeclaration.parent.kind === 246
54729                             || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) {
54730                             continue;
54731                         }
54732                         var overriddenInstanceProperty = basePropertyFlags !== 4 && derivedPropertyFlags === 4;
54733                         var overriddenInstanceAccessor = basePropertyFlags === 4 && derivedPropertyFlags !== 4;
54734                         if (overriddenInstanceProperty || overriddenInstanceAccessor) {
54735                             var errorMessage_1 = overriddenInstanceProperty ?
54736                                 ts.Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property :
54737                                 ts.Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor;
54738                             error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type));
54739                         }
54740                         else {
54741                             var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 159 && !d.initializer; });
54742                             if (uninitialized
54743                                 && !(derived.flags & 33554432)
54744                                 && !(baseDeclarationFlags & 128)
54745                                 && !(derivedDeclarationFlags & 128)
54746                                 && !derived.declarations.some(function (d) { return !!(d.flags & 8388608); })) {
54747                                 var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol));
54748                                 var propName = uninitialized.name;
54749                                 if (uninitialized.exclamationToken
54750                                     || !constructor
54751                                     || !ts.isIdentifier(propName)
54752                                     || !strictNullChecks
54753                                     || !isPropertyInitializedInConstructor(propName, type, constructor)) {
54754                                     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;
54755                                     error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_2, symbolToString(base), typeToString(baseType));
54756                                 }
54757                             }
54758                         }
54759                         continue;
54760                     }
54761                     else if (isPrototypeProperty(base)) {
54762                         if (isPrototypeProperty(derived) || derived.flags & 4) {
54763                             continue;
54764                         }
54765                         else {
54766                             ts.Debug.assert(!!(derived.flags & 98304));
54767                             errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor;
54768                         }
54769                     }
54770                     else if (base.flags & 98304) {
54771                         errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function;
54772                     }
54773                     else {
54774                         errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function;
54775                     }
54776                     error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type));
54777                 }
54778             }
54779         }
54780         function getNonInterhitedProperties(type, baseTypes, properties) {
54781             if (!ts.length(baseTypes)) {
54782                 return properties;
54783             }
54784             var seen = ts.createUnderscoreEscapedMap();
54785             ts.forEach(properties, function (p) { seen.set(p.escapedName, p); });
54786             for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) {
54787                 var base = baseTypes_2[_i];
54788                 var properties_5 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
54789                 for (var _a = 0, properties_4 = properties_5; _a < properties_4.length; _a++) {
54790                     var prop = properties_4[_a];
54791                     var existing = seen.get(prop.escapedName);
54792                     if (existing && !isPropertyIdenticalTo(existing, prop)) {
54793                         seen.delete(prop.escapedName);
54794                     }
54795                 }
54796             }
54797             return ts.arrayFrom(seen.values());
54798         }
54799         function checkInheritedPropertiesAreIdentical(type, typeNode) {
54800             var baseTypes = getBaseTypes(type);
54801             if (baseTypes.length < 2) {
54802                 return true;
54803             }
54804             var seen = ts.createUnderscoreEscapedMap();
54805             ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen.set(p.escapedName, { prop: p, containingType: type }); });
54806             var ok = true;
54807             for (var _i = 0, baseTypes_3 = baseTypes; _i < baseTypes_3.length; _i++) {
54808                 var base = baseTypes_3[_i];
54809                 var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
54810                 for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) {
54811                     var prop = properties_6[_a];
54812                     var existing = seen.get(prop.escapedName);
54813                     if (!existing) {
54814                         seen.set(prop.escapedName, { prop: prop, containingType: base });
54815                     }
54816                     else {
54817                         var isInheritedProperty = existing.containingType !== type;
54818                         if (isInheritedProperty && !isPropertyIdenticalTo(existing.prop, prop)) {
54819                             ok = false;
54820                             var typeName1 = typeToString(existing.containingType);
54821                             var typeName2 = typeToString(base);
54822                             var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Named_property_0_of_types_1_and_2_are_not_identical, symbolToString(prop), typeName1, typeName2);
54823                             errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2, typeToString(type), typeName1, typeName2);
54824                             diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(typeNode, errorInfo));
54825                         }
54826                     }
54827                 }
54828             }
54829             return ok;
54830         }
54831         function checkPropertyInitialization(node) {
54832             if (!strictNullChecks || !strictPropertyInitialization || node.flags & 8388608) {
54833                 return;
54834             }
54835             var constructor = findConstructorDeclaration(node);
54836             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
54837                 var member = _a[_i];
54838                 if (ts.getModifierFlags(member) & 2) {
54839                     continue;
54840                 }
54841                 if (isInstancePropertyWithoutInitializer(member)) {
54842                     var propName = member.name;
54843                     if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName)) {
54844                         var type = getTypeOfSymbol(getSymbolOfNode(member));
54845                         if (!(type.flags & 3 || getFalsyFlags(type) & 32768)) {
54846                             if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) {
54847                                 error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName));
54848                             }
54849                         }
54850                     }
54851                 }
54852             }
54853         }
54854         function isInstancePropertyWithoutInitializer(node) {
54855             return node.kind === 159 &&
54856                 !ts.hasModifier(node, 32 | 128) &&
54857                 !node.exclamationToken &&
54858                 !node.initializer;
54859         }
54860         function isPropertyInitializedInConstructor(propName, propType, constructor) {
54861             var reference = ts.createPropertyAccess(ts.createThis(), propName);
54862             reference.expression.parent = reference;
54863             reference.parent = constructor;
54864             reference.flowNode = constructor.returnFlowNode;
54865             var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
54866             return !(getFalsyFlags(flowType) & 32768);
54867         }
54868         function checkInterfaceDeclaration(node) {
54869             if (!checkGrammarDecoratorsAndModifiers(node))
54870                 checkGrammarInterfaceDeclaration(node);
54871             checkTypeParameters(node.typeParameters);
54872             if (produceDiagnostics) {
54873                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0);
54874                 checkExportsOnMergedDeclarations(node);
54875                 var symbol = getSymbolOfNode(node);
54876                 checkTypeParameterListsIdentical(symbol);
54877                 var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 246);
54878                 if (node === firstInterfaceDecl) {
54879                     var type = getDeclaredTypeOfSymbol(symbol);
54880                     var typeWithThis = getTypeWithThisArgument(type);
54881                     if (checkInheritedPropertiesAreIdentical(type, node.name)) {
54882                         for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) {
54883                             var baseType = _a[_i];
54884                             checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1);
54885                         }
54886                         checkIndexConstraints(type);
54887                     }
54888                 }
54889                 checkObjectTypeForDuplicateDeclarations(node);
54890             }
54891             ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) {
54892                 if (!ts.isEntityNameExpression(heritageElement.expression)) {
54893                     error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments);
54894                 }
54895                 checkTypeReferenceNode(heritageElement);
54896             });
54897             ts.forEach(node.members, checkSourceElement);
54898             if (produceDiagnostics) {
54899                 checkTypeForDuplicateIndexSignatures(node);
54900                 registerForUnusedIdentifiersCheck(node);
54901             }
54902         }
54903         function checkTypeAliasDeclaration(node) {
54904             checkGrammarDecoratorsAndModifiers(node);
54905             checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0);
54906             checkExportsOnMergedDeclarations(node);
54907             checkTypeParameters(node.typeParameters);
54908             checkSourceElement(node.type);
54909             registerForUnusedIdentifiersCheck(node);
54910         }
54911         function computeEnumMemberValues(node) {
54912             var nodeLinks = getNodeLinks(node);
54913             if (!(nodeLinks.flags & 16384)) {
54914                 nodeLinks.flags |= 16384;
54915                 var autoValue = 0;
54916                 for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
54917                     var member = _a[_i];
54918                     var value = computeMemberValue(member, autoValue);
54919                     getNodeLinks(member).enumMemberValue = value;
54920                     autoValue = typeof value === "number" ? value + 1 : undefined;
54921                 }
54922             }
54923         }
54924         function computeMemberValue(member, autoValue) {
54925             if (ts.isComputedNonLiteralName(member.name)) {
54926                 error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums);
54927             }
54928             else {
54929                 var text = ts.getTextOfPropertyName(member.name);
54930                 if (isNumericLiteralName(text) && !isInfinityOrNaNString(text)) {
54931                     error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name);
54932                 }
54933             }
54934             if (member.initializer) {
54935                 return computeConstantValue(member);
54936             }
54937             if (member.parent.flags & 8388608 && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0) {
54938                 return undefined;
54939             }
54940             if (autoValue !== undefined) {
54941                 return autoValue;
54942             }
54943             error(member.name, ts.Diagnostics.Enum_member_must_have_initializer);
54944             return undefined;
54945         }
54946         function computeConstantValue(member) {
54947             var enumKind = getEnumKind(getSymbolOfNode(member.parent));
54948             var isConstEnum = ts.isEnumConst(member.parent);
54949             var initializer = member.initializer;
54950             var value = enumKind === 1 && !isLiteralEnumMember(member) ? undefined : evaluate(initializer);
54951             if (value !== undefined) {
54952                 if (isConstEnum && typeof value === "number" && !isFinite(value)) {
54953                     error(initializer, isNaN(value) ?
54954                         ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN :
54955                         ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value);
54956                 }
54957             }
54958             else if (enumKind === 1) {
54959                 error(initializer, ts.Diagnostics.Computed_values_are_not_permitted_in_an_enum_with_string_valued_members);
54960                 return 0;
54961             }
54962             else if (isConstEnum) {
54963                 error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values);
54964             }
54965             else if (member.parent.flags & 8388608) {
54966                 error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression);
54967             }
54968             else {
54969                 var source = checkExpression(initializer);
54970                 if (!isTypeAssignableToKind(source, 296)) {
54971                     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));
54972                 }
54973                 else {
54974                     checkTypeAssignableTo(source, getDeclaredTypeOfSymbol(getSymbolOfNode(member.parent)), initializer, undefined);
54975                 }
54976             }
54977             return value;
54978             function evaluate(expr) {
54979                 switch (expr.kind) {
54980                     case 207:
54981                         var value_2 = evaluate(expr.operand);
54982                         if (typeof value_2 === "number") {
54983                             switch (expr.operator) {
54984                                 case 39: return value_2;
54985                                 case 40: return -value_2;
54986                                 case 54: return ~value_2;
54987                             }
54988                         }
54989                         break;
54990                     case 209:
54991                         var left = evaluate(expr.left);
54992                         var right = evaluate(expr.right);
54993                         if (typeof left === "number" && typeof right === "number") {
54994                             switch (expr.operatorToken.kind) {
54995                                 case 51: return left | right;
54996                                 case 50: return left & right;
54997                                 case 48: return left >> right;
54998                                 case 49: return left >>> right;
54999                                 case 47: return left << right;
55000                                 case 52: return left ^ right;
55001                                 case 41: return left * right;
55002                                 case 43: return left / right;
55003                                 case 39: return left + right;
55004                                 case 40: return left - right;
55005                                 case 44: return left % right;
55006                                 case 42: return Math.pow(left, right);
55007                             }
55008                         }
55009                         else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39) {
55010                             return left + right;
55011                         }
55012                         break;
55013                     case 10:
55014                     case 14:
55015                         return expr.text;
55016                     case 8:
55017                         checkGrammarNumericLiteral(expr);
55018                         return +expr.text;
55019                     case 200:
55020                         return evaluate(expr.expression);
55021                     case 75:
55022                         var identifier = expr;
55023                         if (isInfinityOrNaNString(identifier.escapedText)) {
55024                             return +(identifier.escapedText);
55025                         }
55026                         return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText);
55027                     case 195:
55028                     case 194:
55029                         var ex = expr;
55030                         if (isConstantMemberAccess(ex)) {
55031                             var type = getTypeOfExpression(ex.expression);
55032                             if (type.symbol && type.symbol.flags & 384) {
55033                                 var name = void 0;
55034                                 if (ex.kind === 194) {
55035                                     name = ex.name.escapedText;
55036                                 }
55037                                 else {
55038                                     name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text);
55039                                 }
55040                                 return evaluateEnumMember(expr, type.symbol, name);
55041                             }
55042                         }
55043                         break;
55044                 }
55045                 return undefined;
55046             }
55047             function evaluateEnumMember(expr, enumSymbol, name) {
55048                 var memberSymbol = enumSymbol.exports.get(name);
55049                 if (memberSymbol) {
55050                     var declaration = memberSymbol.valueDeclaration;
55051                     if (declaration !== member) {
55052                         if (isBlockScopedNameDeclaredBeforeUse(declaration, member)) {
55053                             return getEnumMemberValue(declaration);
55054                         }
55055                         error(expr, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
55056                         return 0;
55057                     }
55058                     else {
55059                         error(expr, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(memberSymbol));
55060                     }
55061                 }
55062                 return undefined;
55063             }
55064         }
55065         function isConstantMemberAccess(node) {
55066             return node.kind === 75 ||
55067                 node.kind === 194 && isConstantMemberAccess(node.expression) ||
55068                 node.kind === 195 && isConstantMemberAccess(node.expression) &&
55069                     ts.isStringLiteralLike(node.argumentExpression);
55070         }
55071         function checkEnumDeclaration(node) {
55072             if (!produceDiagnostics) {
55073                 return;
55074             }
55075             checkGrammarDecoratorsAndModifiers(node);
55076             checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0);
55077             checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
55078             checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
55079             checkExportsOnMergedDeclarations(node);
55080             node.members.forEach(checkEnumMember);
55081             computeEnumMemberValues(node);
55082             var enumSymbol = getSymbolOfNode(node);
55083             var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind);
55084             if (node === firstDeclaration) {
55085                 if (enumSymbol.declarations.length > 1) {
55086                     var enumIsConst_1 = ts.isEnumConst(node);
55087                     ts.forEach(enumSymbol.declarations, function (decl) {
55088                         if (ts.isEnumDeclaration(decl) && ts.isEnumConst(decl) !== enumIsConst_1) {
55089                             error(ts.getNameOfDeclaration(decl), ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const);
55090                         }
55091                     });
55092                 }
55093                 var seenEnumMissingInitialInitializer_1 = false;
55094                 ts.forEach(enumSymbol.declarations, function (declaration) {
55095                     if (declaration.kind !== 248) {
55096                         return false;
55097                     }
55098                     var enumDeclaration = declaration;
55099                     if (!enumDeclaration.members.length) {
55100                         return false;
55101                     }
55102                     var firstEnumMember = enumDeclaration.members[0];
55103                     if (!firstEnumMember.initializer) {
55104                         if (seenEnumMissingInitialInitializer_1) {
55105                             error(firstEnumMember.name, ts.Diagnostics.In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element);
55106                         }
55107                         else {
55108                             seenEnumMissingInitialInitializer_1 = true;
55109                         }
55110                     }
55111                 });
55112             }
55113         }
55114         function checkEnumMember(node) {
55115             if (ts.isPrivateIdentifier(node.name)) {
55116                 error(node, ts.Diagnostics.An_enum_member_cannot_be_named_with_a_private_identifier);
55117             }
55118         }
55119         function getFirstNonAmbientClassOrFunctionDeclaration(symbol) {
55120             var declarations = symbol.declarations;
55121             for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
55122                 var declaration = declarations_8[_i];
55123                 if ((declaration.kind === 245 ||
55124                     (declaration.kind === 244 && ts.nodeIsPresent(declaration.body))) &&
55125                     !(declaration.flags & 8388608)) {
55126                     return declaration;
55127                 }
55128             }
55129             return undefined;
55130         }
55131         function inSameLexicalScope(node1, node2) {
55132             var container1 = ts.getEnclosingBlockScopeContainer(node1);
55133             var container2 = ts.getEnclosingBlockScopeContainer(node2);
55134             if (isGlobalSourceFile(container1)) {
55135                 return isGlobalSourceFile(container2);
55136             }
55137             else if (isGlobalSourceFile(container2)) {
55138                 return false;
55139             }
55140             else {
55141                 return container1 === container2;
55142             }
55143         }
55144         function checkModuleDeclaration(node) {
55145             if (produceDiagnostics) {
55146                 var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node);
55147                 var inAmbientContext = node.flags & 8388608;
55148                 if (isGlobalAugmentation && !inAmbientContext) {
55149                     error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context);
55150                 }
55151                 var isAmbientExternalModule = ts.isAmbientModule(node);
55152                 var contextErrorMessage = isAmbientExternalModule
55153                     ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file
55154                     : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module;
55155                 if (checkGrammarModuleElementContext(node, contextErrorMessage)) {
55156                     return;
55157                 }
55158                 if (!checkGrammarDecoratorsAndModifiers(node)) {
55159                     if (!inAmbientContext && node.name.kind === 10) {
55160                         grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names);
55161                     }
55162                 }
55163                 if (ts.isIdentifier(node.name)) {
55164                     checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
55165                     checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
55166                 }
55167                 checkExportsOnMergedDeclarations(node);
55168                 var symbol = getSymbolOfNode(node);
55169                 if (symbol.flags & 512
55170                     && !inAmbientContext
55171                     && symbol.declarations.length > 1
55172                     && isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules)) {
55173                     var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol);
55174                     if (firstNonAmbientClassOrFunc) {
55175                         if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) {
55176                             error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged);
55177                         }
55178                         else if (node.pos < firstNonAmbientClassOrFunc.pos) {
55179                             error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged);
55180                         }
55181                     }
55182                     var mergedClass = ts.getDeclarationOfKind(symbol, 245);
55183                     if (mergedClass &&
55184                         inSameLexicalScope(node, mergedClass)) {
55185                         getNodeLinks(node).flags |= 32768;
55186                     }
55187                 }
55188                 if (isAmbientExternalModule) {
55189                     if (ts.isExternalModuleAugmentation(node)) {
55190                         var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432);
55191                         if (checkBody && node.body) {
55192                             for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
55193                                 var statement = _a[_i];
55194                                 checkModuleAugmentationElement(statement, isGlobalAugmentation);
55195                             }
55196                         }
55197                     }
55198                     else if (isGlobalSourceFile(node.parent)) {
55199                         if (isGlobalAugmentation) {
55200                             error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations);
55201                         }
55202                         else if (ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(node.name))) {
55203                             error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name);
55204                         }
55205                     }
55206                     else {
55207                         if (isGlobalAugmentation) {
55208                             error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations);
55209                         }
55210                         else {
55211                             error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces);
55212                         }
55213                     }
55214                 }
55215             }
55216             if (node.body) {
55217                 checkSourceElement(node.body);
55218                 if (!ts.isGlobalScopeAugmentation(node)) {
55219                     registerForUnusedIdentifiersCheck(node);
55220                 }
55221             }
55222         }
55223         function checkModuleAugmentationElement(node, isGlobalAugmentation) {
55224             switch (node.kind) {
55225                 case 225:
55226                     for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
55227                         var decl = _a[_i];
55228                         checkModuleAugmentationElement(decl, isGlobalAugmentation);
55229                     }
55230                     break;
55231                 case 259:
55232                 case 260:
55233                     grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations);
55234                     break;
55235                 case 253:
55236                 case 254:
55237                     grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module);
55238                     break;
55239                 case 191:
55240                 case 242:
55241                     var name = node.name;
55242                     if (ts.isBindingPattern(name)) {
55243                         for (var _b = 0, _c = name.elements; _b < _c.length; _b++) {
55244                             var el = _c[_b];
55245                             checkModuleAugmentationElement(el, isGlobalAugmentation);
55246                         }
55247                         break;
55248                     }
55249                 case 245:
55250                 case 248:
55251                 case 244:
55252                 case 246:
55253                 case 249:
55254                 case 247:
55255                     if (isGlobalAugmentation) {
55256                         return;
55257                     }
55258                     var symbol = getSymbolOfNode(node);
55259                     if (symbol) {
55260                         var reportError = !(symbol.flags & 33554432);
55261                         if (!reportError) {
55262                             reportError = !!symbol.parent && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]);
55263                         }
55264                     }
55265                     break;
55266             }
55267         }
55268         function getFirstNonModuleExportsIdentifier(node) {
55269             switch (node.kind) {
55270                 case 75:
55271                     return node;
55272                 case 153:
55273                     do {
55274                         node = node.left;
55275                     } while (node.kind !== 75);
55276                     return node;
55277                 case 194:
55278                     do {
55279                         if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) {
55280                             return node.name;
55281                         }
55282                         node = node.expression;
55283                     } while (node.kind !== 75);
55284                     return node;
55285             }
55286         }
55287         function checkExternalImportOrExportDeclaration(node) {
55288             var moduleName = ts.getExternalModuleName(node);
55289             if (!moduleName || ts.nodeIsMissing(moduleName)) {
55290                 return false;
55291             }
55292             if (!ts.isStringLiteral(moduleName)) {
55293                 error(moduleName, ts.Diagnostics.String_literal_expected);
55294                 return false;
55295             }
55296             var inAmbientExternalModule = node.parent.kind === 250 && ts.isAmbientModule(node.parent.parent);
55297             if (node.parent.kind !== 290 && !inAmbientExternalModule) {
55298                 error(moduleName, node.kind === 260 ?
55299                     ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace :
55300                     ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module);
55301                 return false;
55302             }
55303             if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) {
55304                 if (!isTopLevelInExternalModuleAugmentation(node)) {
55305                     error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name);
55306                     return false;
55307                 }
55308             }
55309             return true;
55310         }
55311         function checkAliasSymbol(node) {
55312             var symbol = getSymbolOfNode(node);
55313             var target = resolveAlias(symbol);
55314             var shouldSkipWithJSExpandoTargets = symbol.flags & 67108864;
55315             if (!shouldSkipWithJSExpandoTargets && target !== unknownSymbol) {
55316                 symbol = getMergedSymbol(symbol.exportSymbol || symbol);
55317                 var excludedMeanings = (symbol.flags & (111551 | 1048576) ? 111551 : 0) |
55318                     (symbol.flags & 788968 ? 788968 : 0) |
55319                     (symbol.flags & 1920 ? 1920 : 0);
55320                 if (target.flags & excludedMeanings) {
55321                     var message = node.kind === 263 ?
55322                         ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 :
55323                         ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
55324                     error(node, message, symbolToString(symbol));
55325                 }
55326                 if (compilerOptions.isolatedModules
55327                     && node.kind === 263
55328                     && !node.parent.parent.isTypeOnly
55329                     && !(target.flags & 111551)
55330                     && !(node.flags & 8388608)) {
55331                     error(node, ts.Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type);
55332                 }
55333             }
55334         }
55335         function checkImportBinding(node) {
55336             checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
55337             checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
55338             checkAliasSymbol(node);
55339         }
55340         function checkImportDeclaration(node) {
55341             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
55342                 return;
55343             }
55344             if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) {
55345                 grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers);
55346             }
55347             if (checkExternalImportOrExportDeclaration(node)) {
55348                 var importClause = node.importClause;
55349                 if (importClause && !checkGrammarImportClause(importClause)) {
55350                     if (importClause.name) {
55351                         checkImportBinding(importClause);
55352                     }
55353                     if (importClause.namedBindings) {
55354                         if (importClause.namedBindings.kind === 256) {
55355                             checkImportBinding(importClause.namedBindings);
55356                         }
55357                         else {
55358                             var moduleExisted = resolveExternalModuleName(node, node.moduleSpecifier);
55359                             if (moduleExisted) {
55360                                 ts.forEach(importClause.namedBindings.elements, checkImportBinding);
55361                             }
55362                         }
55363                     }
55364                 }
55365             }
55366         }
55367         function checkImportEqualsDeclaration(node) {
55368             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
55369                 return;
55370             }
55371             checkGrammarDecoratorsAndModifiers(node);
55372             if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) {
55373                 checkImportBinding(node);
55374                 if (ts.hasModifier(node, 1)) {
55375                     markExportAsReferenced(node);
55376                 }
55377                 if (node.moduleReference.kind !== 265) {
55378                     var target = resolveAlias(getSymbolOfNode(node));
55379                     if (target !== unknownSymbol) {
55380                         if (target.flags & 111551) {
55381                             var moduleName = ts.getFirstIdentifier(node.moduleReference);
55382                             if (!(resolveEntityName(moduleName, 111551 | 1920).flags & 1920)) {
55383                                 error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName));
55384                             }
55385                         }
55386                         if (target.flags & 788968) {
55387                             checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0);
55388                         }
55389                     }
55390                 }
55391                 else {
55392                     if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 8388608)) {
55393                         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);
55394                     }
55395                 }
55396             }
55397         }
55398         function checkExportDeclaration(node) {
55399             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) {
55400                 return;
55401             }
55402             if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) {
55403                 grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers);
55404             }
55405             if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0) {
55406                 checkExternalEmitHelpers(node, 1048576);
55407             }
55408             checkGrammarExportDeclaration(node);
55409             if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) {
55410                 if (node.exportClause && !ts.isNamespaceExport(node.exportClause)) {
55411                     ts.forEach(node.exportClause.elements, checkExportSpecifier);
55412                     var inAmbientExternalModule = node.parent.kind === 250 && ts.isAmbientModule(node.parent.parent);
55413                     var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 250 &&
55414                         !node.moduleSpecifier && node.flags & 8388608;
55415                     if (node.parent.kind !== 290 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) {
55416                         error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace);
55417                     }
55418                 }
55419                 else {
55420                     var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier);
55421                     if (moduleSymbol && hasExportAssignmentSymbol(moduleSymbol)) {
55422                         error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol));
55423                     }
55424                     else if (node.exportClause) {
55425                         checkAliasSymbol(node.exportClause);
55426                     }
55427                     if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) {
55428                         checkExternalEmitHelpers(node, 65536);
55429                     }
55430                 }
55431             }
55432         }
55433         function checkGrammarExportDeclaration(node) {
55434             var _a;
55435             var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 261;
55436             if (isTypeOnlyExportStar) {
55437                 grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type);
55438             }
55439             return !isTypeOnlyExportStar;
55440         }
55441         function checkGrammarModuleElementContext(node, errorMessage) {
55442             var isInAppropriateContext = node.parent.kind === 290 || node.parent.kind === 250 || node.parent.kind === 249;
55443             if (!isInAppropriateContext) {
55444                 grammarErrorOnFirstToken(node, errorMessage);
55445             }
55446             return !isInAppropriateContext;
55447         }
55448         function importClauseContainsReferencedImport(importClause) {
55449             return ts.forEachImportClauseDeclaration(importClause, function (declaration) {
55450                 return !!getSymbolOfNode(declaration).isReferenced;
55451             });
55452         }
55453         function importClauseContainsConstEnumUsedAsValue(importClause) {
55454             return ts.forEachImportClauseDeclaration(importClause, function (declaration) {
55455                 return !!getSymbolLinks(getSymbolOfNode(declaration)).constEnumReferenced;
55456             });
55457         }
55458         function checkImportsForTypeOnlyConversion(sourceFile) {
55459             for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
55460                 var statement = _a[_i];
55461                 if (ts.isImportDeclaration(statement) &&
55462                     statement.importClause &&
55463                     !statement.importClause.isTypeOnly &&
55464                     importClauseContainsReferencedImport(statement.importClause) &&
55465                     !isReferencedAliasDeclaration(statement.importClause, true) &&
55466                     !importClauseContainsConstEnumUsedAsValue(statement.importClause)) {
55467                     error(statement, ts.Diagnostics.This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is_set_to_error);
55468                 }
55469             }
55470         }
55471         function checkExportSpecifier(node) {
55472             checkAliasSymbol(node);
55473             if (ts.getEmitDeclarations(compilerOptions)) {
55474                 collectLinkedAliases(node.propertyName || node.name, true);
55475             }
55476             if (!node.parent.parent.moduleSpecifier) {
55477                 var exportedName = node.propertyName || node.name;
55478                 var symbol = resolveName(exportedName, exportedName.escapedText, 111551 | 788968 | 1920 | 2097152, undefined, undefined, true);
55479                 if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) {
55480                     error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName));
55481                 }
55482                 else {
55483                     markExportAsReferenced(node);
55484                     var target = symbol && (symbol.flags & 2097152 ? resolveAlias(symbol) : symbol);
55485                     if (!target || target === unknownSymbol || target.flags & 111551) {
55486                         checkExpressionCached(node.propertyName || node.name);
55487                     }
55488                 }
55489             }
55490         }
55491         function checkExportAssignment(node) {
55492             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) {
55493                 return;
55494             }
55495             var container = node.parent.kind === 290 ? node.parent : node.parent.parent;
55496             if (container.kind === 249 && !ts.isAmbientModule(container)) {
55497                 if (node.isExportEquals) {
55498                     error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace);
55499                 }
55500                 else {
55501                     error(node, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module);
55502                 }
55503                 return;
55504             }
55505             if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) {
55506                 grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers);
55507             }
55508             if (node.expression.kind === 75) {
55509                 var id = node.expression;
55510                 var sym = resolveEntityName(id, 67108863, true, true, node);
55511                 if (sym) {
55512                     markAliasReferenced(sym, id);
55513                     var target = sym.flags & 2097152 ? resolveAlias(sym) : sym;
55514                     if (target === unknownSymbol || target.flags & 111551) {
55515                         checkExpressionCached(node.expression);
55516                     }
55517                 }
55518                 if (ts.getEmitDeclarations(compilerOptions)) {
55519                     collectLinkedAliases(node.expression, true);
55520                 }
55521             }
55522             else {
55523                 checkExpressionCached(node.expression);
55524             }
55525             checkExternalModuleExports(container);
55526             if ((node.flags & 8388608) && !ts.isEntityNameExpression(node.expression)) {
55527                 grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
55528             }
55529             if (node.isExportEquals && !(node.flags & 8388608)) {
55530                 if (moduleKind >= ts.ModuleKind.ES2015) {
55531                     grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
55532                 }
55533                 else if (moduleKind === ts.ModuleKind.System) {
55534                     grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system);
55535                 }
55536             }
55537         }
55538         function hasExportedMembers(moduleSymbol) {
55539             return ts.forEachEntry(moduleSymbol.exports, function (_, id) { return id !== "export="; });
55540         }
55541         function checkExternalModuleExports(node) {
55542             var moduleSymbol = getSymbolOfNode(node);
55543             var links = getSymbolLinks(moduleSymbol);
55544             if (!links.exportsChecked) {
55545                 var exportEqualsSymbol = moduleSymbol.exports.get("export=");
55546                 if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) {
55547                     var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration;
55548                     if (!isTopLevelInExternalModuleAugmentation(declaration) && !ts.isInJSFile(declaration)) {
55549                         error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements);
55550                     }
55551                 }
55552                 var exports_2 = getExportsOfModule(moduleSymbol);
55553                 if (exports_2) {
55554                     exports_2.forEach(function (_a, id) {
55555                         var declarations = _a.declarations, flags = _a.flags;
55556                         if (id === "__export") {
55557                             return;
55558                         }
55559                         if (flags & (1920 | 64 | 384)) {
55560                             return;
55561                         }
55562                         var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverloadAndNotAccessor);
55563                         if (flags & 524288 && exportedDeclarationsCount <= 2) {
55564                             return;
55565                         }
55566                         if (exportedDeclarationsCount > 1) {
55567                             for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) {
55568                                 var declaration = declarations_9[_i];
55569                                 if (isNotOverload(declaration)) {
55570                                     diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id)));
55571                                 }
55572                             }
55573                         }
55574                     });
55575                 }
55576                 links.exportsChecked = true;
55577             }
55578         }
55579         function checkSourceElement(node) {
55580             if (node) {
55581                 var saveCurrentNode = currentNode;
55582                 currentNode = node;
55583                 instantiationCount = 0;
55584                 checkSourceElementWorker(node);
55585                 currentNode = saveCurrentNode;
55586             }
55587         }
55588         function checkSourceElementWorker(node) {
55589             if (ts.isInJSFile(node)) {
55590                 ts.forEach(node.jsDoc, function (_a) {
55591                     var tags = _a.tags;
55592                     return ts.forEach(tags, checkSourceElement);
55593                 });
55594             }
55595             var kind = node.kind;
55596             if (cancellationToken) {
55597                 switch (kind) {
55598                     case 249:
55599                     case 245:
55600                     case 246:
55601                     case 244:
55602                         cancellationToken.throwIfCancellationRequested();
55603                 }
55604             }
55605             if (kind >= 225 && kind <= 241 && node.flowNode && !isReachableFlowNode(node.flowNode)) {
55606                 errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected);
55607             }
55608             switch (kind) {
55609                 case 155:
55610                     return checkTypeParameter(node);
55611                 case 156:
55612                     return checkParameter(node);
55613                 case 159:
55614                     return checkPropertyDeclaration(node);
55615                 case 158:
55616                     return checkPropertySignature(node);
55617                 case 170:
55618                 case 171:
55619                 case 165:
55620                 case 166:
55621                 case 167:
55622                     return checkSignatureDeclaration(node);
55623                 case 161:
55624                 case 160:
55625                     return checkMethodDeclaration(node);
55626                 case 162:
55627                     return checkConstructorDeclaration(node);
55628                 case 163:
55629                 case 164:
55630                     return checkAccessorDeclaration(node);
55631                 case 169:
55632                     return checkTypeReferenceNode(node);
55633                 case 168:
55634                     return checkTypePredicate(node);
55635                 case 172:
55636                     return checkTypeQuery(node);
55637                 case 173:
55638                     return checkTypeLiteral(node);
55639                 case 174:
55640                     return checkArrayType(node);
55641                 case 175:
55642                     return checkTupleType(node);
55643                 case 178:
55644                 case 179:
55645                     return checkUnionOrIntersectionType(node);
55646                 case 182:
55647                 case 176:
55648                 case 177:
55649                     return checkSourceElement(node.type);
55650                 case 183:
55651                     return checkThisType(node);
55652                 case 184:
55653                     return checkTypeOperator(node);
55654                 case 180:
55655                     return checkConditionalType(node);
55656                 case 181:
55657                     return checkInferType(node);
55658                 case 188:
55659                     return checkImportType(node);
55660                 case 307:
55661                     return checkJSDocAugmentsTag(node);
55662                 case 308:
55663                     return checkJSDocImplementsTag(node);
55664                 case 322:
55665                 case 315:
55666                 case 316:
55667                     return checkJSDocTypeAliasTag(node);
55668                 case 321:
55669                     return checkJSDocTemplateTag(node);
55670                 case 320:
55671                     return checkJSDocTypeTag(node);
55672                 case 317:
55673                     return checkJSDocParameterTag(node);
55674                 case 323:
55675                     return checkJSDocPropertyTag(node);
55676                 case 300:
55677                     checkJSDocFunctionType(node);
55678                 case 298:
55679                 case 297:
55680                 case 295:
55681                 case 296:
55682                 case 304:
55683                     checkJSDocTypeIsInJsFile(node);
55684                     ts.forEachChild(node, checkSourceElement);
55685                     return;
55686                 case 301:
55687                     checkJSDocVariadicType(node);
55688                     return;
55689                 case 294:
55690                     return checkSourceElement(node.type);
55691                 case 185:
55692                     return checkIndexedAccessType(node);
55693                 case 186:
55694                     return checkMappedType(node);
55695                 case 244:
55696                     return checkFunctionDeclaration(node);
55697                 case 223:
55698                 case 250:
55699                     return checkBlock(node);
55700                 case 225:
55701                     return checkVariableStatement(node);
55702                 case 226:
55703                     return checkExpressionStatement(node);
55704                 case 227:
55705                     return checkIfStatement(node);
55706                 case 228:
55707                     return checkDoStatement(node);
55708                 case 229:
55709                     return checkWhileStatement(node);
55710                 case 230:
55711                     return checkForStatement(node);
55712                 case 231:
55713                     return checkForInStatement(node);
55714                 case 232:
55715                     return checkForOfStatement(node);
55716                 case 233:
55717                 case 234:
55718                     return checkBreakOrContinueStatement(node);
55719                 case 235:
55720                     return checkReturnStatement(node);
55721                 case 236:
55722                     return checkWithStatement(node);
55723                 case 237:
55724                     return checkSwitchStatement(node);
55725                 case 238:
55726                     return checkLabeledStatement(node);
55727                 case 239:
55728                     return checkThrowStatement(node);
55729                 case 240:
55730                     return checkTryStatement(node);
55731                 case 242:
55732                     return checkVariableDeclaration(node);
55733                 case 191:
55734                     return checkBindingElement(node);
55735                 case 245:
55736                     return checkClassDeclaration(node);
55737                 case 246:
55738                     return checkInterfaceDeclaration(node);
55739                 case 247:
55740                     return checkTypeAliasDeclaration(node);
55741                 case 248:
55742                     return checkEnumDeclaration(node);
55743                 case 249:
55744                     return checkModuleDeclaration(node);
55745                 case 254:
55746                     return checkImportDeclaration(node);
55747                 case 253:
55748                     return checkImportEqualsDeclaration(node);
55749                 case 260:
55750                     return checkExportDeclaration(node);
55751                 case 259:
55752                     return checkExportAssignment(node);
55753                 case 224:
55754                 case 241:
55755                     checkGrammarStatementInAmbientContext(node);
55756                     return;
55757                 case 264:
55758                     return checkMissingDeclaration(node);
55759             }
55760         }
55761         function checkJSDocTypeIsInJsFile(node) {
55762             if (!ts.isInJSFile(node)) {
55763                 grammarErrorOnNode(node, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments);
55764             }
55765         }
55766         function checkJSDocVariadicType(node) {
55767             checkJSDocTypeIsInJsFile(node);
55768             checkSourceElement(node.type);
55769             var parent = node.parent;
55770             if (ts.isParameter(parent) && ts.isJSDocFunctionType(parent.parent)) {
55771                 if (ts.last(parent.parent.parameters) !== parent) {
55772                     error(node, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
55773                 }
55774                 return;
55775             }
55776             if (!ts.isJSDocTypeExpression(parent)) {
55777                 error(node, ts.Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature);
55778             }
55779             var paramTag = node.parent.parent;
55780             if (!ts.isJSDocParameterTag(paramTag)) {
55781                 error(node, ts.Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature);
55782                 return;
55783             }
55784             var param = ts.getParameterSymbolFromJSDoc(paramTag);
55785             if (!param) {
55786                 return;
55787             }
55788             var host = ts.getHostSignatureFromJSDoc(paramTag);
55789             if (!host || ts.last(host.parameters).symbol !== param) {
55790                 error(node, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
55791             }
55792         }
55793         function getTypeFromJSDocVariadicType(node) {
55794             var type = getTypeFromTypeNode(node.type);
55795             var parent = node.parent;
55796             var paramTag = node.parent.parent;
55797             if (ts.isJSDocTypeExpression(node.parent) && ts.isJSDocParameterTag(paramTag)) {
55798                 var host_1 = ts.getHostSignatureFromJSDoc(paramTag);
55799                 if (host_1) {
55800                     var lastParamDeclaration = ts.lastOrUndefined(host_1.parameters);
55801                     var symbol = ts.getParameterSymbolFromJSDoc(paramTag);
55802                     if (!lastParamDeclaration ||
55803                         symbol && lastParamDeclaration.symbol === symbol && ts.isRestParameter(lastParamDeclaration)) {
55804                         return createArrayType(type);
55805                     }
55806                 }
55807             }
55808             if (ts.isParameter(parent) && ts.isJSDocFunctionType(parent.parent)) {
55809                 return createArrayType(type);
55810             }
55811             return addOptionality(type);
55812         }
55813         function checkNodeDeferred(node) {
55814             var enclosingFile = ts.getSourceFileOfNode(node);
55815             var links = getNodeLinks(enclosingFile);
55816             if (!(links.flags & 1)) {
55817                 links.deferredNodes = links.deferredNodes || ts.createMap();
55818                 var id = "" + getNodeId(node);
55819                 links.deferredNodes.set(id, node);
55820             }
55821         }
55822         function checkDeferredNodes(context) {
55823             var links = getNodeLinks(context);
55824             if (links.deferredNodes) {
55825                 links.deferredNodes.forEach(checkDeferredNode);
55826             }
55827         }
55828         function checkDeferredNode(node) {
55829             var saveCurrentNode = currentNode;
55830             currentNode = node;
55831             instantiationCount = 0;
55832             switch (node.kind) {
55833                 case 196:
55834                 case 197:
55835                 case 198:
55836                 case 157:
55837                 case 268:
55838                     resolveUntypedCall(node);
55839                     break;
55840                 case 201:
55841                 case 202:
55842                 case 161:
55843                 case 160:
55844                     checkFunctionExpressionOrObjectLiteralMethodDeferred(node);
55845                     break;
55846                 case 163:
55847                 case 164:
55848                     checkAccessorDeclaration(node);
55849                     break;
55850                 case 214:
55851                     checkClassExpressionDeferred(node);
55852                     break;
55853                 case 267:
55854                     checkJsxSelfClosingElementDeferred(node);
55855                     break;
55856                 case 266:
55857                     checkJsxElementDeferred(node);
55858                     break;
55859             }
55860             currentNode = saveCurrentNode;
55861         }
55862         function checkSourceFile(node) {
55863             ts.performance.mark("beforeCheck");
55864             checkSourceFileWorker(node);
55865             ts.performance.mark("afterCheck");
55866             ts.performance.measure("Check", "beforeCheck", "afterCheck");
55867         }
55868         function unusedIsError(kind, isAmbient) {
55869             if (isAmbient) {
55870                 return false;
55871             }
55872             switch (kind) {
55873                 case 0:
55874                     return !!compilerOptions.noUnusedLocals;
55875                 case 1:
55876                     return !!compilerOptions.noUnusedParameters;
55877                 default:
55878                     return ts.Debug.assertNever(kind);
55879             }
55880         }
55881         function getPotentiallyUnusedIdentifiers(sourceFile) {
55882             return allPotentiallyUnusedIdentifiers.get(sourceFile.path) || ts.emptyArray;
55883         }
55884         function checkSourceFileWorker(node) {
55885             var links = getNodeLinks(node);
55886             if (!(links.flags & 1)) {
55887                 if (ts.skipTypeChecking(node, compilerOptions, host)) {
55888                     return;
55889                 }
55890                 checkGrammarSourceFile(node);
55891                 ts.clear(potentialThisCollisions);
55892                 ts.clear(potentialNewTargetCollisions);
55893                 ts.clear(potentialWeakMapCollisions);
55894                 ts.forEach(node.statements, checkSourceElement);
55895                 checkSourceElement(node.endOfFileToken);
55896                 checkDeferredNodes(node);
55897                 if (ts.isExternalOrCommonJsModule(node)) {
55898                     registerForUnusedIdentifiersCheck(node);
55899                 }
55900                 if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
55901                     checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
55902                         if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 8388608))) {
55903                             diagnostics.add(diag);
55904                         }
55905                     });
55906                 }
55907                 if (compilerOptions.importsNotUsedAsValues === 2 &&
55908                     !node.isDeclarationFile &&
55909                     ts.isExternalModule(node)) {
55910                     checkImportsForTypeOnlyConversion(node);
55911                 }
55912                 if (ts.isExternalOrCommonJsModule(node)) {
55913                     checkExternalModuleExports(node);
55914                 }
55915                 if (potentialThisCollisions.length) {
55916                     ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope);
55917                     ts.clear(potentialThisCollisions);
55918                 }
55919                 if (potentialNewTargetCollisions.length) {
55920                     ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope);
55921                     ts.clear(potentialNewTargetCollisions);
55922                 }
55923                 if (potentialWeakMapCollisions.length) {
55924                     ts.forEach(potentialWeakMapCollisions, checkWeakMapCollision);
55925                     ts.clear(potentialWeakMapCollisions);
55926                 }
55927                 links.flags |= 1;
55928             }
55929         }
55930         function getDiagnostics(sourceFile, ct) {
55931             try {
55932                 cancellationToken = ct;
55933                 return getDiagnosticsWorker(sourceFile);
55934             }
55935             finally {
55936                 cancellationToken = undefined;
55937             }
55938         }
55939         function getDiagnosticsWorker(sourceFile) {
55940             throwIfNonDiagnosticsProducing();
55941             if (sourceFile) {
55942                 var previousGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
55943                 var previousGlobalDiagnosticsSize = previousGlobalDiagnostics.length;
55944                 checkSourceFile(sourceFile);
55945                 var semanticDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
55946                 var currentGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
55947                 if (currentGlobalDiagnostics !== previousGlobalDiagnostics) {
55948                     var deferredGlobalDiagnostics = ts.relativeComplement(previousGlobalDiagnostics, currentGlobalDiagnostics, ts.compareDiagnostics);
55949                     return ts.concatenate(deferredGlobalDiagnostics, semanticDiagnostics);
55950                 }
55951                 else if (previousGlobalDiagnosticsSize === 0 && currentGlobalDiagnostics.length > 0) {
55952                     return ts.concatenate(currentGlobalDiagnostics, semanticDiagnostics);
55953                 }
55954                 return semanticDiagnostics;
55955             }
55956             ts.forEach(host.getSourceFiles(), checkSourceFile);
55957             return diagnostics.getDiagnostics();
55958         }
55959         function getGlobalDiagnostics() {
55960             throwIfNonDiagnosticsProducing();
55961             return diagnostics.getGlobalDiagnostics();
55962         }
55963         function throwIfNonDiagnosticsProducing() {
55964             if (!produceDiagnostics) {
55965                 throw new Error("Trying to get diagnostics from a type checker that does not produce them.");
55966             }
55967         }
55968         function getSymbolsInScope(location, meaning) {
55969             if (location.flags & 16777216) {
55970                 return [];
55971             }
55972             var symbols = ts.createSymbolTable();
55973             var isStatic = false;
55974             populateSymbols();
55975             symbols.delete("this");
55976             return symbolsToArray(symbols);
55977             function populateSymbols() {
55978                 while (location) {
55979                     if (location.locals && !isGlobalSourceFile(location)) {
55980                         copySymbols(location.locals, meaning);
55981                     }
55982                     switch (location.kind) {
55983                         case 290:
55984                             if (!ts.isExternalOrCommonJsModule(location))
55985                                 break;
55986                         case 249:
55987                             copySymbols(getSymbolOfNode(location).exports, meaning & 2623475);
55988                             break;
55989                         case 248:
55990                             copySymbols(getSymbolOfNode(location).exports, meaning & 8);
55991                             break;
55992                         case 214:
55993                             var className = location.name;
55994                             if (className) {
55995                                 copySymbol(location.symbol, meaning);
55996                             }
55997                         case 245:
55998                         case 246:
55999                             if (!isStatic) {
56000                                 copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968);
56001                             }
56002                             break;
56003                         case 201:
56004                             var funcName = location.name;
56005                             if (funcName) {
56006                                 copySymbol(location.symbol, meaning);
56007                             }
56008                             break;
56009                     }
56010                     if (ts.introducesArgumentsExoticObject(location)) {
56011                         copySymbol(argumentsSymbol, meaning);
56012                     }
56013                     isStatic = ts.hasModifier(location, 32);
56014                     location = location.parent;
56015                 }
56016                 copySymbols(globals, meaning);
56017             }
56018             function copySymbol(symbol, meaning) {
56019                 if (ts.getCombinedLocalAndExportSymbolFlags(symbol) & meaning) {
56020                     var id = symbol.escapedName;
56021                     if (!symbols.has(id)) {
56022                         symbols.set(id, symbol);
56023                     }
56024                 }
56025             }
56026             function copySymbols(source, meaning) {
56027                 if (meaning) {
56028                     source.forEach(function (symbol) {
56029                         copySymbol(symbol, meaning);
56030                     });
56031                 }
56032             }
56033         }
56034         function isTypeDeclarationName(name) {
56035             return name.kind === 75 &&
56036                 isTypeDeclaration(name.parent) &&
56037                 name.parent.name === name;
56038         }
56039         function isTypeDeclaration(node) {
56040             switch (node.kind) {
56041                 case 155:
56042                 case 245:
56043                 case 246:
56044                 case 247:
56045                 case 248:
56046                     return true;
56047                 case 255:
56048                     return node.isTypeOnly;
56049                 case 258:
56050                 case 263:
56051                     return node.parent.parent.isTypeOnly;
56052                 default:
56053                     return false;
56054             }
56055         }
56056         function isTypeReferenceIdentifier(node) {
56057             while (node.parent.kind === 153) {
56058                 node = node.parent;
56059             }
56060             return node.parent.kind === 169;
56061         }
56062         function isHeritageClauseElementIdentifier(node) {
56063             while (node.parent.kind === 194) {
56064                 node = node.parent;
56065             }
56066             return node.parent.kind === 216;
56067         }
56068         function forEachEnclosingClass(node, callback) {
56069             var result;
56070             while (true) {
56071                 node = ts.getContainingClass(node);
56072                 if (!node)
56073                     break;
56074                 if (result = callback(node))
56075                     break;
56076             }
56077             return result;
56078         }
56079         function isNodeUsedDuringClassInitialization(node) {
56080             return !!ts.findAncestor(node, function (element) {
56081                 if (ts.isConstructorDeclaration(element) && ts.nodeIsPresent(element.body) || ts.isPropertyDeclaration(element)) {
56082                     return true;
56083                 }
56084                 else if (ts.isClassLike(element) || ts.isFunctionLikeDeclaration(element)) {
56085                     return "quit";
56086                 }
56087                 return false;
56088             });
56089         }
56090         function isNodeWithinClass(node, classDeclaration) {
56091             return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; });
56092         }
56093         function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) {
56094             while (nodeOnRightSide.parent.kind === 153) {
56095                 nodeOnRightSide = nodeOnRightSide.parent;
56096             }
56097             if (nodeOnRightSide.parent.kind === 253) {
56098                 return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined;
56099             }
56100             if (nodeOnRightSide.parent.kind === 259) {
56101                 return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined;
56102             }
56103             return undefined;
56104         }
56105         function isInRightSideOfImportOrExportAssignment(node) {
56106             return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined;
56107         }
56108         function getSpecialPropertyAssignmentSymbolFromEntityName(entityName) {
56109             var specialPropertyAssignmentKind = ts.getAssignmentDeclarationKind(entityName.parent.parent);
56110             switch (specialPropertyAssignmentKind) {
56111                 case 1:
56112                 case 3:
56113                     return getSymbolOfNode(entityName.parent);
56114                 case 4:
56115                 case 2:
56116                 case 5:
56117                     return getSymbolOfNode(entityName.parent.parent);
56118             }
56119         }
56120         function isImportTypeQualifierPart(node) {
56121             var parent = node.parent;
56122             while (ts.isQualifiedName(parent)) {
56123                 node = parent;
56124                 parent = parent.parent;
56125             }
56126             if (parent && parent.kind === 188 && parent.qualifier === node) {
56127                 return parent;
56128             }
56129             return undefined;
56130         }
56131         function getSymbolOfNameOrPropertyAccessExpression(name) {
56132             if (ts.isDeclarationName(name)) {
56133                 return getSymbolOfNode(name.parent);
56134             }
56135             if (ts.isInJSFile(name) &&
56136                 name.parent.kind === 194 &&
56137                 name.parent === name.parent.parent.left) {
56138                 if (!ts.isPrivateIdentifier(name)) {
56139                     var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(name);
56140                     if (specialPropertyAssignmentSymbol) {
56141                         return specialPropertyAssignmentSymbol;
56142                     }
56143                 }
56144             }
56145             if (name.parent.kind === 259 && ts.isEntityNameExpression(name)) {
56146                 var success = resolveEntityName(name, 111551 | 788968 | 1920 | 2097152, true);
56147                 if (success && success !== unknownSymbol) {
56148                     return success;
56149                 }
56150             }
56151             else if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name) && isInRightSideOfImportOrExportAssignment(name)) {
56152                 var importEqualsDeclaration = ts.getAncestor(name, 253);
56153                 ts.Debug.assert(importEqualsDeclaration !== undefined);
56154                 return getSymbolOfPartOfRightHandSideOfImportEquals(name, true);
56155             }
56156             if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name)) {
56157                 var possibleImportNode = isImportTypeQualifierPart(name);
56158                 if (possibleImportNode) {
56159                     getTypeFromTypeNode(possibleImportNode);
56160                     var sym = getNodeLinks(name).resolvedSymbol;
56161                     return sym === unknownSymbol ? undefined : sym;
56162                 }
56163             }
56164             while (ts.isRightSideOfQualifiedNameOrPropertyAccess(name)) {
56165                 name = name.parent;
56166             }
56167             if (isHeritageClauseElementIdentifier(name)) {
56168                 var meaning = 0;
56169                 if (name.parent.kind === 216) {
56170                     meaning = 788968;
56171                     if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) {
56172                         meaning |= 111551;
56173                     }
56174                 }
56175                 else {
56176                     meaning = 1920;
56177                 }
56178                 meaning |= 2097152;
56179                 var entityNameSymbol = ts.isEntityNameExpression(name) ? resolveEntityName(name, meaning) : undefined;
56180                 if (entityNameSymbol) {
56181                     return entityNameSymbol;
56182                 }
56183             }
56184             if (name.parent.kind === 317) {
56185                 return ts.getParameterSymbolFromJSDoc(name.parent);
56186             }
56187             if (name.parent.kind === 155 && name.parent.parent.kind === 321) {
56188                 ts.Debug.assert(!ts.isInJSFile(name));
56189                 var typeParameter = ts.getTypeParameterFromJsDoc(name.parent);
56190                 return typeParameter && typeParameter.symbol;
56191             }
56192             if (ts.isExpressionNode(name)) {
56193                 if (ts.nodeIsMissing(name)) {
56194                     return undefined;
56195                 }
56196                 if (name.kind === 75) {
56197                     if (ts.isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) {
56198                         var symbol = getIntrinsicTagSymbol(name.parent);
56199                         return symbol === unknownSymbol ? undefined : symbol;
56200                     }
56201                     return resolveEntityName(name, 111551, false, true);
56202                 }
56203                 else if (name.kind === 194 || name.kind === 153) {
56204                     var links = getNodeLinks(name);
56205                     if (links.resolvedSymbol) {
56206                         return links.resolvedSymbol;
56207                     }
56208                     if (name.kind === 194) {
56209                         checkPropertyAccessExpression(name);
56210                     }
56211                     else {
56212                         checkQualifiedName(name);
56213                     }
56214                     return links.resolvedSymbol;
56215                 }
56216             }
56217             else if (isTypeReferenceIdentifier(name)) {
56218                 var meaning = name.parent.kind === 169 ? 788968 : 1920;
56219                 return resolveEntityName(name, meaning, false, true);
56220             }
56221             if (name.parent.kind === 168) {
56222                 return resolveEntityName(name, 1);
56223             }
56224             return undefined;
56225         }
56226         function getSymbolAtLocation(node, ignoreErrors) {
56227             if (node.kind === 290) {
56228                 return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined;
56229             }
56230             var parent = node.parent;
56231             var grandParent = parent.parent;
56232             if (node.flags & 16777216) {
56233                 return undefined;
56234             }
56235             if (isDeclarationNameOrImportPropertyName(node)) {
56236                 var parentSymbol = getSymbolOfNode(parent);
56237                 return ts.isImportOrExportSpecifier(node.parent) && node.parent.propertyName === node
56238                     ? getImmediateAliasedSymbol(parentSymbol)
56239                     : parentSymbol;
56240             }
56241             else if (ts.isLiteralComputedPropertyDeclarationName(node)) {
56242                 return getSymbolOfNode(parent.parent);
56243             }
56244             if (node.kind === 75) {
56245                 if (isInRightSideOfImportOrExportAssignment(node)) {
56246                     return getSymbolOfNameOrPropertyAccessExpression(node);
56247                 }
56248                 else if (parent.kind === 191 &&
56249                     grandParent.kind === 189 &&
56250                     node === parent.propertyName) {
56251                     var typeOfPattern = getTypeOfNode(grandParent);
56252                     var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText);
56253                     if (propertyDeclaration) {
56254                         return propertyDeclaration;
56255                     }
56256                 }
56257             }
56258             switch (node.kind) {
56259                 case 75:
56260                 case 76:
56261                 case 194:
56262                 case 153:
56263                     return getSymbolOfNameOrPropertyAccessExpression(node);
56264                 case 104:
56265                     var container = ts.getThisContainer(node, false);
56266                     if (ts.isFunctionLike(container)) {
56267                         var sig = getSignatureFromDeclaration(container);
56268                         if (sig.thisParameter) {
56269                             return sig.thisParameter;
56270                         }
56271                     }
56272                     if (ts.isInExpressionContext(node)) {
56273                         return checkExpression(node).symbol;
56274                     }
56275                 case 183:
56276                     return getTypeFromThisTypeNode(node).symbol;
56277                 case 102:
56278                     return checkExpression(node).symbol;
56279                 case 129:
56280                     var constructorDeclaration = node.parent;
56281                     if (constructorDeclaration && constructorDeclaration.kind === 162) {
56282                         return constructorDeclaration.parent.symbol;
56283                     }
56284                     return undefined;
56285                 case 10:
56286                 case 14:
56287                     if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) ||
56288                         ((node.parent.kind === 254 || node.parent.kind === 260) && node.parent.moduleSpecifier === node) ||
56289                         ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, false)) || ts.isImportCall(node.parent)) ||
56290                         (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) {
56291                         return resolveExternalModuleName(node, node, ignoreErrors);
56292                     }
56293                     if (ts.isCallExpression(parent) && ts.isBindableObjectDefinePropertyCall(parent) && parent.arguments[1] === node) {
56294                         return getSymbolOfNode(parent);
56295                     }
56296                 case 8:
56297                     var objectType = ts.isElementAccessExpression(parent)
56298                         ? parent.argumentExpression === node ? getTypeOfExpression(parent.expression) : undefined
56299                         : ts.isLiteralTypeNode(parent) && ts.isIndexedAccessTypeNode(grandParent)
56300                             ? getTypeFromTypeNode(grandParent.objectType)
56301                             : undefined;
56302                     return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text));
56303                 case 84:
56304                 case 94:
56305                 case 38:
56306                 case 80:
56307                     return getSymbolOfNode(node.parent);
56308                 case 188:
56309                     return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined;
56310                 case 89:
56311                     return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined;
56312                 default:
56313                     return undefined;
56314             }
56315         }
56316         function getShorthandAssignmentValueSymbol(location) {
56317             if (location && location.kind === 282) {
56318                 return resolveEntityName(location.name, 111551 | 2097152);
56319             }
56320             return undefined;
56321         }
56322         function getExportSpecifierLocalTargetSymbol(node) {
56323             return node.parent.parent.moduleSpecifier ?
56324                 getExternalModuleMember(node.parent.parent, node) :
56325                 resolveEntityName(node.propertyName || node.name, 111551 | 788968 | 1920 | 2097152);
56326         }
56327         function getTypeOfNode(node) {
56328             if (node.flags & 16777216) {
56329                 return errorType;
56330             }
56331             var classDecl = ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node);
56332             var classType = classDecl && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(classDecl.class));
56333             if (ts.isPartOfTypeNode(node)) {
56334                 var typeFromTypeNode = getTypeFromTypeNode(node);
56335                 return classType ? getTypeWithThisArgument(typeFromTypeNode, classType.thisType) : typeFromTypeNode;
56336             }
56337             if (ts.isExpressionNode(node)) {
56338                 return getRegularTypeOfExpression(node);
56339             }
56340             if (classType && !classDecl.isImplements) {
56341                 var baseType = ts.firstOrUndefined(getBaseTypes(classType));
56342                 return baseType ? getTypeWithThisArgument(baseType, classType.thisType) : errorType;
56343             }
56344             if (isTypeDeclaration(node)) {
56345                 var symbol = getSymbolOfNode(node);
56346                 return getDeclaredTypeOfSymbol(symbol);
56347             }
56348             if (isTypeDeclarationName(node)) {
56349                 var symbol = getSymbolAtLocation(node);
56350                 return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType;
56351             }
56352             if (ts.isDeclaration(node)) {
56353                 var symbol = getSymbolOfNode(node);
56354                 return getTypeOfSymbol(symbol);
56355             }
56356             if (isDeclarationNameOrImportPropertyName(node)) {
56357                 var symbol = getSymbolAtLocation(node);
56358                 if (symbol) {
56359                     return getTypeOfSymbol(symbol);
56360                 }
56361                 return errorType;
56362             }
56363             if (ts.isBindingPattern(node)) {
56364                 return getTypeForVariableLikeDeclaration(node.parent, true) || errorType;
56365             }
56366             if (isInRightSideOfImportOrExportAssignment(node)) {
56367                 var symbol = getSymbolAtLocation(node);
56368                 if (symbol) {
56369                     var declaredType = getDeclaredTypeOfSymbol(symbol);
56370                     return declaredType !== errorType ? declaredType : getTypeOfSymbol(symbol);
56371                 }
56372             }
56373             return errorType;
56374         }
56375         function getTypeOfAssignmentPattern(expr) {
56376             ts.Debug.assert(expr.kind === 193 || expr.kind === 192);
56377             if (expr.parent.kind === 232) {
56378                 var iteratedType = checkRightHandSideOfForOf(expr.parent);
56379                 return checkDestructuringAssignment(expr, iteratedType || errorType);
56380             }
56381             if (expr.parent.kind === 209) {
56382                 var iteratedType = getTypeOfExpression(expr.parent.right);
56383                 return checkDestructuringAssignment(expr, iteratedType || errorType);
56384             }
56385             if (expr.parent.kind === 281) {
56386                 var node_4 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
56387                 var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_4) || errorType;
56388                 var propertyIndex = ts.indexOfNode(node_4.properties, expr.parent);
56389                 return checkObjectLiteralDestructuringPropertyAssignment(node_4, typeOfParentObjectLiteral, propertyIndex);
56390             }
56391             var node = ts.cast(expr.parent, ts.isArrayLiteralExpression);
56392             var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType;
56393             var elementType = checkIteratedTypeOrElementType(65, typeOfArrayLiteral, undefinedType, expr.parent) || errorType;
56394             return checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, node.elements.indexOf(expr), elementType);
56395         }
56396         function getPropertySymbolOfDestructuringAssignment(location) {
56397             var typeOfObjectLiteral = getTypeOfAssignmentPattern(ts.cast(location.parent.parent, ts.isAssignmentPattern));
56398             return typeOfObjectLiteral && getPropertyOfType(typeOfObjectLiteral, location.escapedText);
56399         }
56400         function getRegularTypeOfExpression(expr) {
56401             if (ts.isRightSideOfQualifiedNameOrPropertyAccess(expr)) {
56402                 expr = expr.parent;
56403             }
56404             return getRegularTypeOfLiteralType(getTypeOfExpression(expr));
56405         }
56406         function getParentTypeOfClassElement(node) {
56407             var classSymbol = getSymbolOfNode(node.parent);
56408             return ts.hasModifier(node, 32)
56409                 ? getTypeOfSymbol(classSymbol)
56410                 : getDeclaredTypeOfSymbol(classSymbol);
56411         }
56412         function getClassElementPropertyKeyType(element) {
56413             var name = element.name;
56414             switch (name.kind) {
56415                 case 75:
56416                     return getLiteralType(ts.idText(name));
56417                 case 8:
56418                 case 10:
56419                     return getLiteralType(name.text);
56420                 case 154:
56421                     var nameType = checkComputedPropertyName(name);
56422                     return isTypeAssignableToKind(nameType, 12288) ? nameType : stringType;
56423                 default:
56424                     return ts.Debug.fail("Unsupported property name.");
56425             }
56426         }
56427         function getAugmentedPropertiesOfType(type) {
56428             type = getApparentType(type);
56429             var propsByName = ts.createSymbolTable(getPropertiesOfType(type));
56430             var functionType = getSignaturesOfType(type, 0).length ? globalCallableFunctionType :
56431                 getSignaturesOfType(type, 1).length ? globalNewableFunctionType :
56432                     undefined;
56433             if (functionType) {
56434                 ts.forEach(getPropertiesOfType(functionType), function (p) {
56435                     if (!propsByName.has(p.escapedName)) {
56436                         propsByName.set(p.escapedName, p);
56437                     }
56438                 });
56439             }
56440             return getNamedMembers(propsByName);
56441         }
56442         function typeHasCallOrConstructSignatures(type) {
56443             return ts.typeHasCallOrConstructSignatures(type, checker);
56444         }
56445         function getRootSymbols(symbol) {
56446             var roots = getImmediateRootSymbols(symbol);
56447             return roots ? ts.flatMap(roots, getRootSymbols) : [symbol];
56448         }
56449         function getImmediateRootSymbols(symbol) {
56450             if (ts.getCheckFlags(symbol) & 6) {
56451                 return ts.mapDefined(getSymbolLinks(symbol).containingType.types, function (type) { return getPropertyOfType(type, symbol.escapedName); });
56452             }
56453             else if (symbol.flags & 33554432) {
56454                 var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin;
56455                 return leftSpread ? [leftSpread, rightSpread]
56456                     : syntheticOrigin ? [syntheticOrigin]
56457                         : ts.singleElementArray(tryGetAliasTarget(symbol));
56458             }
56459             return undefined;
56460         }
56461         function tryGetAliasTarget(symbol) {
56462             var target;
56463             var next = symbol;
56464             while (next = getSymbolLinks(next).target) {
56465                 target = next;
56466             }
56467             return target;
56468         }
56469         function isArgumentsLocalBinding(nodeIn) {
56470             if (!ts.isGeneratedIdentifier(nodeIn)) {
56471                 var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
56472                 if (node) {
56473                     var isPropertyName_1 = node.parent.kind === 194 && node.parent.name === node;
56474                     return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol;
56475                 }
56476             }
56477             return false;
56478         }
56479         function moduleExportsSomeValue(moduleReferenceExpression) {
56480             var moduleSymbol = resolveExternalModuleName(moduleReferenceExpression.parent, moduleReferenceExpression);
56481             if (!moduleSymbol || ts.isShorthandAmbientModuleSymbol(moduleSymbol)) {
56482                 return true;
56483             }
56484             var hasExportAssignment = hasExportAssignmentSymbol(moduleSymbol);
56485             moduleSymbol = resolveExternalModuleSymbol(moduleSymbol);
56486             var symbolLinks = getSymbolLinks(moduleSymbol);
56487             if (symbolLinks.exportsSomeValue === undefined) {
56488                 symbolLinks.exportsSomeValue = hasExportAssignment
56489                     ? !!(moduleSymbol.flags & 111551)
56490                     : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue);
56491             }
56492             return symbolLinks.exportsSomeValue;
56493             function isValue(s) {
56494                 s = resolveSymbol(s);
56495                 return s && !!(s.flags & 111551);
56496             }
56497         }
56498         function isNameOfModuleOrEnumDeclaration(node) {
56499             return ts.isModuleOrEnumDeclaration(node.parent) && node === node.parent.name;
56500         }
56501         function getReferencedExportContainer(nodeIn, prefixLocals) {
56502             var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
56503             if (node) {
56504                 var symbol = getReferencedValueSymbol(node, isNameOfModuleOrEnumDeclaration(node));
56505                 if (symbol) {
56506                     if (symbol.flags & 1048576) {
56507                         var exportSymbol = getMergedSymbol(symbol.exportSymbol);
56508                         if (!prefixLocals && exportSymbol.flags & 944 && !(exportSymbol.flags & 3)) {
56509                             return undefined;
56510                         }
56511                         symbol = exportSymbol;
56512                     }
56513                     var parentSymbol_1 = getParentOfSymbol(symbol);
56514                     if (parentSymbol_1) {
56515                         if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 290) {
56516                             var symbolFile = parentSymbol_1.valueDeclaration;
56517                             var referenceFile = ts.getSourceFileOfNode(node);
56518                             var symbolIsUmdExport = symbolFile !== referenceFile;
56519                             return symbolIsUmdExport ? undefined : symbolFile;
56520                         }
56521                         return ts.findAncestor(node.parent, function (n) { return ts.isModuleOrEnumDeclaration(n) && getSymbolOfNode(n) === parentSymbol_1; });
56522                     }
56523                 }
56524             }
56525         }
56526         function getReferencedImportDeclaration(nodeIn) {
56527             var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
56528             if (node) {
56529                 var symbol = getReferencedValueSymbol(node);
56530                 if (isNonLocalAlias(symbol, 111551) && !getTypeOnlyAliasDeclaration(symbol)) {
56531                     return getDeclarationOfAliasSymbol(symbol);
56532                 }
56533             }
56534             return undefined;
56535         }
56536         function isSymbolOfDestructuredElementOfCatchBinding(symbol) {
56537             return ts.isBindingElement(symbol.valueDeclaration)
56538                 && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 280;
56539         }
56540         function isSymbolOfDeclarationWithCollidingName(symbol) {
56541             if (symbol.flags & 418 && !ts.isSourceFile(symbol.valueDeclaration)) {
56542                 var links = getSymbolLinks(symbol);
56543                 if (links.isDeclarationWithCollidingName === undefined) {
56544                     var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration);
56545                     if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) {
56546                         var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration);
56547                         if (resolveName(container.parent, symbol.escapedName, 111551, undefined, undefined, false)) {
56548                             links.isDeclarationWithCollidingName = true;
56549                         }
56550                         else if (nodeLinks_1.flags & 262144) {
56551                             var isDeclaredInLoop = nodeLinks_1.flags & 524288;
56552                             var inLoopInitializer = ts.isIterationStatement(container, false);
56553                             var inLoopBodyBlock = container.kind === 223 && ts.isIterationStatement(container.parent, false);
56554                             links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock));
56555                         }
56556                         else {
56557                             links.isDeclarationWithCollidingName = false;
56558                         }
56559                     }
56560                 }
56561                 return links.isDeclarationWithCollidingName;
56562             }
56563             return false;
56564         }
56565         function getReferencedDeclarationWithCollidingName(nodeIn) {
56566             if (!ts.isGeneratedIdentifier(nodeIn)) {
56567                 var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
56568                 if (node) {
56569                     var symbol = getReferencedValueSymbol(node);
56570                     if (symbol && isSymbolOfDeclarationWithCollidingName(symbol)) {
56571                         return symbol.valueDeclaration;
56572                     }
56573                 }
56574             }
56575             return undefined;
56576         }
56577         function isDeclarationWithCollidingName(nodeIn) {
56578             var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration);
56579             if (node) {
56580                 var symbol = getSymbolOfNode(node);
56581                 if (symbol) {
56582                     return isSymbolOfDeclarationWithCollidingName(symbol);
56583                 }
56584             }
56585             return false;
56586         }
56587         function isValueAliasDeclaration(node) {
56588             switch (node.kind) {
56589                 case 253:
56590                     return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol);
56591                 case 255:
56592                 case 256:
56593                 case 258:
56594                 case 263:
56595                     var symbol = getSymbolOfNode(node) || unknownSymbol;
56596                     return isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol);
56597                 case 260:
56598                     var exportClause = node.exportClause;
56599                     return !!exportClause && (ts.isNamespaceExport(exportClause) ||
56600                         ts.some(exportClause.elements, isValueAliasDeclaration));
56601                 case 259:
56602                     return node.expression && node.expression.kind === 75 ?
56603                         isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) :
56604                         true;
56605             }
56606             return false;
56607         }
56608         function isTopLevelValueImportEqualsWithEntityName(nodeIn) {
56609             var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration);
56610             if (node === undefined || node.parent.kind !== 290 || !ts.isInternalModuleImportEqualsDeclaration(node)) {
56611                 return false;
56612             }
56613             var isValue = isAliasResolvedToValue(getSymbolOfNode(node));
56614             return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference);
56615         }
56616         function isAliasResolvedToValue(symbol) {
56617             var target = resolveAlias(symbol);
56618             if (target === unknownSymbol) {
56619                 return true;
56620             }
56621             return !!(target.flags & 111551) &&
56622                 (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target));
56623         }
56624         function isConstEnumOrConstEnumOnlyModule(s) {
56625             return isConstEnumSymbol(s) || !!s.constEnumOnlyModule;
56626         }
56627         function isReferencedAliasDeclaration(node, checkChildren) {
56628             if (isAliasSymbolDeclaration(node)) {
56629                 var symbol = getSymbolOfNode(node);
56630                 if (symbol && getSymbolLinks(symbol).referenced) {
56631                     return true;
56632                 }
56633                 var target = getSymbolLinks(symbol).target;
56634                 if (target && ts.getModifierFlags(node) & 1 &&
56635                     target.flags & 111551 &&
56636                     (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) {
56637                     return true;
56638                 }
56639             }
56640             if (checkChildren) {
56641                 return !!ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); });
56642             }
56643             return false;
56644         }
56645         function isImplementationOfOverload(node) {
56646             if (ts.nodeIsPresent(node.body)) {
56647                 if (ts.isGetAccessor(node) || ts.isSetAccessor(node))
56648                     return false;
56649                 var symbol = getSymbolOfNode(node);
56650                 var signaturesOfSymbol = getSignaturesOfSymbol(symbol);
56651                 return signaturesOfSymbol.length > 1 ||
56652                     (signaturesOfSymbol.length === 1 && signaturesOfSymbol[0].declaration !== node);
56653             }
56654             return false;
56655         }
56656         function isRequiredInitializedParameter(parameter) {
56657             return !!strictNullChecks &&
56658                 !isOptionalParameter(parameter) &&
56659                 !ts.isJSDocParameterTag(parameter) &&
56660                 !!parameter.initializer &&
56661                 !ts.hasModifier(parameter, 92);
56662         }
56663         function isOptionalUninitializedParameterProperty(parameter) {
56664             return strictNullChecks &&
56665                 isOptionalParameter(parameter) &&
56666                 !parameter.initializer &&
56667                 ts.hasModifier(parameter, 92);
56668         }
56669         function isExpandoFunctionDeclaration(node) {
56670             var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
56671             if (!declaration) {
56672                 return false;
56673             }
56674             var symbol = getSymbolOfNode(declaration);
56675             if (!symbol || !(symbol.flags & 16)) {
56676                 return false;
56677             }
56678             return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); });
56679         }
56680         function getPropertiesOfContainerFunction(node) {
56681             var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
56682             if (!declaration) {
56683                 return ts.emptyArray;
56684             }
56685             var symbol = getSymbolOfNode(declaration);
56686             return symbol && getPropertiesOfType(getTypeOfSymbol(symbol)) || ts.emptyArray;
56687         }
56688         function getNodeCheckFlags(node) {
56689             return getNodeLinks(node).flags || 0;
56690         }
56691         function getEnumMemberValue(node) {
56692             computeEnumMemberValues(node.parent);
56693             return getNodeLinks(node).enumMemberValue;
56694         }
56695         function canHaveConstantValue(node) {
56696             switch (node.kind) {
56697                 case 284:
56698                 case 194:
56699                 case 195:
56700                     return true;
56701             }
56702             return false;
56703         }
56704         function getConstantValue(node) {
56705             if (node.kind === 284) {
56706                 return getEnumMemberValue(node);
56707             }
56708             var symbol = getNodeLinks(node).resolvedSymbol;
56709             if (symbol && (symbol.flags & 8)) {
56710                 var member = symbol.valueDeclaration;
56711                 if (ts.isEnumConst(member.parent)) {
56712                     return getEnumMemberValue(member);
56713                 }
56714             }
56715             return undefined;
56716         }
56717         function isFunctionType(type) {
56718             return !!(type.flags & 524288) && getSignaturesOfType(type, 0).length > 0;
56719         }
56720         function getTypeReferenceSerializationKind(typeNameIn, location) {
56721             var typeName = ts.getParseTreeNode(typeNameIn, ts.isEntityName);
56722             if (!typeName)
56723                 return ts.TypeReferenceSerializationKind.Unknown;
56724             if (location) {
56725                 location = ts.getParseTreeNode(location);
56726                 if (!location)
56727                     return ts.TypeReferenceSerializationKind.Unknown;
56728             }
56729             var valueSymbol = resolveEntityName(typeName, 111551, true, false, location);
56730             var typeSymbol = resolveEntityName(typeName, 788968, true, false, location);
56731             if (valueSymbol && valueSymbol === typeSymbol) {
56732                 var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(false);
56733                 if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) {
56734                     return ts.TypeReferenceSerializationKind.Promise;
56735                 }
56736                 var constructorType = getTypeOfSymbol(valueSymbol);
56737                 if (constructorType && isConstructorType(constructorType)) {
56738                     return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue;
56739                 }
56740             }
56741             if (!typeSymbol) {
56742                 return ts.TypeReferenceSerializationKind.Unknown;
56743             }
56744             var type = getDeclaredTypeOfSymbol(typeSymbol);
56745             if (type === errorType) {
56746                 return ts.TypeReferenceSerializationKind.Unknown;
56747             }
56748             else if (type.flags & 3) {
56749                 return ts.TypeReferenceSerializationKind.ObjectType;
56750             }
56751             else if (isTypeAssignableToKind(type, 16384 | 98304 | 131072)) {
56752                 return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType;
56753             }
56754             else if (isTypeAssignableToKind(type, 528)) {
56755                 return ts.TypeReferenceSerializationKind.BooleanType;
56756             }
56757             else if (isTypeAssignableToKind(type, 296)) {
56758                 return ts.TypeReferenceSerializationKind.NumberLikeType;
56759             }
56760             else if (isTypeAssignableToKind(type, 2112)) {
56761                 return ts.TypeReferenceSerializationKind.BigIntLikeType;
56762             }
56763             else if (isTypeAssignableToKind(type, 132)) {
56764                 return ts.TypeReferenceSerializationKind.StringLikeType;
56765             }
56766             else if (isTupleType(type)) {
56767                 return ts.TypeReferenceSerializationKind.ArrayLikeType;
56768             }
56769             else if (isTypeAssignableToKind(type, 12288)) {
56770                 return ts.TypeReferenceSerializationKind.ESSymbolType;
56771             }
56772             else if (isFunctionType(type)) {
56773                 return ts.TypeReferenceSerializationKind.TypeWithCallSignature;
56774             }
56775             else if (isArrayType(type)) {
56776                 return ts.TypeReferenceSerializationKind.ArrayLikeType;
56777             }
56778             else {
56779                 return ts.TypeReferenceSerializationKind.ObjectType;
56780             }
56781         }
56782         function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) {
56783             var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor);
56784             if (!declaration) {
56785                 return ts.createToken(125);
56786             }
56787             var symbol = getSymbolOfNode(declaration);
56788             var type = symbol && !(symbol.flags & (2048 | 131072))
56789                 ? getWidenedLiteralType(getTypeOfSymbol(symbol))
56790                 : errorType;
56791             if (type.flags & 8192 &&
56792                 type.symbol === symbol) {
56793                 flags |= 1048576;
56794             }
56795             if (addUndefined) {
56796                 type = getOptionalType(type);
56797             }
56798             return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024, tracker);
56799         }
56800         function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) {
56801             var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike);
56802             if (!signatureDeclaration) {
56803                 return ts.createToken(125);
56804             }
56805             var signature = getSignatureFromDeclaration(signatureDeclaration);
56806             return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024, tracker);
56807         }
56808         function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) {
56809             var expr = ts.getParseTreeNode(exprIn, ts.isExpression);
56810             if (!expr) {
56811                 return ts.createToken(125);
56812             }
56813             var type = getWidenedType(getRegularTypeOfExpression(expr));
56814             return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024, tracker);
56815         }
56816         function hasGlobalName(name) {
56817             return globals.has(ts.escapeLeadingUnderscores(name));
56818         }
56819         function getReferencedValueSymbol(reference, startInDeclarationContainer) {
56820             var resolvedSymbol = getNodeLinks(reference).resolvedSymbol;
56821             if (resolvedSymbol) {
56822                 return resolvedSymbol;
56823             }
56824             var location = reference;
56825             if (startInDeclarationContainer) {
56826                 var parent = reference.parent;
56827                 if (ts.isDeclaration(parent) && reference === parent.name) {
56828                     location = getDeclarationContainer(parent);
56829                 }
56830             }
56831             return resolveName(location, reference.escapedText, 111551 | 1048576 | 2097152, undefined, undefined, true);
56832         }
56833         function getReferencedValueDeclaration(referenceIn) {
56834             if (!ts.isGeneratedIdentifier(referenceIn)) {
56835                 var reference = ts.getParseTreeNode(referenceIn, ts.isIdentifier);
56836                 if (reference) {
56837                     var symbol = getReferencedValueSymbol(reference);
56838                     if (symbol) {
56839                         return getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration;
56840                     }
56841                 }
56842             }
56843             return undefined;
56844         }
56845         function isLiteralConstDeclaration(node) {
56846             if (ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) {
56847                 return isFreshLiteralType(getTypeOfSymbol(getSymbolOfNode(node)));
56848             }
56849             return false;
56850         }
56851         function literalTypeToNode(type, enclosing, tracker) {
56852             var enumResult = type.flags & 1024 ? nodeBuilder.symbolToExpression(type.symbol, 111551, enclosing, undefined, tracker)
56853                 : type === trueType ? ts.createTrue() : type === falseType && ts.createFalse();
56854             return enumResult || ts.createLiteral(type.value);
56855         }
56856         function createLiteralConstValue(node, tracker) {
56857             var type = getTypeOfSymbol(getSymbolOfNode(node));
56858             return literalTypeToNode(type, node, tracker);
56859         }
56860         function getJsxFactoryEntity(location) {
56861             return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity;
56862         }
56863         function createResolver() {
56864             var resolvedTypeReferenceDirectives = host.getResolvedTypeReferenceDirectives();
56865             var fileToDirective;
56866             if (resolvedTypeReferenceDirectives) {
56867                 fileToDirective = ts.createMap();
56868                 resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) {
56869                     if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
56870                         return;
56871                     }
56872                     var file = host.getSourceFile(resolvedDirective.resolvedFileName);
56873                     if (file) {
56874                         addReferencedFilesToTypeDirective(file, key);
56875                     }
56876                 });
56877             }
56878             return {
56879                 getReferencedExportContainer: getReferencedExportContainer,
56880                 getReferencedImportDeclaration: getReferencedImportDeclaration,
56881                 getReferencedDeclarationWithCollidingName: getReferencedDeclarationWithCollidingName,
56882                 isDeclarationWithCollidingName: isDeclarationWithCollidingName,
56883                 isValueAliasDeclaration: function (node) {
56884                     node = ts.getParseTreeNode(node);
56885                     return node ? isValueAliasDeclaration(node) : true;
56886                 },
56887                 hasGlobalName: hasGlobalName,
56888                 isReferencedAliasDeclaration: function (node, checkChildren) {
56889                     node = ts.getParseTreeNode(node);
56890                     return node ? isReferencedAliasDeclaration(node, checkChildren) : true;
56891                 },
56892                 getNodeCheckFlags: function (node) {
56893                     node = ts.getParseTreeNode(node);
56894                     return node ? getNodeCheckFlags(node) : 0;
56895                 },
56896                 isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName,
56897                 isDeclarationVisible: isDeclarationVisible,
56898                 isImplementationOfOverload: isImplementationOfOverload,
56899                 isRequiredInitializedParameter: isRequiredInitializedParameter,
56900                 isOptionalUninitializedParameterProperty: isOptionalUninitializedParameterProperty,
56901                 isExpandoFunctionDeclaration: isExpandoFunctionDeclaration,
56902                 getPropertiesOfContainerFunction: getPropertiesOfContainerFunction,
56903                 createTypeOfDeclaration: createTypeOfDeclaration,
56904                 createReturnTypeOfSignatureDeclaration: createReturnTypeOfSignatureDeclaration,
56905                 createTypeOfExpression: createTypeOfExpression,
56906                 createLiteralConstValue: createLiteralConstValue,
56907                 isSymbolAccessible: isSymbolAccessible,
56908                 isEntityNameVisible: isEntityNameVisible,
56909                 getConstantValue: function (nodeIn) {
56910                     var node = ts.getParseTreeNode(nodeIn, canHaveConstantValue);
56911                     return node ? getConstantValue(node) : undefined;
56912                 },
56913                 collectLinkedAliases: collectLinkedAliases,
56914                 getReferencedValueDeclaration: getReferencedValueDeclaration,
56915                 getTypeReferenceSerializationKind: getTypeReferenceSerializationKind,
56916                 isOptionalParameter: isOptionalParameter,
56917                 moduleExportsSomeValue: moduleExportsSomeValue,
56918                 isArgumentsLocalBinding: isArgumentsLocalBinding,
56919                 getExternalModuleFileFromDeclaration: getExternalModuleFileFromDeclaration,
56920                 getTypeReferenceDirectivesForEntityName: getTypeReferenceDirectivesForEntityName,
56921                 getTypeReferenceDirectivesForSymbol: getTypeReferenceDirectivesForSymbol,
56922                 isLiteralConstDeclaration: isLiteralConstDeclaration,
56923                 isLateBound: function (nodeIn) {
56924                     var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration);
56925                     var symbol = node && getSymbolOfNode(node);
56926                     return !!(symbol && ts.getCheckFlags(symbol) & 4096);
56927                 },
56928                 getJsxFactoryEntity: getJsxFactoryEntity,
56929                 getAllAccessorDeclarations: function (accessor) {
56930                     accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration);
56931                     var otherKind = accessor.kind === 164 ? 163 : 164;
56932                     var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind);
56933                     var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor;
56934                     var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor;
56935                     var setAccessor = accessor.kind === 164 ? accessor : otherAccessor;
56936                     var getAccessor = accessor.kind === 163 ? accessor : otherAccessor;
56937                     return {
56938                         firstAccessor: firstAccessor,
56939                         secondAccessor: secondAccessor,
56940                         setAccessor: setAccessor,
56941                         getAccessor: getAccessor
56942                     };
56943                 },
56944                 getSymbolOfExternalModuleSpecifier: function (moduleName) { return resolveExternalModuleNameWorker(moduleName, moduleName, undefined); },
56945                 isBindingCapturedByNode: function (node, decl) {
56946                     var parseNode = ts.getParseTreeNode(node);
56947                     var parseDecl = ts.getParseTreeNode(decl);
56948                     return !!parseNode && !!parseDecl && (ts.isVariableDeclaration(parseDecl) || ts.isBindingElement(parseDecl)) && isBindingCapturedByNode(parseNode, parseDecl);
56949                 },
56950                 getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) {
56951                     var n = ts.getParseTreeNode(node);
56952                     ts.Debug.assert(n && n.kind === 290, "Non-sourcefile node passed into getDeclarationsForSourceFile");
56953                     var sym = getSymbolOfNode(node);
56954                     if (!sym) {
56955                         return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled);
56956                     }
56957                     return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled);
56958                 },
56959                 isImportRequiredByAugmentation: isImportRequiredByAugmentation,
56960             };
56961             function isImportRequiredByAugmentation(node) {
56962                 var file = ts.getSourceFileOfNode(node);
56963                 if (!file.symbol)
56964                     return false;
56965                 var importTarget = getExternalModuleFileFromDeclaration(node);
56966                 if (!importTarget)
56967                     return false;
56968                 if (importTarget === file)
56969                     return false;
56970                 var exports = getExportsOfModule(file.symbol);
56971                 for (var _i = 0, _a = ts.arrayFrom(exports.values()); _i < _a.length; _i++) {
56972                     var s = _a[_i];
56973                     if (s.mergeId) {
56974                         var merged = getMergedSymbol(s);
56975                         for (var _b = 0, _c = merged.declarations; _b < _c.length; _b++) {
56976                             var d = _c[_b];
56977                             var declFile = ts.getSourceFileOfNode(d);
56978                             if (declFile === importTarget) {
56979                                 return true;
56980                             }
56981                         }
56982                     }
56983                 }
56984                 return false;
56985             }
56986             function isInHeritageClause(node) {
56987                 return node.parent && node.parent.kind === 216 && node.parent.parent && node.parent.parent.kind === 279;
56988             }
56989             function getTypeReferenceDirectivesForEntityName(node) {
56990                 if (!fileToDirective) {
56991                     return undefined;
56992                 }
56993                 var meaning = 788968 | 1920;
56994                 if ((node.kind === 75 && isInTypeQuery(node)) || (node.kind === 194 && !isInHeritageClause(node))) {
56995                     meaning = 111551 | 1048576;
56996                 }
56997                 var symbol = resolveEntityName(node, meaning, true);
56998                 return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined;
56999             }
57000             function getTypeReferenceDirectivesForSymbol(symbol, meaning) {
57001                 if (!fileToDirective) {
57002                     return undefined;
57003                 }
57004                 if (!isSymbolFromTypeDeclarationFile(symbol)) {
57005                     return undefined;
57006                 }
57007                 var typeReferenceDirectives;
57008                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
57009                     var decl = _a[_i];
57010                     if (decl.symbol && decl.symbol.flags & meaning) {
57011                         var file = ts.getSourceFileOfNode(decl);
57012                         var typeReferenceDirective = fileToDirective.get(file.path);
57013                         if (typeReferenceDirective) {
57014                             (typeReferenceDirectives || (typeReferenceDirectives = [])).push(typeReferenceDirective);
57015                         }
57016                         else {
57017                             return undefined;
57018                         }
57019                     }
57020                 }
57021                 return typeReferenceDirectives;
57022             }
57023             function isSymbolFromTypeDeclarationFile(symbol) {
57024                 if (!symbol.declarations) {
57025                     return false;
57026                 }
57027                 var current = symbol;
57028                 while (true) {
57029                     var parent = getParentOfSymbol(current);
57030                     if (parent) {
57031                         current = parent;
57032                     }
57033                     else {
57034                         break;
57035                     }
57036                 }
57037                 if (current.valueDeclaration && current.valueDeclaration.kind === 290 && current.flags & 512) {
57038                     return false;
57039                 }
57040                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
57041                     var decl = _a[_i];
57042                     var file = ts.getSourceFileOfNode(decl);
57043                     if (fileToDirective.has(file.path)) {
57044                         return true;
57045                     }
57046                 }
57047                 return false;
57048             }
57049             function addReferencedFilesToTypeDirective(file, key) {
57050                 if (fileToDirective.has(file.path))
57051                     return;
57052                 fileToDirective.set(file.path, key);
57053                 for (var _i = 0, _a = file.referencedFiles; _i < _a.length; _i++) {
57054                     var fileName = _a[_i].fileName;
57055                     var resolvedFile = ts.resolveTripleslashReference(fileName, file.originalFileName);
57056                     var referencedFile = host.getSourceFile(resolvedFile);
57057                     if (referencedFile) {
57058                         addReferencedFilesToTypeDirective(referencedFile, key);
57059                     }
57060                 }
57061             }
57062         }
57063         function getExternalModuleFileFromDeclaration(declaration) {
57064             var specifier = declaration.kind === 249 ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration);
57065             var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, undefined);
57066             if (!moduleSymbol) {
57067                 return undefined;
57068             }
57069             return ts.getDeclarationOfKind(moduleSymbol, 290);
57070         }
57071         function initializeTypeChecker() {
57072             for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) {
57073                 var file = _a[_i];
57074                 ts.bindSourceFile(file, compilerOptions);
57075             }
57076             amalgamatedDuplicates = ts.createMap();
57077             var augmentations;
57078             for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) {
57079                 var file = _c[_b];
57080                 if (file.redirectInfo) {
57081                     continue;
57082                 }
57083                 if (!ts.isExternalOrCommonJsModule(file)) {
57084                     var fileGlobalThisSymbol = file.locals.get("globalThis");
57085                     if (fileGlobalThisSymbol) {
57086                         for (var _d = 0, _e = fileGlobalThisSymbol.declarations; _d < _e.length; _d++) {
57087                             var declaration = _e[_d];
57088                             diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0, "globalThis"));
57089                         }
57090                     }
57091                     mergeSymbolTable(globals, file.locals);
57092                 }
57093                 if (file.jsGlobalAugmentations) {
57094                     mergeSymbolTable(globals, file.jsGlobalAugmentations);
57095                 }
57096                 if (file.patternAmbientModules && file.patternAmbientModules.length) {
57097                     patternAmbientModules = ts.concatenate(patternAmbientModules, file.patternAmbientModules);
57098                 }
57099                 if (file.moduleAugmentations.length) {
57100                     (augmentations || (augmentations = [])).push(file.moduleAugmentations);
57101                 }
57102                 if (file.symbol && file.symbol.globalExports) {
57103                     var source = file.symbol.globalExports;
57104                     source.forEach(function (sourceSymbol, id) {
57105                         if (!globals.has(id)) {
57106                             globals.set(id, sourceSymbol);
57107                         }
57108                     });
57109                 }
57110             }
57111             if (augmentations) {
57112                 for (var _f = 0, augmentations_1 = augmentations; _f < augmentations_1.length; _f++) {
57113                     var list = augmentations_1[_f];
57114                     for (var _g = 0, list_1 = list; _g < list_1.length; _g++) {
57115                         var augmentation = list_1[_g];
57116                         if (!ts.isGlobalScopeAugmentation(augmentation.parent))
57117                             continue;
57118                         mergeModuleAugmentation(augmentation);
57119                     }
57120                 }
57121             }
57122             addToSymbolTable(globals, builtinGlobals, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0);
57123             getSymbolLinks(undefinedSymbol).type = undefinedWideningType;
57124             getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", 0, true);
57125             getSymbolLinks(unknownSymbol).type = errorType;
57126             getSymbolLinks(globalThisSymbol).type = createObjectType(16, globalThisSymbol);
57127             globalArrayType = getGlobalType("Array", 1, true);
57128             globalObjectType = getGlobalType("Object", 0, true);
57129             globalFunctionType = getGlobalType("Function", 0, true);
57130             globalCallableFunctionType = strictBindCallApply && getGlobalType("CallableFunction", 0, true) || globalFunctionType;
57131             globalNewableFunctionType = strictBindCallApply && getGlobalType("NewableFunction", 0, true) || globalFunctionType;
57132             globalStringType = getGlobalType("String", 0, true);
57133             globalNumberType = getGlobalType("Number", 0, true);
57134             globalBooleanType = getGlobalType("Boolean", 0, true);
57135             globalRegExpType = getGlobalType("RegExp", 0, true);
57136             anyArrayType = createArrayType(anyType);
57137             autoArrayType = createArrayType(autoType);
57138             if (autoArrayType === emptyObjectType) {
57139                 autoArrayType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
57140             }
57141             globalReadonlyArrayType = getGlobalTypeOrUndefined("ReadonlyArray", 1) || globalArrayType;
57142             anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType;
57143             globalThisType = getGlobalTypeOrUndefined("ThisType", 1);
57144             if (augmentations) {
57145                 for (var _h = 0, augmentations_2 = augmentations; _h < augmentations_2.length; _h++) {
57146                     var list = augmentations_2[_h];
57147                     for (var _j = 0, list_2 = list; _j < list_2.length; _j++) {
57148                         var augmentation = list_2[_j];
57149                         if (ts.isGlobalScopeAugmentation(augmentation.parent))
57150                             continue;
57151                         mergeModuleAugmentation(augmentation);
57152                     }
57153                 }
57154             }
57155             amalgamatedDuplicates.forEach(function (_a) {
57156                 var firstFile = _a.firstFile, secondFile = _a.secondFile, conflictingSymbols = _a.conflictingSymbols;
57157                 if (conflictingSymbols.size < 8) {
57158                     conflictingSymbols.forEach(function (_a, symbolName) {
57159                         var isBlockScoped = _a.isBlockScoped, firstFileLocations = _a.firstFileLocations, secondFileLocations = _a.secondFileLocations;
57160                         var message = isBlockScoped ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0;
57161                         for (var _i = 0, firstFileLocations_1 = firstFileLocations; _i < firstFileLocations_1.length; _i++) {
57162                             var node = firstFileLocations_1[_i];
57163                             addDuplicateDeclarationError(node, message, symbolName, secondFileLocations);
57164                         }
57165                         for (var _b = 0, secondFileLocations_1 = secondFileLocations; _b < secondFileLocations_1.length; _b++) {
57166                             var node = secondFileLocations_1[_b];
57167                             addDuplicateDeclarationError(node, message, symbolName, firstFileLocations);
57168                         }
57169                     });
57170                 }
57171                 else {
57172                     var list = ts.arrayFrom(conflictingSymbols.keys()).join(", ");
57173                     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)));
57174                     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)));
57175                 }
57176             });
57177             amalgamatedDuplicates = undefined;
57178         }
57179         function checkExternalEmitHelpers(location, helpers) {
57180             if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) {
57181                 var sourceFile = ts.getSourceFileOfNode(location);
57182                 if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 8388608)) {
57183                     var helpersModule = resolveHelpersModule(sourceFile, location);
57184                     if (helpersModule !== unknownSymbol) {
57185                         var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers;
57186                         for (var helper = 1; helper <= 1048576; helper <<= 1) {
57187                             if (uncheckedHelpers & helper) {
57188                                 var name = getHelperName(helper);
57189                                 var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551);
57190                                 if (!symbol) {
57191                                     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);
57192                                 }
57193                             }
57194                         }
57195                     }
57196                     requestedExternalEmitHelpers |= helpers;
57197                 }
57198             }
57199         }
57200         function getHelperName(helper) {
57201             switch (helper) {
57202                 case 1: return "__extends";
57203                 case 2: return "__assign";
57204                 case 4: return "__rest";
57205                 case 8: return "__decorate";
57206                 case 16: return "__metadata";
57207                 case 32: return "__param";
57208                 case 64: return "__awaiter";
57209                 case 128: return "__generator";
57210                 case 256: return "__values";
57211                 case 512: return "__read";
57212                 case 1024: return "__spread";
57213                 case 2048: return "__spreadArrays";
57214                 case 4096: return "__await";
57215                 case 8192: return "__asyncGenerator";
57216                 case 16384: return "__asyncDelegator";
57217                 case 32768: return "__asyncValues";
57218                 case 65536: return "__exportStar";
57219                 case 131072: return "__makeTemplateObject";
57220                 case 262144: return "__classPrivateFieldGet";
57221                 case 524288: return "__classPrivateFieldSet";
57222                 case 1048576: return "__createBinding";
57223                 default: return ts.Debug.fail("Unrecognized helper");
57224             }
57225         }
57226         function resolveHelpersModule(node, errorNode) {
57227             if (!externalHelpersModule) {
57228                 externalHelpersModule = resolveExternalModule(node, ts.externalHelpersModuleNameText, ts.Diagnostics.This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found, errorNode) || unknownSymbol;
57229             }
57230             return externalHelpersModule;
57231         }
57232         function checkGrammarDecoratorsAndModifiers(node) {
57233             return checkGrammarDecorators(node) || checkGrammarModifiers(node);
57234         }
57235         function checkGrammarDecorators(node) {
57236             if (!node.decorators) {
57237                 return false;
57238             }
57239             if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) {
57240                 if (node.kind === 161 && !ts.nodeIsPresent(node.body)) {
57241                     return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload);
57242                 }
57243                 else {
57244                     return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here);
57245                 }
57246             }
57247             else if (node.kind === 163 || node.kind === 164) {
57248                 var accessors = ts.getAllAccessorDeclarations(node.parent.members, node);
57249                 if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) {
57250                     return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name);
57251                 }
57252             }
57253             return false;
57254         }
57255         function checkGrammarModifiers(node) {
57256             var quickResult = reportObviousModifierErrors(node);
57257             if (quickResult !== undefined) {
57258                 return quickResult;
57259             }
57260             var lastStatic, lastDeclare, lastAsync, lastReadonly;
57261             var flags = 0;
57262             for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
57263                 var modifier = _a[_i];
57264                 if (modifier.kind !== 138) {
57265                     if (node.kind === 158 || node.kind === 160) {
57266                         return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind));
57267                     }
57268                     if (node.kind === 167) {
57269                         return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind));
57270                     }
57271                 }
57272                 switch (modifier.kind) {
57273                     case 81:
57274                         if (node.kind !== 248) {
57275                             return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(81));
57276                         }
57277                         break;
57278                     case 119:
57279                     case 118:
57280                     case 117:
57281                         var text = visibilityToString(ts.modifierToFlag(modifier.kind));
57282                         if (flags & 28) {
57283                             return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen);
57284                         }
57285                         else if (flags & 32) {
57286                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static");
57287                         }
57288                         else if (flags & 64) {
57289                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly");
57290                         }
57291                         else if (flags & 256) {
57292                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async");
57293                         }
57294                         else if (node.parent.kind === 250 || node.parent.kind === 290) {
57295                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text);
57296                         }
57297                         else if (flags & 128) {
57298                             if (modifier.kind === 117) {
57299                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract");
57300                             }
57301                             else {
57302                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract");
57303                             }
57304                         }
57305                         else if (ts.isPrivateIdentifierPropertyDeclaration(node)) {
57306                             return grammarErrorOnNode(modifier, ts.Diagnostics.An_accessibility_modifier_cannot_be_used_with_a_private_identifier);
57307                         }
57308                         flags |= ts.modifierToFlag(modifier.kind);
57309                         break;
57310                     case 120:
57311                         if (flags & 32) {
57312                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static");
57313                         }
57314                         else if (flags & 64) {
57315                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly");
57316                         }
57317                         else if (flags & 256) {
57318                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async");
57319                         }
57320                         else if (node.parent.kind === 250 || node.parent.kind === 290) {
57321                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static");
57322                         }
57323                         else if (node.kind === 156) {
57324                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static");
57325                         }
57326                         else if (flags & 128) {
57327                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract");
57328                         }
57329                         else if (ts.isPrivateIdentifierPropertyDeclaration(node)) {
57330                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "static");
57331                         }
57332                         flags |= 32;
57333                         lastStatic = modifier;
57334                         break;
57335                     case 138:
57336                         if (flags & 64) {
57337                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly");
57338                         }
57339                         else if (node.kind !== 159 && node.kind !== 158 && node.kind !== 167 && node.kind !== 156) {
57340                             return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature);
57341                         }
57342                         flags |= 64;
57343                         lastReadonly = modifier;
57344                         break;
57345                     case 89:
57346                         if (flags & 1) {
57347                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export");
57348                         }
57349                         else if (flags & 2) {
57350                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare");
57351                         }
57352                         else if (flags & 128) {
57353                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract");
57354                         }
57355                         else if (flags & 256) {
57356                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async");
57357                         }
57358                         else if (ts.isClassLike(node.parent)) {
57359                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export");
57360                         }
57361                         else if (node.kind === 156) {
57362                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export");
57363                         }
57364                         flags |= 1;
57365                         break;
57366                     case 84:
57367                         var container = node.parent.kind === 290 ? node.parent : node.parent.parent;
57368                         if (container.kind === 249 && !ts.isAmbientModule(container)) {
57369                             return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module);
57370                         }
57371                         flags |= 512;
57372                         break;
57373                     case 130:
57374                         if (flags & 2) {
57375                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare");
57376                         }
57377                         else if (flags & 256) {
57378                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
57379                         }
57380                         else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) {
57381                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare");
57382                         }
57383                         else if (node.kind === 156) {
57384                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare");
57385                         }
57386                         else if ((node.parent.flags & 8388608) && node.parent.kind === 250) {
57387                             return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context);
57388                         }
57389                         else if (ts.isPrivateIdentifierPropertyDeclaration(node)) {
57390                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare");
57391                         }
57392                         flags |= 2;
57393                         lastDeclare = modifier;
57394                         break;
57395                     case 122:
57396                         if (flags & 128) {
57397                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract");
57398                         }
57399                         if (node.kind !== 245) {
57400                             if (node.kind !== 161 &&
57401                                 node.kind !== 159 &&
57402                                 node.kind !== 163 &&
57403                                 node.kind !== 164) {
57404                                 return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration);
57405                             }
57406                             if (!(node.parent.kind === 245 && ts.hasModifier(node.parent, 128))) {
57407                                 return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class);
57408                             }
57409                             if (flags & 32) {
57410                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract");
57411                             }
57412                             if (flags & 8) {
57413                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract");
57414                             }
57415                         }
57416                         if (ts.isNamedDeclaration(node) && node.name.kind === 76) {
57417                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract");
57418                         }
57419                         flags |= 128;
57420                         break;
57421                     case 126:
57422                         if (flags & 256) {
57423                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async");
57424                         }
57425                         else if (flags & 2 || node.parent.flags & 8388608) {
57426                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
57427                         }
57428                         else if (node.kind === 156) {
57429                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async");
57430                         }
57431                         flags |= 256;
57432                         lastAsync = modifier;
57433                         break;
57434                 }
57435             }
57436             if (node.kind === 162) {
57437                 if (flags & 32) {
57438                     return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static");
57439                 }
57440                 if (flags & 128) {
57441                     return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract");
57442                 }
57443                 else if (flags & 256) {
57444                     return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async");
57445                 }
57446                 else if (flags & 64) {
57447                     return grammarErrorOnNode(lastReadonly, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "readonly");
57448                 }
57449                 return false;
57450             }
57451             else if ((node.kind === 254 || node.kind === 253) && flags & 2) {
57452                 return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare");
57453             }
57454             else if (node.kind === 156 && (flags & 92) && ts.isBindingPattern(node.name)) {
57455                 return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern);
57456             }
57457             else if (node.kind === 156 && (flags & 92) && node.dotDotDotToken) {
57458                 return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter);
57459             }
57460             if (flags & 256) {
57461                 return checkGrammarAsyncModifier(node, lastAsync);
57462             }
57463             return false;
57464         }
57465         function reportObviousModifierErrors(node) {
57466             return !node.modifiers
57467                 ? false
57468                 : shouldReportBadModifier(node)
57469                     ? grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here)
57470                     : undefined;
57471         }
57472         function shouldReportBadModifier(node) {
57473             switch (node.kind) {
57474                 case 163:
57475                 case 164:
57476                 case 162:
57477                 case 159:
57478                 case 158:
57479                 case 161:
57480                 case 160:
57481                 case 167:
57482                 case 249:
57483                 case 254:
57484                 case 253:
57485                 case 260:
57486                 case 259:
57487                 case 201:
57488                 case 202:
57489                 case 156:
57490                     return false;
57491                 default:
57492                     if (node.parent.kind === 250 || node.parent.kind === 290) {
57493                         return false;
57494                     }
57495                     switch (node.kind) {
57496                         case 244:
57497                             return nodeHasAnyModifiersExcept(node, 126);
57498                         case 245:
57499                             return nodeHasAnyModifiersExcept(node, 122);
57500                         case 246:
57501                         case 225:
57502                         case 247:
57503                             return true;
57504                         case 248:
57505                             return nodeHasAnyModifiersExcept(node, 81);
57506                         default:
57507                             ts.Debug.fail();
57508                             return false;
57509                     }
57510             }
57511         }
57512         function nodeHasAnyModifiersExcept(node, allowedModifier) {
57513             return node.modifiers.length > 1 || node.modifiers[0].kind !== allowedModifier;
57514         }
57515         function checkGrammarAsyncModifier(node, asyncModifier) {
57516             switch (node.kind) {
57517                 case 161:
57518                 case 244:
57519                 case 201:
57520                 case 202:
57521                     return false;
57522             }
57523             return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async");
57524         }
57525         function checkGrammarForDisallowedTrailingComma(list, diag) {
57526             if (diag === void 0) { diag = ts.Diagnostics.Trailing_comma_not_allowed; }
57527             if (list && list.hasTrailingComma) {
57528                 return grammarErrorAtPos(list[0], list.end - ",".length, ",".length, diag);
57529             }
57530             return false;
57531         }
57532         function checkGrammarTypeParameterList(typeParameters, file) {
57533             if (typeParameters && typeParameters.length === 0) {
57534                 var start = typeParameters.pos - "<".length;
57535                 var end = ts.skipTrivia(file.text, typeParameters.end) + ">".length;
57536                 return grammarErrorAtPos(file, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty);
57537             }
57538             return false;
57539         }
57540         function checkGrammarParameterList(parameters) {
57541             var seenOptionalParameter = false;
57542             var parameterCount = parameters.length;
57543             for (var i = 0; i < parameterCount; i++) {
57544                 var parameter = parameters[i];
57545                 if (parameter.dotDotDotToken) {
57546                     if (i !== (parameterCount - 1)) {
57547                         return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
57548                     }
57549                     if (!(parameter.flags & 8388608)) {
57550                         checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
57551                     }
57552                     if (parameter.questionToken) {
57553                         return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_rest_parameter_cannot_be_optional);
57554                     }
57555                     if (parameter.initializer) {
57556                         return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer);
57557                     }
57558                 }
57559                 else if (parameter.questionToken) {
57560                     seenOptionalParameter = true;
57561                     if (parameter.initializer) {
57562                         return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer);
57563                     }
57564                 }
57565                 else if (seenOptionalParameter && !parameter.initializer) {
57566                     return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter);
57567                 }
57568             }
57569         }
57570         function getNonSimpleParameters(parameters) {
57571             return ts.filter(parameters, function (parameter) { return !!parameter.initializer || ts.isBindingPattern(parameter.name) || ts.isRestParameter(parameter); });
57572         }
57573         function checkGrammarForUseStrictSimpleParameterList(node) {
57574             if (languageVersion >= 3) {
57575                 var useStrictDirective_1 = node.body && ts.isBlock(node.body) && ts.findUseStrictPrologue(node.body.statements);
57576                 if (useStrictDirective_1) {
57577                     var nonSimpleParameters = getNonSimpleParameters(node.parameters);
57578                     if (ts.length(nonSimpleParameters)) {
57579                         ts.forEach(nonSimpleParameters, function (parameter) {
57580                             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));
57581                         });
57582                         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)); });
57583                         ts.addRelatedInfo.apply(void 0, __spreadArrays([error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)], diagnostics_1));
57584                         return true;
57585                     }
57586                 }
57587             }
57588             return false;
57589         }
57590         function checkGrammarFunctionLikeDeclaration(node) {
57591             var file = ts.getSourceFileOfNode(node);
57592             return checkGrammarDecoratorsAndModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) ||
57593                 checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file) ||
57594                 (ts.isFunctionLikeDeclaration(node) && checkGrammarForUseStrictSimpleParameterList(node));
57595         }
57596         function checkGrammarClassLikeDeclaration(node) {
57597             var file = ts.getSourceFileOfNode(node);
57598             return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(node.typeParameters, file);
57599         }
57600         function checkGrammarArrowFunction(node, file) {
57601             if (!ts.isArrowFunction(node)) {
57602                 return false;
57603             }
57604             var equalsGreaterThanToken = node.equalsGreaterThanToken;
57605             var startLine = ts.getLineAndCharacterOfPosition(file, equalsGreaterThanToken.pos).line;
57606             var endLine = ts.getLineAndCharacterOfPosition(file, equalsGreaterThanToken.end).line;
57607             return startLine !== endLine && grammarErrorOnNode(equalsGreaterThanToken, ts.Diagnostics.Line_terminator_not_permitted_before_arrow);
57608         }
57609         function checkGrammarIndexSignatureParameters(node) {
57610             var parameter = node.parameters[0];
57611             if (node.parameters.length !== 1) {
57612                 if (parameter) {
57613                     return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter);
57614                 }
57615                 else {
57616                     return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter);
57617                 }
57618             }
57619             checkGrammarForDisallowedTrailingComma(node.parameters, ts.Diagnostics.An_index_signature_cannot_have_a_trailing_comma);
57620             if (parameter.dotDotDotToken) {
57621                 return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter);
57622             }
57623             if (ts.hasModifiers(parameter)) {
57624                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier);
57625             }
57626             if (parameter.questionToken) {
57627                 return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark);
57628             }
57629             if (parameter.initializer) {
57630                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_initializer);
57631             }
57632             if (!parameter.type) {
57633                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation);
57634             }
57635             if (parameter.type.kind !== 143 && parameter.type.kind !== 140) {
57636                 var type = getTypeFromTypeNode(parameter.type);
57637                 if (type.flags & 4 || type.flags & 8) {
57638                     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));
57639                 }
57640                 if (type.flags & 1048576 && allTypesAssignableToKind(type, 384, true)) {
57641                     return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead);
57642                 }
57643                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_either_string_or_number);
57644             }
57645             if (!node.type) {
57646                 return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation);
57647             }
57648             return false;
57649         }
57650         function checkGrammarIndexSignature(node) {
57651             return checkGrammarDecoratorsAndModifiers(node) || checkGrammarIndexSignatureParameters(node);
57652         }
57653         function checkGrammarForAtLeastOneTypeArgument(node, typeArguments) {
57654             if (typeArguments && typeArguments.length === 0) {
57655                 var sourceFile = ts.getSourceFileOfNode(node);
57656                 var start = typeArguments.pos - "<".length;
57657                 var end = ts.skipTrivia(sourceFile.text, typeArguments.end) + ">".length;
57658                 return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty);
57659             }
57660             return false;
57661         }
57662         function checkGrammarTypeArguments(node, typeArguments) {
57663             return checkGrammarForDisallowedTrailingComma(typeArguments) ||
57664                 checkGrammarForAtLeastOneTypeArgument(node, typeArguments);
57665         }
57666         function checkGrammarTaggedTemplateChain(node) {
57667             if (node.questionDotToken || node.flags & 32) {
57668                 return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain);
57669             }
57670             return false;
57671         }
57672         function checkGrammarForOmittedArgument(args) {
57673             if (args) {
57674                 for (var _i = 0, args_4 = args; _i < args_4.length; _i++) {
57675                     var arg = args_4[_i];
57676                     if (arg.kind === 215) {
57677                         return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected);
57678                     }
57679                 }
57680             }
57681             return false;
57682         }
57683         function checkGrammarArguments(args) {
57684             return checkGrammarForOmittedArgument(args);
57685         }
57686         function checkGrammarHeritageClause(node) {
57687             var types = node.types;
57688             if (checkGrammarForDisallowedTrailingComma(types)) {
57689                 return true;
57690             }
57691             if (types && types.length === 0) {
57692                 var listType = ts.tokenToString(node.token);
57693                 return grammarErrorAtPos(node, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType);
57694             }
57695             return ts.some(types, checkGrammarExpressionWithTypeArguments);
57696         }
57697         function checkGrammarExpressionWithTypeArguments(node) {
57698             return checkGrammarTypeArguments(node, node.typeArguments);
57699         }
57700         function checkGrammarClassDeclarationHeritageClauses(node) {
57701             var seenExtendsClause = false;
57702             var seenImplementsClause = false;
57703             if (!checkGrammarDecoratorsAndModifiers(node) && node.heritageClauses) {
57704                 for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) {
57705                     var heritageClause = _a[_i];
57706                     if (heritageClause.token === 90) {
57707                         if (seenExtendsClause) {
57708                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen);
57709                         }
57710                         if (seenImplementsClause) {
57711                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_must_precede_implements_clause);
57712                         }
57713                         if (heritageClause.types.length > 1) {
57714                             return grammarErrorOnFirstToken(heritageClause.types[1], ts.Diagnostics.Classes_can_only_extend_a_single_class);
57715                         }
57716                         seenExtendsClause = true;
57717                     }
57718                     else {
57719                         ts.Debug.assert(heritageClause.token === 113);
57720                         if (seenImplementsClause) {
57721                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen);
57722                         }
57723                         seenImplementsClause = true;
57724                     }
57725                     checkGrammarHeritageClause(heritageClause);
57726                 }
57727             }
57728         }
57729         function checkGrammarInterfaceDeclaration(node) {
57730             var seenExtendsClause = false;
57731             if (node.heritageClauses) {
57732                 for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) {
57733                     var heritageClause = _a[_i];
57734                     if (heritageClause.token === 90) {
57735                         if (seenExtendsClause) {
57736                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen);
57737                         }
57738                         seenExtendsClause = true;
57739                     }
57740                     else {
57741                         ts.Debug.assert(heritageClause.token === 113);
57742                         return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause);
57743                     }
57744                     checkGrammarHeritageClause(heritageClause);
57745                 }
57746             }
57747             return false;
57748         }
57749         function checkGrammarComputedPropertyName(node) {
57750             if (node.kind !== 154) {
57751                 return false;
57752             }
57753             var computedPropertyName = node;
57754             if (computedPropertyName.expression.kind === 209 && computedPropertyName.expression.operatorToken.kind === 27) {
57755                 return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name);
57756             }
57757             return false;
57758         }
57759         function checkGrammarForGenerator(node) {
57760             if (node.asteriskToken) {
57761                 ts.Debug.assert(node.kind === 244 ||
57762                     node.kind === 201 ||
57763                     node.kind === 161);
57764                 if (node.flags & 8388608) {
57765                     return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context);
57766                 }
57767                 if (!node.body) {
57768                     return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator);
57769                 }
57770             }
57771         }
57772         function checkGrammarForInvalidQuestionMark(questionToken, message) {
57773             return !!questionToken && grammarErrorOnNode(questionToken, message);
57774         }
57775         function checkGrammarForInvalidExclamationToken(exclamationToken, message) {
57776             return !!exclamationToken && grammarErrorOnNode(exclamationToken, message);
57777         }
57778         function checkGrammarObjectLiteralExpression(node, inDestructuring) {
57779             var seen = ts.createUnderscoreEscapedMap();
57780             for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
57781                 var prop = _a[_i];
57782                 if (prop.kind === 283) {
57783                     if (inDestructuring) {
57784                         var expression = ts.skipParentheses(prop.expression);
57785                         if (ts.isArrayLiteralExpression(expression) || ts.isObjectLiteralExpression(expression)) {
57786                             return grammarErrorOnNode(prop.expression, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern);
57787                         }
57788                     }
57789                     continue;
57790                 }
57791                 var name = prop.name;
57792                 if (name.kind === 154) {
57793                     checkGrammarComputedPropertyName(name);
57794                 }
57795                 if (prop.kind === 282 && !inDestructuring && prop.objectAssignmentInitializer) {
57796                     return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment);
57797                 }
57798                 if (name.kind === 76) {
57799                     return grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
57800                 }
57801                 if (prop.modifiers) {
57802                     for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) {
57803                         var mod = _c[_b];
57804                         if (mod.kind !== 126 || prop.kind !== 161) {
57805                             grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod));
57806                         }
57807                     }
57808                 }
57809                 var currentKind = void 0;
57810                 switch (prop.kind) {
57811                     case 282:
57812                         checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context);
57813                     case 281:
57814                         checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional);
57815                         if (name.kind === 8) {
57816                             checkGrammarNumericLiteral(name);
57817                         }
57818                         currentKind = 4;
57819                         break;
57820                     case 161:
57821                         currentKind = 8;
57822                         break;
57823                     case 163:
57824                         currentKind = 1;
57825                         break;
57826                     case 164:
57827                         currentKind = 2;
57828                         break;
57829                     default:
57830                         throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind);
57831                 }
57832                 if (!inDestructuring) {
57833                     var effectiveName = ts.getPropertyNameForPropertyNameNode(name);
57834                     if (effectiveName === undefined) {
57835                         continue;
57836                     }
57837                     var existingKind = seen.get(effectiveName);
57838                     if (!existingKind) {
57839                         seen.set(effectiveName, currentKind);
57840                     }
57841                     else {
57842                         if ((currentKind & 12) && (existingKind & 12)) {
57843                             grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name));
57844                         }
57845                         else if ((currentKind & 3) && (existingKind & 3)) {
57846                             if (existingKind !== 3 && currentKind !== existingKind) {
57847                                 seen.set(effectiveName, currentKind | existingKind);
57848                             }
57849                             else {
57850                                 return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name);
57851                             }
57852                         }
57853                         else {
57854                             return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name);
57855                         }
57856                     }
57857                 }
57858             }
57859         }
57860         function checkGrammarJsxElement(node) {
57861             checkGrammarTypeArguments(node, node.typeArguments);
57862             var seen = ts.createUnderscoreEscapedMap();
57863             for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) {
57864                 var attr = _a[_i];
57865                 if (attr.kind === 275) {
57866                     continue;
57867                 }
57868                 var name = attr.name, initializer = attr.initializer;
57869                 if (!seen.get(name.escapedText)) {
57870                     seen.set(name.escapedText, true);
57871                 }
57872                 else {
57873                     return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name);
57874                 }
57875                 if (initializer && initializer.kind === 276 && !initializer.expression) {
57876                     return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression);
57877                 }
57878             }
57879         }
57880         function checkGrammarJsxExpression(node) {
57881             if (node.expression && ts.isCommaSequence(node.expression)) {
57882                 return grammarErrorOnNode(node.expression, ts.Diagnostics.JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array);
57883             }
57884         }
57885         function checkGrammarForInOrForOfStatement(forInOrOfStatement) {
57886             if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) {
57887                 return true;
57888             }
57889             if (forInOrOfStatement.kind === 232 && forInOrOfStatement.awaitModifier) {
57890                 if ((forInOrOfStatement.flags & 32768) === 0) {
57891                     var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement);
57892                     if (!hasParseDiagnostics(sourceFile)) {
57893                         var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator);
57894                         var func = ts.getContainingFunction(forInOrOfStatement);
57895                         if (func && func.kind !== 162) {
57896                             ts.Debug.assert((ts.getFunctionFlags(func) & 2) === 0, "Enclosing function should never be an async function.");
57897                             var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
57898                             ts.addRelatedInfo(diagnostic, relatedInfo);
57899                         }
57900                         diagnostics.add(diagnostic);
57901                         return true;
57902                     }
57903                     return false;
57904                 }
57905             }
57906             if (forInOrOfStatement.initializer.kind === 243) {
57907                 var variableList = forInOrOfStatement.initializer;
57908                 if (!checkGrammarVariableDeclarationList(variableList)) {
57909                     var declarations = variableList.declarations;
57910                     if (!declarations.length) {
57911                         return false;
57912                     }
57913                     if (declarations.length > 1) {
57914                         var diagnostic = forInOrOfStatement.kind === 231
57915                             ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement
57916                             : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement;
57917                         return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic);
57918                     }
57919                     var firstDeclaration = declarations[0];
57920                     if (firstDeclaration.initializer) {
57921                         var diagnostic = forInOrOfStatement.kind === 231
57922                             ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer
57923                             : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer;
57924                         return grammarErrorOnNode(firstDeclaration.name, diagnostic);
57925                     }
57926                     if (firstDeclaration.type) {
57927                         var diagnostic = forInOrOfStatement.kind === 231
57928                             ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation
57929                             : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation;
57930                         return grammarErrorOnNode(firstDeclaration, diagnostic);
57931                     }
57932                 }
57933             }
57934             return false;
57935         }
57936         function checkGrammarAccessor(accessor) {
57937             if (!(accessor.flags & 8388608)) {
57938                 if (languageVersion < 1) {
57939                     return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher);
57940                 }
57941                 if (accessor.body === undefined && !ts.hasModifier(accessor, 128)) {
57942                     return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{");
57943                 }
57944             }
57945             if (accessor.body && ts.hasModifier(accessor, 128)) {
57946                 return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation);
57947             }
57948             if (accessor.typeParameters) {
57949                 return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters);
57950             }
57951             if (!doesAccessorHaveCorrectParameterCount(accessor)) {
57952                 return grammarErrorOnNode(accessor.name, accessor.kind === 163 ?
57953                     ts.Diagnostics.A_get_accessor_cannot_have_parameters :
57954                     ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter);
57955             }
57956             if (accessor.kind === 164) {
57957                 if (accessor.type) {
57958                     return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation);
57959                 }
57960                 var parameter = ts.Debug.checkDefined(ts.getSetAccessorValueParameter(accessor), "Return value does not match parameter count assertion.");
57961                 if (parameter.dotDotDotToken) {
57962                     return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter);
57963                 }
57964                 if (parameter.questionToken) {
57965                     return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter);
57966                 }
57967                 if (parameter.initializer) {
57968                     return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer);
57969                 }
57970             }
57971             return false;
57972         }
57973         function doesAccessorHaveCorrectParameterCount(accessor) {
57974             return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 163 ? 0 : 1);
57975         }
57976         function getAccessorThisParameter(accessor) {
57977             if (accessor.parameters.length === (accessor.kind === 163 ? 1 : 2)) {
57978                 return ts.getThisParameter(accessor);
57979             }
57980         }
57981         function checkGrammarTypeOperatorNode(node) {
57982             if (node.operator === 147) {
57983                 if (node.type.kind !== 144) {
57984                     return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(144));
57985                 }
57986                 var parent = ts.walkUpParenthesizedTypes(node.parent);
57987                 switch (parent.kind) {
57988                     case 242:
57989                         var decl = parent;
57990                         if (decl.name.kind !== 75) {
57991                             return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name);
57992                         }
57993                         if (!ts.isVariableDeclarationInVariableStatement(decl)) {
57994                             return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement);
57995                         }
57996                         if (!(decl.parent.flags & 2)) {
57997                             return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const);
57998                         }
57999                         break;
58000                     case 159:
58001                         if (!ts.hasModifier(parent, 32) ||
58002                             !ts.hasModifier(parent, 64)) {
58003                             return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly);
58004                         }
58005                         break;
58006                     case 158:
58007                         if (!ts.hasModifier(parent, 64)) {
58008                             return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly);
58009                         }
58010                         break;
58011                     default:
58012                         return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here);
58013                 }
58014             }
58015             else if (node.operator === 138) {
58016                 if (node.type.kind !== 174 && node.type.kind !== 175) {
58017                     return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(144));
58018                 }
58019             }
58020         }
58021         function checkGrammarForInvalidDynamicName(node, message) {
58022             if (isNonBindableDynamicName(node)) {
58023                 return grammarErrorOnNode(node, message);
58024             }
58025         }
58026         function checkGrammarMethod(node) {
58027             if (checkGrammarFunctionLikeDeclaration(node)) {
58028                 return true;
58029             }
58030             if (node.kind === 161) {
58031                 if (node.parent.kind === 193) {
58032                     if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 126)) {
58033                         return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here);
58034                     }
58035                     else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) {
58036                         return true;
58037                     }
58038                     else if (checkGrammarForInvalidExclamationToken(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context)) {
58039                         return true;
58040                     }
58041                     else if (node.body === undefined) {
58042                         return grammarErrorAtPos(node, node.end - 1, ";".length, ts.Diagnostics._0_expected, "{");
58043                     }
58044                 }
58045                 if (checkGrammarForGenerator(node)) {
58046                     return true;
58047                 }
58048             }
58049             if (ts.isClassLike(node.parent)) {
58050                 if (node.flags & 8388608) {
58051                     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);
58052                 }
58053                 else if (node.kind === 161 && !node.body) {
58054                     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);
58055                 }
58056             }
58057             else if (node.parent.kind === 246) {
58058                 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);
58059             }
58060             else if (node.parent.kind === 173) {
58061                 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);
58062             }
58063         }
58064         function checkGrammarBreakOrContinueStatement(node) {
58065             var current = node;
58066             while (current) {
58067                 if (ts.isFunctionLike(current)) {
58068                     return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary);
58069                 }
58070                 switch (current.kind) {
58071                     case 238:
58072                         if (node.label && current.label.escapedText === node.label.escapedText) {
58073                             var isMisplacedContinueLabel = node.kind === 233
58074                                 && !ts.isIterationStatement(current.statement, true);
58075                             if (isMisplacedContinueLabel) {
58076                                 return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement);
58077                             }
58078                             return false;
58079                         }
58080                         break;
58081                     case 237:
58082                         if (node.kind === 234 && !node.label) {
58083                             return false;
58084                         }
58085                         break;
58086                     default:
58087                         if (ts.isIterationStatement(current, false) && !node.label) {
58088                             return false;
58089                         }
58090                         break;
58091                 }
58092                 current = current.parent;
58093             }
58094             if (node.label) {
58095                 var message = node.kind === 234
58096                     ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement
58097                     : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement;
58098                 return grammarErrorOnNode(node, message);
58099             }
58100             else {
58101                 var message = node.kind === 234
58102                     ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement
58103                     : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement;
58104                 return grammarErrorOnNode(node, message);
58105             }
58106         }
58107         function checkGrammarBindingElement(node) {
58108             if (node.dotDotDotToken) {
58109                 var elements = node.parent.elements;
58110                 if (node !== ts.last(elements)) {
58111                     return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
58112                 }
58113                 checkGrammarForDisallowedTrailingComma(elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
58114                 if (node.propertyName) {
58115                     return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_have_a_property_name);
58116                 }
58117                 if (node.initializer) {
58118                     return grammarErrorAtPos(node, node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer);
58119                 }
58120             }
58121         }
58122         function isStringOrNumberLiteralExpression(expr) {
58123             return ts.isStringOrNumericLiteralLike(expr) ||
58124                 expr.kind === 207 && expr.operator === 40 &&
58125                     expr.operand.kind === 8;
58126         }
58127         function isBigIntLiteralExpression(expr) {
58128             return expr.kind === 9 ||
58129                 expr.kind === 207 && expr.operator === 40 &&
58130                     expr.operand.kind === 9;
58131         }
58132         function isSimpleLiteralEnumReference(expr) {
58133             if ((ts.isPropertyAccessExpression(expr) || (ts.isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression))) &&
58134                 ts.isEntityNameExpression(expr.expression)) {
58135                 return !!(checkExpressionCached(expr).flags & 1024);
58136             }
58137         }
58138         function checkAmbientInitializer(node) {
58139             var initializer = node.initializer;
58140             if (initializer) {
58141                 var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) ||
58142                     isSimpleLiteralEnumReference(initializer) ||
58143                     initializer.kind === 106 || initializer.kind === 91 ||
58144                     isBigIntLiteralExpression(initializer));
58145                 var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node);
58146                 if (isConstOrReadonly && !node.type) {
58147                     if (isInvalidInitializer) {
58148                         return grammarErrorOnNode(initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference);
58149                     }
58150                 }
58151                 else {
58152                     return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
58153                 }
58154                 if (!isConstOrReadonly || isInvalidInitializer) {
58155                     return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
58156                 }
58157             }
58158         }
58159         function checkGrammarVariableDeclaration(node) {
58160             if (node.parent.parent.kind !== 231 && node.parent.parent.kind !== 232) {
58161                 if (node.flags & 8388608) {
58162                     checkAmbientInitializer(node);
58163                 }
58164                 else if (!node.initializer) {
58165                     if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) {
58166                         return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer);
58167                     }
58168                     if (ts.isVarConst(node)) {
58169                         return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized);
58170                     }
58171                 }
58172             }
58173             if (node.exclamationToken && (node.parent.parent.kind !== 225 || !node.type || node.initializer || node.flags & 8388608)) {
58174                 return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation);
58175             }
58176             var moduleKind = ts.getEmitModuleKind(compilerOptions);
58177             if (moduleKind < ts.ModuleKind.ES2015 && moduleKind !== ts.ModuleKind.System && !compilerOptions.noEmit &&
58178                 !(node.parent.parent.flags & 8388608) && ts.hasModifier(node.parent.parent, 1)) {
58179                 checkESModuleMarker(node.name);
58180             }
58181             var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node));
58182             return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name);
58183         }
58184         function checkESModuleMarker(name) {
58185             if (name.kind === 75) {
58186                 if (ts.idText(name) === "__esModule") {
58187                     return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules);
58188                 }
58189             }
58190             else {
58191                 var elements = name.elements;
58192                 for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) {
58193                     var element = elements_1[_i];
58194                     if (!ts.isOmittedExpression(element)) {
58195                         return checkESModuleMarker(element.name);
58196                     }
58197                 }
58198             }
58199             return false;
58200         }
58201         function checkGrammarNameInLetOrConstDeclarations(name) {
58202             if (name.kind === 75) {
58203                 if (name.originalKeywordKind === 115) {
58204                     return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations);
58205                 }
58206             }
58207             else {
58208                 var elements = name.elements;
58209                 for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) {
58210                     var element = elements_2[_i];
58211                     if (!ts.isOmittedExpression(element)) {
58212                         checkGrammarNameInLetOrConstDeclarations(element.name);
58213                     }
58214                 }
58215             }
58216             return false;
58217         }
58218         function checkGrammarVariableDeclarationList(declarationList) {
58219             var declarations = declarationList.declarations;
58220             if (checkGrammarForDisallowedTrailingComma(declarationList.declarations)) {
58221                 return true;
58222             }
58223             if (!declarationList.declarations.length) {
58224                 return grammarErrorAtPos(declarationList, declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty);
58225             }
58226             return false;
58227         }
58228         function allowLetAndConstDeclarations(parent) {
58229             switch (parent.kind) {
58230                 case 227:
58231                 case 228:
58232                 case 229:
58233                 case 236:
58234                 case 230:
58235                 case 231:
58236                 case 232:
58237                     return false;
58238                 case 238:
58239                     return allowLetAndConstDeclarations(parent.parent);
58240             }
58241             return true;
58242         }
58243         function checkGrammarForDisallowedLetOrConstStatement(node) {
58244             if (!allowLetAndConstDeclarations(node.parent)) {
58245                 if (ts.isLet(node.declarationList)) {
58246                     return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block);
58247                 }
58248                 else if (ts.isVarConst(node.declarationList)) {
58249                     return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block);
58250                 }
58251             }
58252         }
58253         function checkGrammarMetaProperty(node) {
58254             var escapedText = node.name.escapedText;
58255             switch (node.keywordToken) {
58256                 case 99:
58257                     if (escapedText !== "target") {
58258                         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");
58259                     }
58260                     break;
58261                 case 96:
58262                     if (escapedText !== "meta") {
58263                         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");
58264                     }
58265                     break;
58266             }
58267         }
58268         function hasParseDiagnostics(sourceFile) {
58269             return sourceFile.parseDiagnostics.length > 0;
58270         }
58271         function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) {
58272             var sourceFile = ts.getSourceFileOfNode(node);
58273             if (!hasParseDiagnostics(sourceFile)) {
58274                 var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
58275                 diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2));
58276                 return true;
58277             }
58278             return false;
58279         }
58280         function grammarErrorAtPos(nodeForSourceFile, start, length, message, arg0, arg1, arg2) {
58281             var sourceFile = ts.getSourceFileOfNode(nodeForSourceFile);
58282             if (!hasParseDiagnostics(sourceFile)) {
58283                 diagnostics.add(ts.createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2));
58284                 return true;
58285             }
58286             return false;
58287         }
58288         function grammarErrorOnNode(node, message, arg0, arg1, arg2) {
58289             var sourceFile = ts.getSourceFileOfNode(node);
58290             if (!hasParseDiagnostics(sourceFile)) {
58291                 diagnostics.add(ts.createDiagnosticForNode(node, message, arg0, arg1, arg2));
58292                 return true;
58293             }
58294             return false;
58295         }
58296         function checkGrammarConstructorTypeParameters(node) {
58297             var jsdocTypeParameters = ts.isInJSFile(node) ? ts.getJSDocTypeParameterDeclarations(node) : undefined;
58298             var range = node.typeParameters || jsdocTypeParameters && ts.firstOrUndefined(jsdocTypeParameters);
58299             if (range) {
58300                 var pos = range.pos === range.end ? range.pos : ts.skipTrivia(ts.getSourceFileOfNode(node).text, range.pos);
58301                 return grammarErrorAtPos(node, pos, range.end - pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration);
58302             }
58303         }
58304         function checkGrammarConstructorTypeAnnotation(node) {
58305             var type = ts.getEffectiveReturnTypeNode(node);
58306             if (type) {
58307                 return grammarErrorOnNode(type, ts.Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration);
58308             }
58309         }
58310         function checkGrammarProperty(node) {
58311             if (ts.isClassLike(node.parent)) {
58312                 if (ts.isStringLiteral(node.name) && node.name.text === "constructor") {
58313                     return grammarErrorOnNode(node.name, ts.Diagnostics.Classes_may_not_have_a_field_named_constructor);
58314                 }
58315                 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)) {
58316                     return true;
58317                 }
58318                 if (languageVersion < 2 && ts.isPrivateIdentifier(node.name)) {
58319                     return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher);
58320                 }
58321             }
58322             else if (node.parent.kind === 246) {
58323                 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)) {
58324                     return true;
58325                 }
58326                 if (node.initializer) {
58327                     return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer);
58328                 }
58329             }
58330             else if (node.parent.kind === 173) {
58331                 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)) {
58332                     return true;
58333                 }
58334                 if (node.initializer) {
58335                     return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer);
58336                 }
58337             }
58338             if (node.flags & 8388608) {
58339                 checkAmbientInitializer(node);
58340             }
58341             if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer ||
58342                 node.flags & 8388608 || ts.hasModifier(node, 32 | 128))) {
58343                 return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context);
58344             }
58345         }
58346         function checkGrammarTopLevelElementForRequiredDeclareModifier(node) {
58347             if (node.kind === 246 ||
58348                 node.kind === 247 ||
58349                 node.kind === 254 ||
58350                 node.kind === 253 ||
58351                 node.kind === 260 ||
58352                 node.kind === 259 ||
58353                 node.kind === 252 ||
58354                 ts.hasModifier(node, 2 | 1 | 512)) {
58355                 return false;
58356             }
58357             return grammarErrorOnFirstToken(node, ts.Diagnostics.Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier);
58358         }
58359         function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) {
58360             for (var _i = 0, _a = file.statements; _i < _a.length; _i++) {
58361                 var decl = _a[_i];
58362                 if (ts.isDeclaration(decl) || decl.kind === 225) {
58363                     if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) {
58364                         return true;
58365                     }
58366                 }
58367             }
58368             return false;
58369         }
58370         function checkGrammarSourceFile(node) {
58371             return !!(node.flags & 8388608) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node);
58372         }
58373         function checkGrammarStatementInAmbientContext(node) {
58374             if (node.flags & 8388608) {
58375                 var links = getNodeLinks(node);
58376                 if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) {
58377                     return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts);
58378                 }
58379                 if (node.parent.kind === 223 || node.parent.kind === 250 || node.parent.kind === 290) {
58380                     var links_2 = getNodeLinks(node.parent);
58381                     if (!links_2.hasReportedStatementInAmbientContext) {
58382                         return links_2.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts);
58383                     }
58384                 }
58385                 else {
58386                 }
58387             }
58388             return false;
58389         }
58390         function checkGrammarNumericLiteral(node) {
58391             if (node.numericLiteralFlags & 32) {
58392                 var diagnosticMessage = void 0;
58393                 if (languageVersion >= 1) {
58394                     diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0;
58395                 }
58396                 else if (ts.isChildOfNodeWithKind(node, 187)) {
58397                     diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0;
58398                 }
58399                 else if (ts.isChildOfNodeWithKind(node, 284)) {
58400                     diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0;
58401                 }
58402                 if (diagnosticMessage) {
58403                     var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40;
58404                     var literal = (withMinus ? "-" : "") + "0o" + node.text;
58405                     return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal);
58406                 }
58407             }
58408             checkNumericLiteralValueSize(node);
58409             return false;
58410         }
58411         function checkNumericLiteralValueSize(node) {
58412             if (node.numericLiteralFlags & 16 || node.text.length <= 15 || node.text.indexOf(".") !== -1) {
58413                 return;
58414             }
58415             var apparentValue = +ts.getTextOfNode(node);
58416             if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) {
58417                 return;
58418             }
58419             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));
58420         }
58421         function checkGrammarBigIntLiteral(node) {
58422             var literalType = ts.isLiteralTypeNode(node.parent) ||
58423                 ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent);
58424             if (!literalType) {
58425                 if (languageVersion < 7) {
58426                     if (grammarErrorOnNode(node, ts.Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020)) {
58427                         return true;
58428                     }
58429                 }
58430             }
58431             return false;
58432         }
58433         function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) {
58434             var sourceFile = ts.getSourceFileOfNode(node);
58435             if (!hasParseDiagnostics(sourceFile)) {
58436                 var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
58437                 diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), 0, message, arg0, arg1, arg2));
58438                 return true;
58439             }
58440             return false;
58441         }
58442         function getAmbientModules() {
58443             if (!ambientModulesCache) {
58444                 ambientModulesCache = [];
58445                 globals.forEach(function (global, sym) {
58446                     if (ambientModuleSymbolRegex.test(sym)) {
58447                         ambientModulesCache.push(global);
58448                     }
58449                 });
58450             }
58451             return ambientModulesCache;
58452         }
58453         function checkGrammarImportClause(node) {
58454             if (node.isTypeOnly && node.name && node.namedBindings) {
58455                 return grammarErrorOnNode(node, ts.Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both);
58456             }
58457             return false;
58458         }
58459         function checkGrammarImportCallExpression(node) {
58460             if (moduleKind === ts.ModuleKind.ES2015) {
58461                 return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system_or_umd);
58462             }
58463             if (node.typeArguments) {
58464                 return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments);
58465             }
58466             var nodeArguments = node.arguments;
58467             if (nodeArguments.length !== 1) {
58468                 return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_must_have_one_specifier_as_an_argument);
58469             }
58470             checkGrammarForDisallowedTrailingComma(nodeArguments);
58471             if (ts.isSpreadElement(nodeArguments[0])) {
58472                 return grammarErrorOnNode(nodeArguments[0], ts.Diagnostics.Specifier_of_dynamic_import_cannot_be_spread_element);
58473             }
58474             return false;
58475         }
58476         function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) {
58477             var sourceObjectFlags = ts.getObjectFlags(source);
58478             if (sourceObjectFlags & (4 | 16) && unionTarget.flags & 1048576) {
58479                 return ts.find(unionTarget.types, function (target) {
58480                     if (target.flags & 524288) {
58481                         var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target);
58482                         if (overlapObjFlags & 4) {
58483                             return source.target === target.target;
58484                         }
58485                         if (overlapObjFlags & 16) {
58486                             return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol;
58487                         }
58488                     }
58489                     return false;
58490                 });
58491             }
58492         }
58493         function findBestTypeForObjectLiteral(source, unionTarget) {
58494             if (ts.getObjectFlags(source) & 128 && forEachType(unionTarget, isArrayLikeType)) {
58495                 return ts.find(unionTarget.types, function (t) { return !isArrayLikeType(t); });
58496             }
58497         }
58498         function findBestTypeForInvokable(source, unionTarget) {
58499             var signatureKind = 0;
58500             var hasSignatures = getSignaturesOfType(source, signatureKind).length > 0 ||
58501                 (signatureKind = 1, getSignaturesOfType(source, signatureKind).length > 0);
58502             if (hasSignatures) {
58503                 return ts.find(unionTarget.types, function (t) { return getSignaturesOfType(t, signatureKind).length > 0; });
58504             }
58505         }
58506         function findMostOverlappyType(source, unionTarget) {
58507             var bestMatch;
58508             var matchingCount = 0;
58509             for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) {
58510                 var target = _a[_i];
58511                 var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]);
58512                 if (overlap.flags & 4194304) {
58513                     bestMatch = target;
58514                     matchingCount = Infinity;
58515                 }
58516                 else if (overlap.flags & 1048576) {
58517                     var len = ts.length(ts.filter(overlap.types, isUnitType));
58518                     if (len >= matchingCount) {
58519                         bestMatch = target;
58520                         matchingCount = len;
58521                     }
58522                 }
58523                 else if (isUnitType(overlap) && 1 >= matchingCount) {
58524                     bestMatch = target;
58525                     matchingCount = 1;
58526                 }
58527             }
58528             return bestMatch;
58529         }
58530         function filterPrimitivesIfContainsNonPrimitive(type) {
58531             if (maybeTypeOfKind(type, 67108864)) {
58532                 var result = filterType(type, function (t) { return !(t.flags & 131068); });
58533                 if (!(result.flags & 131072)) {
58534                     return result;
58535                 }
58536             }
58537             return type;
58538         }
58539         function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) {
58540             if (target.flags & 1048576 && source.flags & (2097152 | 524288)) {
58541                 var sourceProperties = getPropertiesOfType(source);
58542                 if (sourceProperties) {
58543                     var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
58544                     if (sourcePropertiesFiltered) {
58545                         return discriminateTypeByDiscriminableItems(target, ts.map(sourcePropertiesFiltered, function (p) { return [function () { return getTypeOfSymbol(p); }, p.escapedName]; }), isRelatedTo, undefined, skipPartial);
58546                     }
58547                 }
58548             }
58549             return undefined;
58550         }
58551     }
58552     ts.createTypeChecker = createTypeChecker;
58553     function isNotAccessor(declaration) {
58554         return !ts.isAccessor(declaration);
58555     }
58556     function isNotOverload(declaration) {
58557         return (declaration.kind !== 244 && declaration.kind !== 161) ||
58558             !!declaration.body;
58559     }
58560     function isDeclarationNameOrImportPropertyName(name) {
58561         switch (name.parent.kind) {
58562             case 258:
58563             case 263:
58564                 return ts.isIdentifier(name);
58565             default:
58566                 return ts.isDeclarationName(name);
58567         }
58568     }
58569     function isSomeImportDeclaration(decl) {
58570         switch (decl.kind) {
58571             case 255:
58572             case 253:
58573             case 256:
58574             case 258:
58575                 return true;
58576             case 75:
58577                 return decl.parent.kind === 258;
58578             default:
58579                 return false;
58580         }
58581     }
58582     var JsxNames;
58583     (function (JsxNames) {
58584         JsxNames.JSX = "JSX";
58585         JsxNames.IntrinsicElements = "IntrinsicElements";
58586         JsxNames.ElementClass = "ElementClass";
58587         JsxNames.ElementAttributesPropertyNameContainer = "ElementAttributesProperty";
58588         JsxNames.ElementChildrenAttributeNameContainer = "ElementChildrenAttribute";
58589         JsxNames.Element = "Element";
58590         JsxNames.IntrinsicAttributes = "IntrinsicAttributes";
58591         JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes";
58592         JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes";
58593     })(JsxNames || (JsxNames = {}));
58594     function getIterationTypesKeyFromIterationTypeKind(typeKind) {
58595         switch (typeKind) {
58596             case 0: return "yieldType";
58597             case 1: return "returnType";
58598             case 2: return "nextType";
58599         }
58600     }
58601     function signatureHasRestParameter(s) {
58602         return !!(s.flags & 1);
58603     }
58604     ts.signatureHasRestParameter = signatureHasRestParameter;
58605     function signatureHasLiteralTypes(s) {
58606         return !!(s.flags & 2);
58607     }
58608     ts.signatureHasLiteralTypes = signatureHasLiteralTypes;
58609 })(ts || (ts = {}));
58610 var ts;
58611 (function (ts) {
58612     function createSynthesizedNode(kind) {
58613         var node = ts.createNode(kind, -1, -1);
58614         node.flags |= 8;
58615         return node;
58616     }
58617     function updateNode(updated, original) {
58618         if (updated !== original) {
58619             setOriginalNode(updated, original);
58620             setTextRange(updated, original);
58621             ts.aggregateTransformFlags(updated);
58622         }
58623         return updated;
58624     }
58625     ts.updateNode = updateNode;
58626     function createNodeArray(elements, hasTrailingComma) {
58627         if (!elements || elements === ts.emptyArray) {
58628             elements = [];
58629         }
58630         else if (ts.isNodeArray(elements)) {
58631             return elements;
58632         }
58633         var array = elements;
58634         array.pos = -1;
58635         array.end = -1;
58636         array.hasTrailingComma = hasTrailingComma;
58637         return array;
58638     }
58639     ts.createNodeArray = createNodeArray;
58640     function getSynthesizedClone(node) {
58641         if (node === undefined) {
58642             return node;
58643         }
58644         var clone = createSynthesizedNode(node.kind);
58645         clone.flags |= node.flags;
58646         setOriginalNode(clone, node);
58647         for (var key in node) {
58648             if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) {
58649                 continue;
58650             }
58651             clone[key] = node[key];
58652         }
58653         return clone;
58654     }
58655     ts.getSynthesizedClone = getSynthesizedClone;
58656     function createLiteral(value, isSingleQuote) {
58657         if (typeof value === "number") {
58658             return createNumericLiteral(value + "");
58659         }
58660         if (typeof value === "object" && "base10Value" in value) {
58661             return createBigIntLiteral(ts.pseudoBigIntToString(value) + "n");
58662         }
58663         if (typeof value === "boolean") {
58664             return value ? createTrue() : createFalse();
58665         }
58666         if (ts.isString(value)) {
58667             var res = createStringLiteral(value);
58668             if (isSingleQuote)
58669                 res.singleQuote = true;
58670             return res;
58671         }
58672         return createLiteralFromNode(value);
58673     }
58674     ts.createLiteral = createLiteral;
58675     function createNumericLiteral(value, numericLiteralFlags) {
58676         if (numericLiteralFlags === void 0) { numericLiteralFlags = 0; }
58677         var node = createSynthesizedNode(8);
58678         node.text = value;
58679         node.numericLiteralFlags = numericLiteralFlags;
58680         return node;
58681     }
58682     ts.createNumericLiteral = createNumericLiteral;
58683     function createBigIntLiteral(value) {
58684         var node = createSynthesizedNode(9);
58685         node.text = value;
58686         return node;
58687     }
58688     ts.createBigIntLiteral = createBigIntLiteral;
58689     function createStringLiteral(text) {
58690         var node = createSynthesizedNode(10);
58691         node.text = text;
58692         return node;
58693     }
58694     ts.createStringLiteral = createStringLiteral;
58695     function createRegularExpressionLiteral(text) {
58696         var node = createSynthesizedNode(13);
58697         node.text = text;
58698         return node;
58699     }
58700     ts.createRegularExpressionLiteral = createRegularExpressionLiteral;
58701     function createLiteralFromNode(sourceNode) {
58702         var node = createStringLiteral(ts.getTextOfIdentifierOrLiteral(sourceNode));
58703         node.textSourceNode = sourceNode;
58704         return node;
58705     }
58706     function createIdentifier(text, typeArguments) {
58707         var node = createSynthesizedNode(75);
58708         node.escapedText = ts.escapeLeadingUnderscores(text);
58709         node.originalKeywordKind = text ? ts.stringToToken(text) : 0;
58710         node.autoGenerateFlags = 0;
58711         node.autoGenerateId = 0;
58712         if (typeArguments) {
58713             node.typeArguments = createNodeArray(typeArguments);
58714         }
58715         return node;
58716     }
58717     ts.createIdentifier = createIdentifier;
58718     function updateIdentifier(node, typeArguments) {
58719         return node.typeArguments !== typeArguments
58720             ? updateNode(createIdentifier(ts.idText(node), typeArguments), node)
58721             : node;
58722     }
58723     ts.updateIdentifier = updateIdentifier;
58724     var nextAutoGenerateId = 0;
58725     function createTempVariable(recordTempVariable, reservedInNestedScopes) {
58726         var name = createIdentifier("");
58727         name.autoGenerateFlags = 1;
58728         name.autoGenerateId = nextAutoGenerateId;
58729         nextAutoGenerateId++;
58730         if (recordTempVariable) {
58731             recordTempVariable(name);
58732         }
58733         if (reservedInNestedScopes) {
58734             name.autoGenerateFlags |= 8;
58735         }
58736         return name;
58737     }
58738     ts.createTempVariable = createTempVariable;
58739     function createLoopVariable() {
58740         var name = createIdentifier("");
58741         name.autoGenerateFlags = 2;
58742         name.autoGenerateId = nextAutoGenerateId;
58743         nextAutoGenerateId++;
58744         return name;
58745     }
58746     ts.createLoopVariable = createLoopVariable;
58747     function createUniqueName(text) {
58748         var name = createIdentifier(text);
58749         name.autoGenerateFlags = 3;
58750         name.autoGenerateId = nextAutoGenerateId;
58751         nextAutoGenerateId++;
58752         return name;
58753     }
58754     ts.createUniqueName = createUniqueName;
58755     function createOptimisticUniqueName(text) {
58756         var name = createIdentifier(text);
58757         name.autoGenerateFlags = 3 | 16;
58758         name.autoGenerateId = nextAutoGenerateId;
58759         nextAutoGenerateId++;
58760         return name;
58761     }
58762     ts.createOptimisticUniqueName = createOptimisticUniqueName;
58763     function createFileLevelUniqueName(text) {
58764         var name = createOptimisticUniqueName(text);
58765         name.autoGenerateFlags |= 32;
58766         return name;
58767     }
58768     ts.createFileLevelUniqueName = createFileLevelUniqueName;
58769     function getGeneratedNameForNode(node, flags) {
58770         var name = createIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "");
58771         name.autoGenerateFlags = 4 | flags;
58772         name.autoGenerateId = nextAutoGenerateId;
58773         name.original = node;
58774         nextAutoGenerateId++;
58775         return name;
58776     }
58777     ts.getGeneratedNameForNode = getGeneratedNameForNode;
58778     function createPrivateIdentifier(text) {
58779         if (text[0] !== "#") {
58780             ts.Debug.fail("First character of private identifier must be #: " + text);
58781         }
58782         var node = createSynthesizedNode(76);
58783         node.escapedText = ts.escapeLeadingUnderscores(text);
58784         return node;
58785     }
58786     ts.createPrivateIdentifier = createPrivateIdentifier;
58787     function createToken(token) {
58788         return createSynthesizedNode(token);
58789     }
58790     ts.createToken = createToken;
58791     function createSuper() {
58792         return createSynthesizedNode(102);
58793     }
58794     ts.createSuper = createSuper;
58795     function createThis() {
58796         return createSynthesizedNode(104);
58797     }
58798     ts.createThis = createThis;
58799     function createNull() {
58800         return createSynthesizedNode(100);
58801     }
58802     ts.createNull = createNull;
58803     function createTrue() {
58804         return createSynthesizedNode(106);
58805     }
58806     ts.createTrue = createTrue;
58807     function createFalse() {
58808         return createSynthesizedNode(91);
58809     }
58810     ts.createFalse = createFalse;
58811     function createModifier(kind) {
58812         return createToken(kind);
58813     }
58814     ts.createModifier = createModifier;
58815     function createModifiersFromModifierFlags(flags) {
58816         var result = [];
58817         if (flags & 1) {
58818             result.push(createModifier(89));
58819         }
58820         if (flags & 2) {
58821             result.push(createModifier(130));
58822         }
58823         if (flags & 512) {
58824             result.push(createModifier(84));
58825         }
58826         if (flags & 2048) {
58827             result.push(createModifier(81));
58828         }
58829         if (flags & 4) {
58830             result.push(createModifier(119));
58831         }
58832         if (flags & 8) {
58833             result.push(createModifier(117));
58834         }
58835         if (flags & 16) {
58836             result.push(createModifier(118));
58837         }
58838         if (flags & 128) {
58839             result.push(createModifier(122));
58840         }
58841         if (flags & 32) {
58842             result.push(createModifier(120));
58843         }
58844         if (flags & 64) {
58845             result.push(createModifier(138));
58846         }
58847         if (flags & 256) {
58848             result.push(createModifier(126));
58849         }
58850         return result;
58851     }
58852     ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags;
58853     function createQualifiedName(left, right) {
58854         var node = createSynthesizedNode(153);
58855         node.left = left;
58856         node.right = asName(right);
58857         return node;
58858     }
58859     ts.createQualifiedName = createQualifiedName;
58860     function updateQualifiedName(node, left, right) {
58861         return node.left !== left
58862             || node.right !== right
58863             ? updateNode(createQualifiedName(left, right), node)
58864             : node;
58865     }
58866     ts.updateQualifiedName = updateQualifiedName;
58867     function parenthesizeForComputedName(expression) {
58868         return ts.isCommaSequence(expression)
58869             ? createParen(expression)
58870             : expression;
58871     }
58872     function createComputedPropertyName(expression) {
58873         var node = createSynthesizedNode(154);
58874         node.expression = parenthesizeForComputedName(expression);
58875         return node;
58876     }
58877     ts.createComputedPropertyName = createComputedPropertyName;
58878     function updateComputedPropertyName(node, expression) {
58879         return node.expression !== expression
58880             ? updateNode(createComputedPropertyName(expression), node)
58881             : node;
58882     }
58883     ts.updateComputedPropertyName = updateComputedPropertyName;
58884     function createTypeParameterDeclaration(name, constraint, defaultType) {
58885         var node = createSynthesizedNode(155);
58886         node.name = asName(name);
58887         node.constraint = constraint;
58888         node.default = defaultType;
58889         return node;
58890     }
58891     ts.createTypeParameterDeclaration = createTypeParameterDeclaration;
58892     function updateTypeParameterDeclaration(node, name, constraint, defaultType) {
58893         return node.name !== name
58894             || node.constraint !== constraint
58895             || node.default !== defaultType
58896             ? updateNode(createTypeParameterDeclaration(name, constraint, defaultType), node)
58897             : node;
58898     }
58899     ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration;
58900     function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) {
58901         var node = createSynthesizedNode(156);
58902         node.decorators = asNodeArray(decorators);
58903         node.modifiers = asNodeArray(modifiers);
58904         node.dotDotDotToken = dotDotDotToken;
58905         node.name = asName(name);
58906         node.questionToken = questionToken;
58907         node.type = type;
58908         node.initializer = initializer ? ts.parenthesizeExpressionForList(initializer) : undefined;
58909         return node;
58910     }
58911     ts.createParameter = createParameter;
58912     function updateParameter(node, decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) {
58913         return node.decorators !== decorators
58914             || node.modifiers !== modifiers
58915             || node.dotDotDotToken !== dotDotDotToken
58916             || node.name !== name
58917             || node.questionToken !== questionToken
58918             || node.type !== type
58919             || node.initializer !== initializer
58920             ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer), node)
58921             : node;
58922     }
58923     ts.updateParameter = updateParameter;
58924     function createDecorator(expression) {
58925         var node = createSynthesizedNode(157);
58926         node.expression = ts.parenthesizeForAccess(expression);
58927         return node;
58928     }
58929     ts.createDecorator = createDecorator;
58930     function updateDecorator(node, expression) {
58931         return node.expression !== expression
58932             ? updateNode(createDecorator(expression), node)
58933             : node;
58934     }
58935     ts.updateDecorator = updateDecorator;
58936     function createPropertySignature(modifiers, name, questionToken, type, initializer) {
58937         var node = createSynthesizedNode(158);
58938         node.modifiers = asNodeArray(modifiers);
58939         node.name = asName(name);
58940         node.questionToken = questionToken;
58941         node.type = type;
58942         node.initializer = initializer;
58943         return node;
58944     }
58945     ts.createPropertySignature = createPropertySignature;
58946     function updatePropertySignature(node, modifiers, name, questionToken, type, initializer) {
58947         return node.modifiers !== modifiers
58948             || node.name !== name
58949             || node.questionToken !== questionToken
58950             || node.type !== type
58951             || node.initializer !== initializer
58952             ? updateNode(createPropertySignature(modifiers, name, questionToken, type, initializer), node)
58953             : node;
58954     }
58955     ts.updatePropertySignature = updatePropertySignature;
58956     function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) {
58957         var node = createSynthesizedNode(159);
58958         node.decorators = asNodeArray(decorators);
58959         node.modifiers = asNodeArray(modifiers);
58960         node.name = asName(name);
58961         node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 ? questionOrExclamationToken : undefined;
58962         node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 ? questionOrExclamationToken : undefined;
58963         node.type = type;
58964         node.initializer = initializer;
58965         return node;
58966     }
58967     ts.createProperty = createProperty;
58968     function updateProperty(node, decorators, modifiers, name, questionOrExclamationToken, type, initializer) {
58969         return node.decorators !== decorators
58970             || node.modifiers !== modifiers
58971             || node.name !== name
58972             || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 ? questionOrExclamationToken : undefined)
58973             || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 ? questionOrExclamationToken : undefined)
58974             || node.type !== type
58975             || node.initializer !== initializer
58976             ? updateNode(createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer), node)
58977             : node;
58978     }
58979     ts.updateProperty = updateProperty;
58980     function createMethodSignature(typeParameters, parameters, type, name, questionToken) {
58981         var node = createSignatureDeclaration(160, typeParameters, parameters, type);
58982         node.name = asName(name);
58983         node.questionToken = questionToken;
58984         return node;
58985     }
58986     ts.createMethodSignature = createMethodSignature;
58987     function updateMethodSignature(node, typeParameters, parameters, type, name, questionToken) {
58988         return node.typeParameters !== typeParameters
58989             || node.parameters !== parameters
58990             || node.type !== type
58991             || node.name !== name
58992             || node.questionToken !== questionToken
58993             ? updateNode(createMethodSignature(typeParameters, parameters, type, name, questionToken), node)
58994             : node;
58995     }
58996     ts.updateMethodSignature = updateMethodSignature;
58997     function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) {
58998         var node = createSynthesizedNode(161);
58999         node.decorators = asNodeArray(decorators);
59000         node.modifiers = asNodeArray(modifiers);
59001         node.asteriskToken = asteriskToken;
59002         node.name = asName(name);
59003         node.questionToken = questionToken;
59004         node.typeParameters = asNodeArray(typeParameters);
59005         node.parameters = createNodeArray(parameters);
59006         node.type = type;
59007         node.body = body;
59008         return node;
59009     }
59010     ts.createMethod = createMethod;
59011     function createMethodCall(object, methodName, argumentsList) {
59012         return createCall(createPropertyAccess(object, asName(methodName)), undefined, argumentsList);
59013     }
59014     function createGlobalMethodCall(globalObjectName, methodName, argumentsList) {
59015         return createMethodCall(createIdentifier(globalObjectName), methodName, argumentsList);
59016     }
59017     function createObjectDefinePropertyCall(target, propertyName, attributes) {
59018         return createGlobalMethodCall("Object", "defineProperty", [target, asExpression(propertyName), attributes]);
59019     }
59020     ts.createObjectDefinePropertyCall = createObjectDefinePropertyCall;
59021     function tryAddPropertyAssignment(properties, propertyName, expression) {
59022         if (expression) {
59023             properties.push(createPropertyAssignment(propertyName, expression));
59024             return true;
59025         }
59026         return false;
59027     }
59028     function createPropertyDescriptor(attributes, singleLine) {
59029         var properties = [];
59030         tryAddPropertyAssignment(properties, "enumerable", asExpression(attributes.enumerable));
59031         tryAddPropertyAssignment(properties, "configurable", asExpression(attributes.configurable));
59032         var isData = tryAddPropertyAssignment(properties, "writable", asExpression(attributes.writable));
59033         isData = tryAddPropertyAssignment(properties, "value", attributes.value) || isData;
59034         var isAccessor = tryAddPropertyAssignment(properties, "get", attributes.get);
59035         isAccessor = tryAddPropertyAssignment(properties, "set", attributes.set) || isAccessor;
59036         ts.Debug.assert(!(isData && isAccessor), "A PropertyDescriptor may not be both an accessor descriptor and a data descriptor.");
59037         return createObjectLiteral(properties, !singleLine);
59038     }
59039     ts.createPropertyDescriptor = createPropertyDescriptor;
59040     function updateMethod(node, decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) {
59041         return node.decorators !== decorators
59042             || node.modifiers !== modifiers
59043             || node.asteriskToken !== asteriskToken
59044             || node.name !== name
59045             || node.questionToken !== questionToken
59046             || node.typeParameters !== typeParameters
59047             || node.parameters !== parameters
59048             || node.type !== type
59049             || node.body !== body
59050             ? updateNode(createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body), node)
59051             : node;
59052     }
59053     ts.updateMethod = updateMethod;
59054     function createConstructor(decorators, modifiers, parameters, body) {
59055         var node = createSynthesizedNode(162);
59056         node.decorators = asNodeArray(decorators);
59057         node.modifiers = asNodeArray(modifiers);
59058         node.typeParameters = undefined;
59059         node.parameters = createNodeArray(parameters);
59060         node.type = undefined;
59061         node.body = body;
59062         return node;
59063     }
59064     ts.createConstructor = createConstructor;
59065     function updateConstructor(node, decorators, modifiers, parameters, body) {
59066         return node.decorators !== decorators
59067             || node.modifiers !== modifiers
59068             || node.parameters !== parameters
59069             || node.body !== body
59070             ? updateNode(createConstructor(decorators, modifiers, parameters, body), node)
59071             : node;
59072     }
59073     ts.updateConstructor = updateConstructor;
59074     function createGetAccessor(decorators, modifiers, name, parameters, type, body) {
59075         var node = createSynthesizedNode(163);
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.type = type;
59082         node.body = body;
59083         return node;
59084     }
59085     ts.createGetAccessor = createGetAccessor;
59086     function updateGetAccessor(node, decorators, modifiers, name, parameters, type, body) {
59087         return node.decorators !== decorators
59088             || node.modifiers !== modifiers
59089             || node.name !== name
59090             || node.parameters !== parameters
59091             || node.type !== type
59092             || node.body !== body
59093             ? updateNode(createGetAccessor(decorators, modifiers, name, parameters, type, body), node)
59094             : node;
59095     }
59096     ts.updateGetAccessor = updateGetAccessor;
59097     function createSetAccessor(decorators, modifiers, name, parameters, body) {
59098         var node = createSynthesizedNode(164);
59099         node.decorators = asNodeArray(decorators);
59100         node.modifiers = asNodeArray(modifiers);
59101         node.name = asName(name);
59102         node.typeParameters = undefined;
59103         node.parameters = createNodeArray(parameters);
59104         node.body = body;
59105         return node;
59106     }
59107     ts.createSetAccessor = createSetAccessor;
59108     function updateSetAccessor(node, decorators, modifiers, name, parameters, body) {
59109         return node.decorators !== decorators
59110             || node.modifiers !== modifiers
59111             || node.name !== name
59112             || node.parameters !== parameters
59113             || node.body !== body
59114             ? updateNode(createSetAccessor(decorators, modifiers, name, parameters, body), node)
59115             : node;
59116     }
59117     ts.updateSetAccessor = updateSetAccessor;
59118     function createCallSignature(typeParameters, parameters, type) {
59119         return createSignatureDeclaration(165, typeParameters, parameters, type);
59120     }
59121     ts.createCallSignature = createCallSignature;
59122     function updateCallSignature(node, typeParameters, parameters, type) {
59123         return updateSignatureDeclaration(node, typeParameters, parameters, type);
59124     }
59125     ts.updateCallSignature = updateCallSignature;
59126     function createConstructSignature(typeParameters, parameters, type) {
59127         return createSignatureDeclaration(166, typeParameters, parameters, type);
59128     }
59129     ts.createConstructSignature = createConstructSignature;
59130     function updateConstructSignature(node, typeParameters, parameters, type) {
59131         return updateSignatureDeclaration(node, typeParameters, parameters, type);
59132     }
59133     ts.updateConstructSignature = updateConstructSignature;
59134     function createIndexSignature(decorators, modifiers, parameters, type) {
59135         var node = createSynthesizedNode(167);
59136         node.decorators = asNodeArray(decorators);
59137         node.modifiers = asNodeArray(modifiers);
59138         node.parameters = createNodeArray(parameters);
59139         node.type = type;
59140         return node;
59141     }
59142     ts.createIndexSignature = createIndexSignature;
59143     function updateIndexSignature(node, decorators, modifiers, parameters, type) {
59144         return node.parameters !== parameters
59145             || node.type !== type
59146             || node.decorators !== decorators
59147             || node.modifiers !== modifiers
59148             ? updateNode(createIndexSignature(decorators, modifiers, parameters, type), node)
59149             : node;
59150     }
59151     ts.updateIndexSignature = updateIndexSignature;
59152     function createSignatureDeclaration(kind, typeParameters, parameters, type, typeArguments) {
59153         var node = createSynthesizedNode(kind);
59154         node.typeParameters = asNodeArray(typeParameters);
59155         node.parameters = asNodeArray(parameters);
59156         node.type = type;
59157         node.typeArguments = asNodeArray(typeArguments);
59158         return node;
59159     }
59160     ts.createSignatureDeclaration = createSignatureDeclaration;
59161     function updateSignatureDeclaration(node, typeParameters, parameters, type) {
59162         return node.typeParameters !== typeParameters
59163             || node.parameters !== parameters
59164             || node.type !== type
59165             ? updateNode(createSignatureDeclaration(node.kind, typeParameters, parameters, type), node)
59166             : node;
59167     }
59168     function createKeywordTypeNode(kind) {
59169         return createSynthesizedNode(kind);
59170     }
59171     ts.createKeywordTypeNode = createKeywordTypeNode;
59172     function createTypePredicateNode(parameterName, type) {
59173         return createTypePredicateNodeWithModifier(undefined, parameterName, type);
59174     }
59175     ts.createTypePredicateNode = createTypePredicateNode;
59176     function createTypePredicateNodeWithModifier(assertsModifier, parameterName, type) {
59177         var node = createSynthesizedNode(168);
59178         node.assertsModifier = assertsModifier;
59179         node.parameterName = asName(parameterName);
59180         node.type = type;
59181         return node;
59182     }
59183     ts.createTypePredicateNodeWithModifier = createTypePredicateNodeWithModifier;
59184     function updateTypePredicateNode(node, parameterName, type) {
59185         return updateTypePredicateNodeWithModifier(node, node.assertsModifier, parameterName, type);
59186     }
59187     ts.updateTypePredicateNode = updateTypePredicateNode;
59188     function updateTypePredicateNodeWithModifier(node, assertsModifier, parameterName, type) {
59189         return node.assertsModifier !== assertsModifier
59190             || node.parameterName !== parameterName
59191             || node.type !== type
59192             ? updateNode(createTypePredicateNodeWithModifier(assertsModifier, parameterName, type), node)
59193             : node;
59194     }
59195     ts.updateTypePredicateNodeWithModifier = updateTypePredicateNodeWithModifier;
59196     function createTypeReferenceNode(typeName, typeArguments) {
59197         var node = createSynthesizedNode(169);
59198         node.typeName = asName(typeName);
59199         node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments);
59200         return node;
59201     }
59202     ts.createTypeReferenceNode = createTypeReferenceNode;
59203     function updateTypeReferenceNode(node, typeName, typeArguments) {
59204         return node.typeName !== typeName
59205             || node.typeArguments !== typeArguments
59206             ? updateNode(createTypeReferenceNode(typeName, typeArguments), node)
59207             : node;
59208     }
59209     ts.updateTypeReferenceNode = updateTypeReferenceNode;
59210     function createFunctionTypeNode(typeParameters, parameters, type) {
59211         return createSignatureDeclaration(170, typeParameters, parameters, type);
59212     }
59213     ts.createFunctionTypeNode = createFunctionTypeNode;
59214     function updateFunctionTypeNode(node, typeParameters, parameters, type) {
59215         return updateSignatureDeclaration(node, typeParameters, parameters, type);
59216     }
59217     ts.updateFunctionTypeNode = updateFunctionTypeNode;
59218     function createConstructorTypeNode(typeParameters, parameters, type) {
59219         return createSignatureDeclaration(171, typeParameters, parameters, type);
59220     }
59221     ts.createConstructorTypeNode = createConstructorTypeNode;
59222     function updateConstructorTypeNode(node, typeParameters, parameters, type) {
59223         return updateSignatureDeclaration(node, typeParameters, parameters, type);
59224     }
59225     ts.updateConstructorTypeNode = updateConstructorTypeNode;
59226     function createTypeQueryNode(exprName) {
59227         var node = createSynthesizedNode(172);
59228         node.exprName = exprName;
59229         return node;
59230     }
59231     ts.createTypeQueryNode = createTypeQueryNode;
59232     function updateTypeQueryNode(node, exprName) {
59233         return node.exprName !== exprName
59234             ? updateNode(createTypeQueryNode(exprName), node)
59235             : node;
59236     }
59237     ts.updateTypeQueryNode = updateTypeQueryNode;
59238     function createTypeLiteralNode(members) {
59239         var node = createSynthesizedNode(173);
59240         node.members = createNodeArray(members);
59241         return node;
59242     }
59243     ts.createTypeLiteralNode = createTypeLiteralNode;
59244     function updateTypeLiteralNode(node, members) {
59245         return node.members !== members
59246             ? updateNode(createTypeLiteralNode(members), node)
59247             : node;
59248     }
59249     ts.updateTypeLiteralNode = updateTypeLiteralNode;
59250     function createArrayTypeNode(elementType) {
59251         var node = createSynthesizedNode(174);
59252         node.elementType = ts.parenthesizeArrayTypeMember(elementType);
59253         return node;
59254     }
59255     ts.createArrayTypeNode = createArrayTypeNode;
59256     function updateArrayTypeNode(node, elementType) {
59257         return node.elementType !== elementType
59258             ? updateNode(createArrayTypeNode(elementType), node)
59259             : node;
59260     }
59261     ts.updateArrayTypeNode = updateArrayTypeNode;
59262     function createTupleTypeNode(elementTypes) {
59263         var node = createSynthesizedNode(175);
59264         node.elementTypes = createNodeArray(elementTypes);
59265         return node;
59266     }
59267     ts.createTupleTypeNode = createTupleTypeNode;
59268     function updateTupleTypeNode(node, elementTypes) {
59269         return node.elementTypes !== elementTypes
59270             ? updateNode(createTupleTypeNode(elementTypes), node)
59271             : node;
59272     }
59273     ts.updateTupleTypeNode = updateTupleTypeNode;
59274     function createOptionalTypeNode(type) {
59275         var node = createSynthesizedNode(176);
59276         node.type = ts.parenthesizeArrayTypeMember(type);
59277         return node;
59278     }
59279     ts.createOptionalTypeNode = createOptionalTypeNode;
59280     function updateOptionalTypeNode(node, type) {
59281         return node.type !== type
59282             ? updateNode(createOptionalTypeNode(type), node)
59283             : node;
59284     }
59285     ts.updateOptionalTypeNode = updateOptionalTypeNode;
59286     function createRestTypeNode(type) {
59287         var node = createSynthesizedNode(177);
59288         node.type = type;
59289         return node;
59290     }
59291     ts.createRestTypeNode = createRestTypeNode;
59292     function updateRestTypeNode(node, type) {
59293         return node.type !== type
59294             ? updateNode(createRestTypeNode(type), node)
59295             : node;
59296     }
59297     ts.updateRestTypeNode = updateRestTypeNode;
59298     function createUnionTypeNode(types) {
59299         return createUnionOrIntersectionTypeNode(178, types);
59300     }
59301     ts.createUnionTypeNode = createUnionTypeNode;
59302     function updateUnionTypeNode(node, types) {
59303         return updateUnionOrIntersectionTypeNode(node, types);
59304     }
59305     ts.updateUnionTypeNode = updateUnionTypeNode;
59306     function createIntersectionTypeNode(types) {
59307         return createUnionOrIntersectionTypeNode(179, types);
59308     }
59309     ts.createIntersectionTypeNode = createIntersectionTypeNode;
59310     function updateIntersectionTypeNode(node, types) {
59311         return updateUnionOrIntersectionTypeNode(node, types);
59312     }
59313     ts.updateIntersectionTypeNode = updateIntersectionTypeNode;
59314     function createUnionOrIntersectionTypeNode(kind, types) {
59315         var node = createSynthesizedNode(kind);
59316         node.types = ts.parenthesizeElementTypeMembers(types);
59317         return node;
59318     }
59319     ts.createUnionOrIntersectionTypeNode = createUnionOrIntersectionTypeNode;
59320     function updateUnionOrIntersectionTypeNode(node, types) {
59321         return node.types !== types
59322             ? updateNode(createUnionOrIntersectionTypeNode(node.kind, types), node)
59323             : node;
59324     }
59325     function createConditionalTypeNode(checkType, extendsType, trueType, falseType) {
59326         var node = createSynthesizedNode(180);
59327         node.checkType = ts.parenthesizeConditionalTypeMember(checkType);
59328         node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType);
59329         node.trueType = trueType;
59330         node.falseType = falseType;
59331         return node;
59332     }
59333     ts.createConditionalTypeNode = createConditionalTypeNode;
59334     function updateConditionalTypeNode(node, checkType, extendsType, trueType, falseType) {
59335         return node.checkType !== checkType
59336             || node.extendsType !== extendsType
59337             || node.trueType !== trueType
59338             || node.falseType !== falseType
59339             ? updateNode(createConditionalTypeNode(checkType, extendsType, trueType, falseType), node)
59340             : node;
59341     }
59342     ts.updateConditionalTypeNode = updateConditionalTypeNode;
59343     function createInferTypeNode(typeParameter) {
59344         var node = createSynthesizedNode(181);
59345         node.typeParameter = typeParameter;
59346         return node;
59347     }
59348     ts.createInferTypeNode = createInferTypeNode;
59349     function updateInferTypeNode(node, typeParameter) {
59350         return node.typeParameter !== typeParameter
59351             ? updateNode(createInferTypeNode(typeParameter), node)
59352             : node;
59353     }
59354     ts.updateInferTypeNode = updateInferTypeNode;
59355     function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) {
59356         var node = createSynthesizedNode(188);
59357         node.argument = argument;
59358         node.qualifier = qualifier;
59359         node.typeArguments = ts.parenthesizeTypeParameters(typeArguments);
59360         node.isTypeOf = isTypeOf;
59361         return node;
59362     }
59363     ts.createImportTypeNode = createImportTypeNode;
59364     function updateImportTypeNode(node, argument, qualifier, typeArguments, isTypeOf) {
59365         return node.argument !== argument
59366             || node.qualifier !== qualifier
59367             || node.typeArguments !== typeArguments
59368             || node.isTypeOf !== isTypeOf
59369             ? updateNode(createImportTypeNode(argument, qualifier, typeArguments, isTypeOf), node)
59370             : node;
59371     }
59372     ts.updateImportTypeNode = updateImportTypeNode;
59373     function createParenthesizedType(type) {
59374         var node = createSynthesizedNode(182);
59375         node.type = type;
59376         return node;
59377     }
59378     ts.createParenthesizedType = createParenthesizedType;
59379     function updateParenthesizedType(node, type) {
59380         return node.type !== type
59381             ? updateNode(createParenthesizedType(type), node)
59382             : node;
59383     }
59384     ts.updateParenthesizedType = updateParenthesizedType;
59385     function createThisTypeNode() {
59386         return createSynthesizedNode(183);
59387     }
59388     ts.createThisTypeNode = createThisTypeNode;
59389     function createTypeOperatorNode(operatorOrType, type) {
59390         var node = createSynthesizedNode(184);
59391         node.operator = typeof operatorOrType === "number" ? operatorOrType : 134;
59392         node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType);
59393         return node;
59394     }
59395     ts.createTypeOperatorNode = createTypeOperatorNode;
59396     function updateTypeOperatorNode(node, type) {
59397         return node.type !== type ? updateNode(createTypeOperatorNode(node.operator, type), node) : node;
59398     }
59399     ts.updateTypeOperatorNode = updateTypeOperatorNode;
59400     function createIndexedAccessTypeNode(objectType, indexType) {
59401         var node = createSynthesizedNode(185);
59402         node.objectType = ts.parenthesizeElementTypeMember(objectType);
59403         node.indexType = indexType;
59404         return node;
59405     }
59406     ts.createIndexedAccessTypeNode = createIndexedAccessTypeNode;
59407     function updateIndexedAccessTypeNode(node, objectType, indexType) {
59408         return node.objectType !== objectType
59409             || node.indexType !== indexType
59410             ? updateNode(createIndexedAccessTypeNode(objectType, indexType), node)
59411             : node;
59412     }
59413     ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode;
59414     function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) {
59415         var node = createSynthesizedNode(186);
59416         node.readonlyToken = readonlyToken;
59417         node.typeParameter = typeParameter;
59418         node.questionToken = questionToken;
59419         node.type = type;
59420         return node;
59421     }
59422     ts.createMappedTypeNode = createMappedTypeNode;
59423     function updateMappedTypeNode(node, readonlyToken, typeParameter, questionToken, type) {
59424         return node.readonlyToken !== readonlyToken
59425             || node.typeParameter !== typeParameter
59426             || node.questionToken !== questionToken
59427             || node.type !== type
59428             ? updateNode(createMappedTypeNode(readonlyToken, typeParameter, questionToken, type), node)
59429             : node;
59430     }
59431     ts.updateMappedTypeNode = updateMappedTypeNode;
59432     function createLiteralTypeNode(literal) {
59433         var node = createSynthesizedNode(187);
59434         node.literal = literal;
59435         return node;
59436     }
59437     ts.createLiteralTypeNode = createLiteralTypeNode;
59438     function updateLiteralTypeNode(node, literal) {
59439         return node.literal !== literal
59440             ? updateNode(createLiteralTypeNode(literal), node)
59441             : node;
59442     }
59443     ts.updateLiteralTypeNode = updateLiteralTypeNode;
59444     function createObjectBindingPattern(elements) {
59445         var node = createSynthesizedNode(189);
59446         node.elements = createNodeArray(elements);
59447         return node;
59448     }
59449     ts.createObjectBindingPattern = createObjectBindingPattern;
59450     function updateObjectBindingPattern(node, elements) {
59451         return node.elements !== elements
59452             ? updateNode(createObjectBindingPattern(elements), node)
59453             : node;
59454     }
59455     ts.updateObjectBindingPattern = updateObjectBindingPattern;
59456     function createArrayBindingPattern(elements) {
59457         var node = createSynthesizedNode(190);
59458         node.elements = createNodeArray(elements);
59459         return node;
59460     }
59461     ts.createArrayBindingPattern = createArrayBindingPattern;
59462     function updateArrayBindingPattern(node, elements) {
59463         return node.elements !== elements
59464             ? updateNode(createArrayBindingPattern(elements), node)
59465             : node;
59466     }
59467     ts.updateArrayBindingPattern = updateArrayBindingPattern;
59468     function createBindingElement(dotDotDotToken, propertyName, name, initializer) {
59469         var node = createSynthesizedNode(191);
59470         node.dotDotDotToken = dotDotDotToken;
59471         node.propertyName = asName(propertyName);
59472         node.name = asName(name);
59473         node.initializer = initializer;
59474         return node;
59475     }
59476     ts.createBindingElement = createBindingElement;
59477     function updateBindingElement(node, dotDotDotToken, propertyName, name, initializer) {
59478         return node.propertyName !== propertyName
59479             || node.dotDotDotToken !== dotDotDotToken
59480             || node.name !== name
59481             || node.initializer !== initializer
59482             ? updateNode(createBindingElement(dotDotDotToken, propertyName, name, initializer), node)
59483             : node;
59484     }
59485     ts.updateBindingElement = updateBindingElement;
59486     function createArrayLiteral(elements, multiLine) {
59487         var node = createSynthesizedNode(192);
59488         node.elements = ts.parenthesizeListElements(createNodeArray(elements));
59489         if (multiLine)
59490             node.multiLine = true;
59491         return node;
59492     }
59493     ts.createArrayLiteral = createArrayLiteral;
59494     function updateArrayLiteral(node, elements) {
59495         return node.elements !== elements
59496             ? updateNode(createArrayLiteral(elements, node.multiLine), node)
59497             : node;
59498     }
59499     ts.updateArrayLiteral = updateArrayLiteral;
59500     function createObjectLiteral(properties, multiLine) {
59501         var node = createSynthesizedNode(193);
59502         node.properties = createNodeArray(properties);
59503         if (multiLine)
59504             node.multiLine = true;
59505         return node;
59506     }
59507     ts.createObjectLiteral = createObjectLiteral;
59508     function updateObjectLiteral(node, properties) {
59509         return node.properties !== properties
59510             ? updateNode(createObjectLiteral(properties, node.multiLine), node)
59511             : node;
59512     }
59513     ts.updateObjectLiteral = updateObjectLiteral;
59514     function createPropertyAccess(expression, name) {
59515         var node = createSynthesizedNode(194);
59516         node.expression = ts.parenthesizeForAccess(expression);
59517         node.name = asName(name);
59518         setEmitFlags(node, 131072);
59519         return node;
59520     }
59521     ts.createPropertyAccess = createPropertyAccess;
59522     function updatePropertyAccess(node, expression, name) {
59523         if (ts.isPropertyAccessChain(node)) {
59524             return updatePropertyAccessChain(node, expression, node.questionDotToken, ts.cast(name, ts.isIdentifier));
59525         }
59526         return node.expression !== expression
59527             || node.name !== name
59528             ? updateNode(setEmitFlags(createPropertyAccess(expression, name), ts.getEmitFlags(node)), node)
59529             : node;
59530     }
59531     ts.updatePropertyAccess = updatePropertyAccess;
59532     function createPropertyAccessChain(expression, questionDotToken, name) {
59533         var node = createSynthesizedNode(194);
59534         node.flags |= 32;
59535         node.expression = ts.parenthesizeForAccess(expression);
59536         node.questionDotToken = questionDotToken;
59537         node.name = asName(name);
59538         setEmitFlags(node, 131072);
59539         return node;
59540     }
59541     ts.createPropertyAccessChain = createPropertyAccessChain;
59542     function updatePropertyAccessChain(node, expression, questionDotToken, name) {
59543         ts.Debug.assert(!!(node.flags & 32), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead.");
59544         return node.expression !== expression
59545             || node.questionDotToken !== questionDotToken
59546             || node.name !== name
59547             ? updateNode(setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), ts.getEmitFlags(node)), node)
59548             : node;
59549     }
59550     ts.updatePropertyAccessChain = updatePropertyAccessChain;
59551     function createElementAccess(expression, index) {
59552         var node = createSynthesizedNode(195);
59553         node.expression = ts.parenthesizeForAccess(expression);
59554         node.argumentExpression = asExpression(index);
59555         return node;
59556     }
59557     ts.createElementAccess = createElementAccess;
59558     function updateElementAccess(node, expression, argumentExpression) {
59559         if (ts.isOptionalChain(node)) {
59560             return updateElementAccessChain(node, expression, node.questionDotToken, argumentExpression);
59561         }
59562         return node.expression !== expression
59563             || node.argumentExpression !== argumentExpression
59564             ? updateNode(createElementAccess(expression, argumentExpression), node)
59565             : node;
59566     }
59567     ts.updateElementAccess = updateElementAccess;
59568     function createElementAccessChain(expression, questionDotToken, index) {
59569         var node = createSynthesizedNode(195);
59570         node.flags |= 32;
59571         node.expression = ts.parenthesizeForAccess(expression);
59572         node.questionDotToken = questionDotToken;
59573         node.argumentExpression = asExpression(index);
59574         return node;
59575     }
59576     ts.createElementAccessChain = createElementAccessChain;
59577     function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) {
59578         ts.Debug.assert(!!(node.flags & 32), "Cannot update an ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead.");
59579         return node.expression !== expression
59580             || node.questionDotToken !== questionDotToken
59581             || node.argumentExpression !== argumentExpression
59582             ? updateNode(createElementAccessChain(expression, questionDotToken, argumentExpression), node)
59583             : node;
59584     }
59585     ts.updateElementAccessChain = updateElementAccessChain;
59586     function createCall(expression, typeArguments, argumentsArray) {
59587         var node = createSynthesizedNode(196);
59588         node.expression = ts.parenthesizeForAccess(expression);
59589         node.typeArguments = asNodeArray(typeArguments);
59590         node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray));
59591         return node;
59592     }
59593     ts.createCall = createCall;
59594     function updateCall(node, expression, typeArguments, argumentsArray) {
59595         if (ts.isOptionalChain(node)) {
59596             return updateCallChain(node, expression, node.questionDotToken, typeArguments, argumentsArray);
59597         }
59598         return node.expression !== expression
59599             || node.typeArguments !== typeArguments
59600             || node.arguments !== argumentsArray
59601             ? updateNode(createCall(expression, typeArguments, argumentsArray), node)
59602             : node;
59603     }
59604     ts.updateCall = updateCall;
59605     function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) {
59606         var node = createSynthesizedNode(196);
59607         node.flags |= 32;
59608         node.expression = ts.parenthesizeForAccess(expression);
59609         node.questionDotToken = questionDotToken;
59610         node.typeArguments = asNodeArray(typeArguments);
59611         node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray));
59612         return node;
59613     }
59614     ts.createCallChain = createCallChain;
59615     function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) {
59616         ts.Debug.assert(!!(node.flags & 32), "Cannot update a CallExpression using updateCallChain. Use updateCall instead.");
59617         return node.expression !== expression
59618             || node.questionDotToken !== questionDotToken
59619             || node.typeArguments !== typeArguments
59620             || node.arguments !== argumentsArray
59621             ? updateNode(createCallChain(expression, questionDotToken, typeArguments, argumentsArray), node)
59622             : node;
59623     }
59624     ts.updateCallChain = updateCallChain;
59625     function createNew(expression, typeArguments, argumentsArray) {
59626         var node = createSynthesizedNode(197);
59627         node.expression = ts.parenthesizeForNew(expression);
59628         node.typeArguments = asNodeArray(typeArguments);
59629         node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined;
59630         return node;
59631     }
59632     ts.createNew = createNew;
59633     function updateNew(node, expression, typeArguments, argumentsArray) {
59634         return node.expression !== expression
59635             || node.typeArguments !== typeArguments
59636             || node.arguments !== argumentsArray
59637             ? updateNode(createNew(expression, typeArguments, argumentsArray), node)
59638             : node;
59639     }
59640     ts.updateNew = updateNew;
59641     function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) {
59642         var node = createSynthesizedNode(198);
59643         node.tag = ts.parenthesizeForAccess(tag);
59644         if (template) {
59645             node.typeArguments = asNodeArray(typeArgumentsOrTemplate);
59646             node.template = template;
59647         }
59648         else {
59649             node.typeArguments = undefined;
59650             node.template = typeArgumentsOrTemplate;
59651         }
59652         return node;
59653     }
59654     ts.createTaggedTemplate = createTaggedTemplate;
59655     function updateTaggedTemplate(node, tag, typeArgumentsOrTemplate, template) {
59656         return node.tag !== tag
59657             || (template
59658                 ? node.typeArguments !== typeArgumentsOrTemplate || node.template !== template
59659                 : node.typeArguments !== undefined || node.template !== typeArgumentsOrTemplate)
59660             ? updateNode(createTaggedTemplate(tag, typeArgumentsOrTemplate, template), node)
59661             : node;
59662     }
59663     ts.updateTaggedTemplate = updateTaggedTemplate;
59664     function createTypeAssertion(type, expression) {
59665         var node = createSynthesizedNode(199);
59666         node.type = type;
59667         node.expression = ts.parenthesizePrefixOperand(expression);
59668         return node;
59669     }
59670     ts.createTypeAssertion = createTypeAssertion;
59671     function updateTypeAssertion(node, type, expression) {
59672         return node.type !== type
59673             || node.expression !== expression
59674             ? updateNode(createTypeAssertion(type, expression), node)
59675             : node;
59676     }
59677     ts.updateTypeAssertion = updateTypeAssertion;
59678     function createParen(expression) {
59679         var node = createSynthesizedNode(200);
59680         node.expression = expression;
59681         return node;
59682     }
59683     ts.createParen = createParen;
59684     function updateParen(node, expression) {
59685         return node.expression !== expression
59686             ? updateNode(createParen(expression), node)
59687             : node;
59688     }
59689     ts.updateParen = updateParen;
59690     function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
59691         var node = createSynthesizedNode(201);
59692         node.modifiers = asNodeArray(modifiers);
59693         node.asteriskToken = asteriskToken;
59694         node.name = asName(name);
59695         node.typeParameters = asNodeArray(typeParameters);
59696         node.parameters = createNodeArray(parameters);
59697         node.type = type;
59698         node.body = body;
59699         return node;
59700     }
59701     ts.createFunctionExpression = createFunctionExpression;
59702     function updateFunctionExpression(node, modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
59703         return node.name !== name
59704             || node.modifiers !== modifiers
59705             || node.asteriskToken !== asteriskToken
59706             || node.typeParameters !== typeParameters
59707             || node.parameters !== parameters
59708             || node.type !== type
59709             || node.body !== body
59710             ? updateNode(createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body), node)
59711             : node;
59712     }
59713     ts.updateFunctionExpression = updateFunctionExpression;
59714     function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) {
59715         var node = createSynthesizedNode(202);
59716         node.modifiers = asNodeArray(modifiers);
59717         node.typeParameters = asNodeArray(typeParameters);
59718         node.parameters = createNodeArray(parameters);
59719         node.type = type;
59720         node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(38);
59721         node.body = ts.parenthesizeConciseBody(body);
59722         return node;
59723     }
59724     ts.createArrowFunction = createArrowFunction;
59725     function updateArrowFunction(node, modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) {
59726         return node.modifiers !== modifiers
59727             || node.typeParameters !== typeParameters
59728             || node.parameters !== parameters
59729             || node.type !== type
59730             || node.equalsGreaterThanToken !== equalsGreaterThanToken
59731             || node.body !== body
59732             ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body), node)
59733             : node;
59734     }
59735     ts.updateArrowFunction = updateArrowFunction;
59736     function createDelete(expression) {
59737         var node = createSynthesizedNode(203);
59738         node.expression = ts.parenthesizePrefixOperand(expression);
59739         return node;
59740     }
59741     ts.createDelete = createDelete;
59742     function updateDelete(node, expression) {
59743         return node.expression !== expression
59744             ? updateNode(createDelete(expression), node)
59745             : node;
59746     }
59747     ts.updateDelete = updateDelete;
59748     function createTypeOf(expression) {
59749         var node = createSynthesizedNode(204);
59750         node.expression = ts.parenthesizePrefixOperand(expression);
59751         return node;
59752     }
59753     ts.createTypeOf = createTypeOf;
59754     function updateTypeOf(node, expression) {
59755         return node.expression !== expression
59756             ? updateNode(createTypeOf(expression), node)
59757             : node;
59758     }
59759     ts.updateTypeOf = updateTypeOf;
59760     function createVoid(expression) {
59761         var node = createSynthesizedNode(205);
59762         node.expression = ts.parenthesizePrefixOperand(expression);
59763         return node;
59764     }
59765     ts.createVoid = createVoid;
59766     function updateVoid(node, expression) {
59767         return node.expression !== expression
59768             ? updateNode(createVoid(expression), node)
59769             : node;
59770     }
59771     ts.updateVoid = updateVoid;
59772     function createAwait(expression) {
59773         var node = createSynthesizedNode(206);
59774         node.expression = ts.parenthesizePrefixOperand(expression);
59775         return node;
59776     }
59777     ts.createAwait = createAwait;
59778     function updateAwait(node, expression) {
59779         return node.expression !== expression
59780             ? updateNode(createAwait(expression), node)
59781             : node;
59782     }
59783     ts.updateAwait = updateAwait;
59784     function createPrefix(operator, operand) {
59785         var node = createSynthesizedNode(207);
59786         node.operator = operator;
59787         node.operand = ts.parenthesizePrefixOperand(operand);
59788         return node;
59789     }
59790     ts.createPrefix = createPrefix;
59791     function updatePrefix(node, operand) {
59792         return node.operand !== operand
59793             ? updateNode(createPrefix(node.operator, operand), node)
59794             : node;
59795     }
59796     ts.updatePrefix = updatePrefix;
59797     function createPostfix(operand, operator) {
59798         var node = createSynthesizedNode(208);
59799         node.operand = ts.parenthesizePostfixOperand(operand);
59800         node.operator = operator;
59801         return node;
59802     }
59803     ts.createPostfix = createPostfix;
59804     function updatePostfix(node, operand) {
59805         return node.operand !== operand
59806             ? updateNode(createPostfix(operand, node.operator), node)
59807             : node;
59808     }
59809     ts.updatePostfix = updatePostfix;
59810     function createBinary(left, operator, right) {
59811         var node = createSynthesizedNode(209);
59812         var operatorToken = asToken(operator);
59813         var operatorKind = operatorToken.kind;
59814         node.left = ts.parenthesizeBinaryOperand(operatorKind, left, true, undefined);
59815         node.operatorToken = operatorToken;
59816         node.right = ts.parenthesizeBinaryOperand(operatorKind, right, false, node.left);
59817         return node;
59818     }
59819     ts.createBinary = createBinary;
59820     function updateBinary(node, left, right, operator) {
59821         return node.left !== left
59822             || node.right !== right
59823             ? updateNode(createBinary(left, operator || node.operatorToken, right), node)
59824             : node;
59825     }
59826     ts.updateBinary = updateBinary;
59827     function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) {
59828         var node = createSynthesizedNode(210);
59829         node.condition = ts.parenthesizeForConditionalHead(condition);
59830         node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(57);
59831         node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue);
59832         node.colonToken = whenFalse ? colonToken : createToken(58);
59833         node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse);
59834         return node;
59835     }
59836     ts.createConditional = createConditional;
59837     function updateConditional(node, condition, questionToken, whenTrue, colonToken, whenFalse) {
59838         return node.condition !== condition
59839             || node.questionToken !== questionToken
59840             || node.whenTrue !== whenTrue
59841             || node.colonToken !== colonToken
59842             || node.whenFalse !== whenFalse
59843             ? updateNode(createConditional(condition, questionToken, whenTrue, colonToken, whenFalse), node)
59844             : node;
59845     }
59846     ts.updateConditional = updateConditional;
59847     function createTemplateExpression(head, templateSpans) {
59848         var node = createSynthesizedNode(211);
59849         node.head = head;
59850         node.templateSpans = createNodeArray(templateSpans);
59851         return node;
59852     }
59853     ts.createTemplateExpression = createTemplateExpression;
59854     function updateTemplateExpression(node, head, templateSpans) {
59855         return node.head !== head
59856             || node.templateSpans !== templateSpans
59857             ? updateNode(createTemplateExpression(head, templateSpans), node)
59858             : node;
59859     }
59860     ts.updateTemplateExpression = updateTemplateExpression;
59861     var rawTextScanner;
59862     var invalidValueSentinel = {};
59863     function getCookedText(kind, rawText) {
59864         if (!rawTextScanner) {
59865             rawTextScanner = ts.createScanner(99, false, 0);
59866         }
59867         switch (kind) {
59868             case 14:
59869                 rawTextScanner.setText("`" + rawText + "`");
59870                 break;
59871             case 15:
59872                 rawTextScanner.setText("`" + rawText + "${");
59873                 break;
59874             case 16:
59875                 rawTextScanner.setText("}" + rawText + "${");
59876                 break;
59877             case 17:
59878                 rawTextScanner.setText("}" + rawText + "`");
59879                 break;
59880         }
59881         var token = rawTextScanner.scan();
59882         if (token === 23) {
59883             token = rawTextScanner.reScanTemplateToken(false);
59884         }
59885         if (rawTextScanner.isUnterminated()) {
59886             rawTextScanner.setText(undefined);
59887             return invalidValueSentinel;
59888         }
59889         var tokenValue;
59890         switch (token) {
59891             case 14:
59892             case 15:
59893             case 16:
59894             case 17:
59895                 tokenValue = rawTextScanner.getTokenValue();
59896                 break;
59897         }
59898         if (rawTextScanner.scan() !== 1) {
59899             rawTextScanner.setText(undefined);
59900             return invalidValueSentinel;
59901         }
59902         rawTextScanner.setText(undefined);
59903         return tokenValue;
59904     }
59905     function createTemplateLiteralLikeNode(kind, text, rawText) {
59906         var node = createSynthesizedNode(kind);
59907         node.text = text;
59908         if (rawText === undefined || text === rawText) {
59909             node.rawText = rawText;
59910         }
59911         else {
59912             var cooked = getCookedText(kind, rawText);
59913             if (typeof cooked === "object") {
59914                 return ts.Debug.fail("Invalid raw text");
59915             }
59916             ts.Debug.assert(text === cooked, "Expected argument 'text' to be the normalized (i.e. 'cooked') version of argument 'rawText'.");
59917             node.rawText = rawText;
59918         }
59919         return node;
59920     }
59921     function createTemplateHead(text, rawText) {
59922         var node = createTemplateLiteralLikeNode(15, text, rawText);
59923         node.text = text;
59924         return node;
59925     }
59926     ts.createTemplateHead = createTemplateHead;
59927     function createTemplateMiddle(text, rawText) {
59928         var node = createTemplateLiteralLikeNode(16, text, rawText);
59929         node.text = text;
59930         return node;
59931     }
59932     ts.createTemplateMiddle = createTemplateMiddle;
59933     function createTemplateTail(text, rawText) {
59934         var node = createTemplateLiteralLikeNode(17, text, rawText);
59935         node.text = text;
59936         return node;
59937     }
59938     ts.createTemplateTail = createTemplateTail;
59939     function createNoSubstitutionTemplateLiteral(text, rawText) {
59940         var node = createTemplateLiteralLikeNode(14, text, rawText);
59941         return node;
59942     }
59943     ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral;
59944     function createYield(asteriskTokenOrExpression, expression) {
59945         var asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 41 ? asteriskTokenOrExpression : undefined;
59946         expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 41 ? asteriskTokenOrExpression : expression;
59947         var node = createSynthesizedNode(212);
59948         node.asteriskToken = asteriskToken;
59949         node.expression = expression && ts.parenthesizeExpressionForList(expression);
59950         return node;
59951     }
59952     ts.createYield = createYield;
59953     function updateYield(node, asteriskToken, expression) {
59954         return node.expression !== expression
59955             || node.asteriskToken !== asteriskToken
59956             ? updateNode(createYield(asteriskToken, expression), node)
59957             : node;
59958     }
59959     ts.updateYield = updateYield;
59960     function createSpread(expression) {
59961         var node = createSynthesizedNode(213);
59962         node.expression = ts.parenthesizeExpressionForList(expression);
59963         return node;
59964     }
59965     ts.createSpread = createSpread;
59966     function updateSpread(node, expression) {
59967         return node.expression !== expression
59968             ? updateNode(createSpread(expression), node)
59969             : node;
59970     }
59971     ts.updateSpread = updateSpread;
59972     function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) {
59973         var node = createSynthesizedNode(214);
59974         node.decorators = undefined;
59975         node.modifiers = asNodeArray(modifiers);
59976         node.name = asName(name);
59977         node.typeParameters = asNodeArray(typeParameters);
59978         node.heritageClauses = asNodeArray(heritageClauses);
59979         node.members = createNodeArray(members);
59980         return node;
59981     }
59982     ts.createClassExpression = createClassExpression;
59983     function updateClassExpression(node, modifiers, name, typeParameters, heritageClauses, members) {
59984         return node.modifiers !== modifiers
59985             || node.name !== name
59986             || node.typeParameters !== typeParameters
59987             || node.heritageClauses !== heritageClauses
59988             || node.members !== members
59989             ? updateNode(createClassExpression(modifiers, name, typeParameters, heritageClauses, members), node)
59990             : node;
59991     }
59992     ts.updateClassExpression = updateClassExpression;
59993     function createOmittedExpression() {
59994         return createSynthesizedNode(215);
59995     }
59996     ts.createOmittedExpression = createOmittedExpression;
59997     function createExpressionWithTypeArguments(typeArguments, expression) {
59998         var node = createSynthesizedNode(216);
59999         node.expression = ts.parenthesizeForAccess(expression);
60000         node.typeArguments = asNodeArray(typeArguments);
60001         return node;
60002     }
60003     ts.createExpressionWithTypeArguments = createExpressionWithTypeArguments;
60004     function updateExpressionWithTypeArguments(node, typeArguments, expression) {
60005         return node.typeArguments !== typeArguments
60006             || node.expression !== expression
60007             ? updateNode(createExpressionWithTypeArguments(typeArguments, expression), node)
60008             : node;
60009     }
60010     ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments;
60011     function createAsExpression(expression, type) {
60012         var node = createSynthesizedNode(217);
60013         node.expression = expression;
60014         node.type = type;
60015         return node;
60016     }
60017     ts.createAsExpression = createAsExpression;
60018     function updateAsExpression(node, expression, type) {
60019         return node.expression !== expression
60020             || node.type !== type
60021             ? updateNode(createAsExpression(expression, type), node)
60022             : node;
60023     }
60024     ts.updateAsExpression = updateAsExpression;
60025     function createNonNullExpression(expression) {
60026         var node = createSynthesizedNode(218);
60027         node.expression = ts.parenthesizeForAccess(expression);
60028         return node;
60029     }
60030     ts.createNonNullExpression = createNonNullExpression;
60031     function updateNonNullExpression(node, expression) {
60032         if (ts.isNonNullChain(node)) {
60033             return updateNonNullChain(node, expression);
60034         }
60035         return node.expression !== expression
60036             ? updateNode(createNonNullExpression(expression), node)
60037             : node;
60038     }
60039     ts.updateNonNullExpression = updateNonNullExpression;
60040     function createNonNullChain(expression) {
60041         var node = createSynthesizedNode(218);
60042         node.flags |= 32;
60043         node.expression = ts.parenthesizeForAccess(expression);
60044         return node;
60045     }
60046     ts.createNonNullChain = createNonNullChain;
60047     function updateNonNullChain(node, expression) {
60048         ts.Debug.assert(!!(node.flags & 32), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead.");
60049         return node.expression !== expression
60050             ? updateNode(createNonNullChain(expression), node)
60051             : node;
60052     }
60053     ts.updateNonNullChain = updateNonNullChain;
60054     function createMetaProperty(keywordToken, name) {
60055         var node = createSynthesizedNode(219);
60056         node.keywordToken = keywordToken;
60057         node.name = name;
60058         return node;
60059     }
60060     ts.createMetaProperty = createMetaProperty;
60061     function updateMetaProperty(node, name) {
60062         return node.name !== name
60063             ? updateNode(createMetaProperty(node.keywordToken, name), node)
60064             : node;
60065     }
60066     ts.updateMetaProperty = updateMetaProperty;
60067     function createTemplateSpan(expression, literal) {
60068         var node = createSynthesizedNode(221);
60069         node.expression = expression;
60070         node.literal = literal;
60071         return node;
60072     }
60073     ts.createTemplateSpan = createTemplateSpan;
60074     function updateTemplateSpan(node, expression, literal) {
60075         return node.expression !== expression
60076             || node.literal !== literal
60077             ? updateNode(createTemplateSpan(expression, literal), node)
60078             : node;
60079     }
60080     ts.updateTemplateSpan = updateTemplateSpan;
60081     function createSemicolonClassElement() {
60082         return createSynthesizedNode(222);
60083     }
60084     ts.createSemicolonClassElement = createSemicolonClassElement;
60085     function createBlock(statements, multiLine) {
60086         var block = createSynthesizedNode(223);
60087         block.statements = createNodeArray(statements);
60088         if (multiLine)
60089             block.multiLine = multiLine;
60090         return block;
60091     }
60092     ts.createBlock = createBlock;
60093     function updateBlock(node, statements) {
60094         return node.statements !== statements
60095             ? updateNode(createBlock(statements, node.multiLine), node)
60096             : node;
60097     }
60098     ts.updateBlock = updateBlock;
60099     function createVariableStatement(modifiers, declarationList) {
60100         var node = createSynthesizedNode(225);
60101         node.decorators = undefined;
60102         node.modifiers = asNodeArray(modifiers);
60103         node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList;
60104         return node;
60105     }
60106     ts.createVariableStatement = createVariableStatement;
60107     function updateVariableStatement(node, modifiers, declarationList) {
60108         return node.modifiers !== modifiers
60109             || node.declarationList !== declarationList
60110             ? updateNode(createVariableStatement(modifiers, declarationList), node)
60111             : node;
60112     }
60113     ts.updateVariableStatement = updateVariableStatement;
60114     function createEmptyStatement() {
60115         return createSynthesizedNode(224);
60116     }
60117     ts.createEmptyStatement = createEmptyStatement;
60118     function createExpressionStatement(expression) {
60119         var node = createSynthesizedNode(226);
60120         node.expression = ts.parenthesizeExpressionForExpressionStatement(expression);
60121         return node;
60122     }
60123     ts.createExpressionStatement = createExpressionStatement;
60124     function updateExpressionStatement(node, expression) {
60125         return node.expression !== expression
60126             ? updateNode(createExpressionStatement(expression), node)
60127             : node;
60128     }
60129     ts.updateExpressionStatement = updateExpressionStatement;
60130     ts.createStatement = createExpressionStatement;
60131     ts.updateStatement = updateExpressionStatement;
60132     function createIf(expression, thenStatement, elseStatement) {
60133         var node = createSynthesizedNode(227);
60134         node.expression = expression;
60135         node.thenStatement = asEmbeddedStatement(thenStatement);
60136         node.elseStatement = asEmbeddedStatement(elseStatement);
60137         return node;
60138     }
60139     ts.createIf = createIf;
60140     function updateIf(node, expression, thenStatement, elseStatement) {
60141         return node.expression !== expression
60142             || node.thenStatement !== thenStatement
60143             || node.elseStatement !== elseStatement
60144             ? updateNode(createIf(expression, thenStatement, elseStatement), node)
60145             : node;
60146     }
60147     ts.updateIf = updateIf;
60148     function createDo(statement, expression) {
60149         var node = createSynthesizedNode(228);
60150         node.statement = asEmbeddedStatement(statement);
60151         node.expression = expression;
60152         return node;
60153     }
60154     ts.createDo = createDo;
60155     function updateDo(node, statement, expression) {
60156         return node.statement !== statement
60157             || node.expression !== expression
60158             ? updateNode(createDo(statement, expression), node)
60159             : node;
60160     }
60161     ts.updateDo = updateDo;
60162     function createWhile(expression, statement) {
60163         var node = createSynthesizedNode(229);
60164         node.expression = expression;
60165         node.statement = asEmbeddedStatement(statement);
60166         return node;
60167     }
60168     ts.createWhile = createWhile;
60169     function updateWhile(node, expression, statement) {
60170         return node.expression !== expression
60171             || node.statement !== statement
60172             ? updateNode(createWhile(expression, statement), node)
60173             : node;
60174     }
60175     ts.updateWhile = updateWhile;
60176     function createFor(initializer, condition, incrementor, statement) {
60177         var node = createSynthesizedNode(230);
60178         node.initializer = initializer;
60179         node.condition = condition;
60180         node.incrementor = incrementor;
60181         node.statement = asEmbeddedStatement(statement);
60182         return node;
60183     }
60184     ts.createFor = createFor;
60185     function updateFor(node, initializer, condition, incrementor, statement) {
60186         return node.initializer !== initializer
60187             || node.condition !== condition
60188             || node.incrementor !== incrementor
60189             || node.statement !== statement
60190             ? updateNode(createFor(initializer, condition, incrementor, statement), node)
60191             : node;
60192     }
60193     ts.updateFor = updateFor;
60194     function createForIn(initializer, expression, statement) {
60195         var node = createSynthesizedNode(231);
60196         node.initializer = initializer;
60197         node.expression = expression;
60198         node.statement = asEmbeddedStatement(statement);
60199         return node;
60200     }
60201     ts.createForIn = createForIn;
60202     function updateForIn(node, initializer, expression, statement) {
60203         return node.initializer !== initializer
60204             || node.expression !== expression
60205             || node.statement !== statement
60206             ? updateNode(createForIn(initializer, expression, statement), node)
60207             : node;
60208     }
60209     ts.updateForIn = updateForIn;
60210     function createForOf(awaitModifier, initializer, expression, statement) {
60211         var node = createSynthesizedNode(232);
60212         node.awaitModifier = awaitModifier;
60213         node.initializer = initializer;
60214         node.expression = ts.isCommaSequence(expression) ? createParen(expression) : expression;
60215         node.statement = asEmbeddedStatement(statement);
60216         return node;
60217     }
60218     ts.createForOf = createForOf;
60219     function updateForOf(node, awaitModifier, initializer, expression, statement) {
60220         return node.awaitModifier !== awaitModifier
60221             || node.initializer !== initializer
60222             || node.expression !== expression
60223             || node.statement !== statement
60224             ? updateNode(createForOf(awaitModifier, initializer, expression, statement), node)
60225             : node;
60226     }
60227     ts.updateForOf = updateForOf;
60228     function createContinue(label) {
60229         var node = createSynthesizedNode(233);
60230         node.label = asName(label);
60231         return node;
60232     }
60233     ts.createContinue = createContinue;
60234     function updateContinue(node, label) {
60235         return node.label !== label
60236             ? updateNode(createContinue(label), node)
60237             : node;
60238     }
60239     ts.updateContinue = updateContinue;
60240     function createBreak(label) {
60241         var node = createSynthesizedNode(234);
60242         node.label = asName(label);
60243         return node;
60244     }
60245     ts.createBreak = createBreak;
60246     function updateBreak(node, label) {
60247         return node.label !== label
60248             ? updateNode(createBreak(label), node)
60249             : node;
60250     }
60251     ts.updateBreak = updateBreak;
60252     function createReturn(expression) {
60253         var node = createSynthesizedNode(235);
60254         node.expression = expression;
60255         return node;
60256     }
60257     ts.createReturn = createReturn;
60258     function updateReturn(node, expression) {
60259         return node.expression !== expression
60260             ? updateNode(createReturn(expression), node)
60261             : node;
60262     }
60263     ts.updateReturn = updateReturn;
60264     function createWith(expression, statement) {
60265         var node = createSynthesizedNode(236);
60266         node.expression = expression;
60267         node.statement = asEmbeddedStatement(statement);
60268         return node;
60269     }
60270     ts.createWith = createWith;
60271     function updateWith(node, expression, statement) {
60272         return node.expression !== expression
60273             || node.statement !== statement
60274             ? updateNode(createWith(expression, statement), node)
60275             : node;
60276     }
60277     ts.updateWith = updateWith;
60278     function createSwitch(expression, caseBlock) {
60279         var node = createSynthesizedNode(237);
60280         node.expression = ts.parenthesizeExpressionForList(expression);
60281         node.caseBlock = caseBlock;
60282         return node;
60283     }
60284     ts.createSwitch = createSwitch;
60285     function updateSwitch(node, expression, caseBlock) {
60286         return node.expression !== expression
60287             || node.caseBlock !== caseBlock
60288             ? updateNode(createSwitch(expression, caseBlock), node)
60289             : node;
60290     }
60291     ts.updateSwitch = updateSwitch;
60292     function createLabel(label, statement) {
60293         var node = createSynthesizedNode(238);
60294         node.label = asName(label);
60295         node.statement = asEmbeddedStatement(statement);
60296         return node;
60297     }
60298     ts.createLabel = createLabel;
60299     function updateLabel(node, label, statement) {
60300         return node.label !== label
60301             || node.statement !== statement
60302             ? updateNode(createLabel(label, statement), node)
60303             : node;
60304     }
60305     ts.updateLabel = updateLabel;
60306     function createThrow(expression) {
60307         var node = createSynthesizedNode(239);
60308         node.expression = expression;
60309         return node;
60310     }
60311     ts.createThrow = createThrow;
60312     function updateThrow(node, expression) {
60313         return node.expression !== expression
60314             ? updateNode(createThrow(expression), node)
60315             : node;
60316     }
60317     ts.updateThrow = updateThrow;
60318     function createTry(tryBlock, catchClause, finallyBlock) {
60319         var node = createSynthesizedNode(240);
60320         node.tryBlock = tryBlock;
60321         node.catchClause = catchClause;
60322         node.finallyBlock = finallyBlock;
60323         return node;
60324     }
60325     ts.createTry = createTry;
60326     function updateTry(node, tryBlock, catchClause, finallyBlock) {
60327         return node.tryBlock !== tryBlock
60328             || node.catchClause !== catchClause
60329             || node.finallyBlock !== finallyBlock
60330             ? updateNode(createTry(tryBlock, catchClause, finallyBlock), node)
60331             : node;
60332     }
60333     ts.updateTry = updateTry;
60334     function createDebuggerStatement() {
60335         return createSynthesizedNode(241);
60336     }
60337     ts.createDebuggerStatement = createDebuggerStatement;
60338     function createVariableDeclaration(name, type, initializer) {
60339         var node = createSynthesizedNode(242);
60340         node.name = asName(name);
60341         node.type = type;
60342         node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined;
60343         return node;
60344     }
60345     ts.createVariableDeclaration = createVariableDeclaration;
60346     function updateVariableDeclaration(node, name, type, initializer) {
60347         return node.name !== name
60348             || node.type !== type
60349             || node.initializer !== initializer
60350             ? updateNode(createVariableDeclaration(name, type, initializer), node)
60351             : node;
60352     }
60353     ts.updateVariableDeclaration = updateVariableDeclaration;
60354     function createTypeScriptVariableDeclaration(name, exclaimationToken, type, initializer) {
60355         var node = createSynthesizedNode(242);
60356         node.name = asName(name);
60357         node.type = type;
60358         node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined;
60359         node.exclamationToken = exclaimationToken;
60360         return node;
60361     }
60362     ts.createTypeScriptVariableDeclaration = createTypeScriptVariableDeclaration;
60363     function updateTypeScriptVariableDeclaration(node, name, exclaimationToken, type, initializer) {
60364         return node.name !== name
60365             || node.type !== type
60366             || node.initializer !== initializer
60367             || node.exclamationToken !== exclaimationToken
60368             ? updateNode(createTypeScriptVariableDeclaration(name, exclaimationToken, type, initializer), node)
60369             : node;
60370     }
60371     ts.updateTypeScriptVariableDeclaration = updateTypeScriptVariableDeclaration;
60372     function createVariableDeclarationList(declarations, flags) {
60373         if (flags === void 0) { flags = 0; }
60374         var node = createSynthesizedNode(243);
60375         node.flags |= flags & 3;
60376         node.declarations = createNodeArray(declarations);
60377         return node;
60378     }
60379     ts.createVariableDeclarationList = createVariableDeclarationList;
60380     function updateVariableDeclarationList(node, declarations) {
60381         return node.declarations !== declarations
60382             ? updateNode(createVariableDeclarationList(declarations, node.flags), node)
60383             : node;
60384     }
60385     ts.updateVariableDeclarationList = updateVariableDeclarationList;
60386     function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
60387         var node = createSynthesizedNode(244);
60388         node.decorators = asNodeArray(decorators);
60389         node.modifiers = asNodeArray(modifiers);
60390         node.asteriskToken = asteriskToken;
60391         node.name = asName(name);
60392         node.typeParameters = asNodeArray(typeParameters);
60393         node.parameters = createNodeArray(parameters);
60394         node.type = type;
60395         node.body = body;
60396         return node;
60397     }
60398     ts.createFunctionDeclaration = createFunctionDeclaration;
60399     function updateFunctionDeclaration(node, decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
60400         return node.decorators !== decorators
60401             || node.modifiers !== modifiers
60402             || node.asteriskToken !== asteriskToken
60403             || node.name !== name
60404             || node.typeParameters !== typeParameters
60405             || node.parameters !== parameters
60406             || node.type !== type
60407             || node.body !== body
60408             ? updateNode(createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body), node)
60409             : node;
60410     }
60411     ts.updateFunctionDeclaration = updateFunctionDeclaration;
60412     function updateFunctionLikeBody(declaration, body) {
60413         switch (declaration.kind) {
60414             case 244:
60415                 return createFunctionDeclaration(declaration.decorators, declaration.modifiers, declaration.asteriskToken, declaration.name, declaration.typeParameters, declaration.parameters, declaration.type, body);
60416             case 161:
60417                 return createMethod(declaration.decorators, declaration.modifiers, declaration.asteriskToken, declaration.name, declaration.questionToken, declaration.typeParameters, declaration.parameters, declaration.type, body);
60418             case 163:
60419                 return createGetAccessor(declaration.decorators, declaration.modifiers, declaration.name, declaration.parameters, declaration.type, body);
60420             case 164:
60421                 return createSetAccessor(declaration.decorators, declaration.modifiers, declaration.name, declaration.parameters, body);
60422             case 162:
60423                 return createConstructor(declaration.decorators, declaration.modifiers, declaration.parameters, body);
60424             case 201:
60425                 return createFunctionExpression(declaration.modifiers, declaration.asteriskToken, declaration.name, declaration.typeParameters, declaration.parameters, declaration.type, body);
60426             case 202:
60427                 return createArrowFunction(declaration.modifiers, declaration.typeParameters, declaration.parameters, declaration.type, declaration.equalsGreaterThanToken, body);
60428         }
60429     }
60430     ts.updateFunctionLikeBody = updateFunctionLikeBody;
60431     function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) {
60432         var node = createSynthesizedNode(245);
60433         node.decorators = asNodeArray(decorators);
60434         node.modifiers = asNodeArray(modifiers);
60435         node.name = asName(name);
60436         node.typeParameters = asNodeArray(typeParameters);
60437         node.heritageClauses = asNodeArray(heritageClauses);
60438         node.members = createNodeArray(members);
60439         return node;
60440     }
60441     ts.createClassDeclaration = createClassDeclaration;
60442     function updateClassDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) {
60443         return node.decorators !== decorators
60444             || node.modifiers !== modifiers
60445             || node.name !== name
60446             || node.typeParameters !== typeParameters
60447             || node.heritageClauses !== heritageClauses
60448             || node.members !== members
60449             ? updateNode(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node)
60450             : node;
60451     }
60452     ts.updateClassDeclaration = updateClassDeclaration;
60453     function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) {
60454         var node = createSynthesizedNode(246);
60455         node.decorators = asNodeArray(decorators);
60456         node.modifiers = asNodeArray(modifiers);
60457         node.name = asName(name);
60458         node.typeParameters = asNodeArray(typeParameters);
60459         node.heritageClauses = asNodeArray(heritageClauses);
60460         node.members = createNodeArray(members);
60461         return node;
60462     }
60463     ts.createInterfaceDeclaration = createInterfaceDeclaration;
60464     function updateInterfaceDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) {
60465         return node.decorators !== decorators
60466             || node.modifiers !== modifiers
60467             || node.name !== name
60468             || node.typeParameters !== typeParameters
60469             || node.heritageClauses !== heritageClauses
60470             || node.members !== members
60471             ? updateNode(createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node)
60472             : node;
60473     }
60474     ts.updateInterfaceDeclaration = updateInterfaceDeclaration;
60475     function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) {
60476         var node = createSynthesizedNode(247);
60477         node.decorators = asNodeArray(decorators);
60478         node.modifiers = asNodeArray(modifiers);
60479         node.name = asName(name);
60480         node.typeParameters = asNodeArray(typeParameters);
60481         node.type = type;
60482         return node;
60483     }
60484     ts.createTypeAliasDeclaration = createTypeAliasDeclaration;
60485     function updateTypeAliasDeclaration(node, decorators, modifiers, name, typeParameters, type) {
60486         return node.decorators !== decorators
60487             || node.modifiers !== modifiers
60488             || node.name !== name
60489             || node.typeParameters !== typeParameters
60490             || node.type !== type
60491             ? updateNode(createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type), node)
60492             : node;
60493     }
60494     ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration;
60495     function createEnumDeclaration(decorators, modifiers, name, members) {
60496         var node = createSynthesizedNode(248);
60497         node.decorators = asNodeArray(decorators);
60498         node.modifiers = asNodeArray(modifiers);
60499         node.name = asName(name);
60500         node.members = createNodeArray(members);
60501         return node;
60502     }
60503     ts.createEnumDeclaration = createEnumDeclaration;
60504     function updateEnumDeclaration(node, decorators, modifiers, name, members) {
60505         return node.decorators !== decorators
60506             || node.modifiers !== modifiers
60507             || node.name !== name
60508             || node.members !== members
60509             ? updateNode(createEnumDeclaration(decorators, modifiers, name, members), node)
60510             : node;
60511     }
60512     ts.updateEnumDeclaration = updateEnumDeclaration;
60513     function createModuleDeclaration(decorators, modifiers, name, body, flags) {
60514         if (flags === void 0) { flags = 0; }
60515         var node = createSynthesizedNode(249);
60516         node.flags |= flags & (16 | 4 | 1024);
60517         node.decorators = asNodeArray(decorators);
60518         node.modifiers = asNodeArray(modifiers);
60519         node.name = name;
60520         node.body = body;
60521         return node;
60522     }
60523     ts.createModuleDeclaration = createModuleDeclaration;
60524     function updateModuleDeclaration(node, decorators, modifiers, name, body) {
60525         return node.decorators !== decorators
60526             || node.modifiers !== modifiers
60527             || node.name !== name
60528             || node.body !== body
60529             ? updateNode(createModuleDeclaration(decorators, modifiers, name, body, node.flags), node)
60530             : node;
60531     }
60532     ts.updateModuleDeclaration = updateModuleDeclaration;
60533     function createModuleBlock(statements) {
60534         var node = createSynthesizedNode(250);
60535         node.statements = createNodeArray(statements);
60536         return node;
60537     }
60538     ts.createModuleBlock = createModuleBlock;
60539     function updateModuleBlock(node, statements) {
60540         return node.statements !== statements
60541             ? updateNode(createModuleBlock(statements), node)
60542             : node;
60543     }
60544     ts.updateModuleBlock = updateModuleBlock;
60545     function createCaseBlock(clauses) {
60546         var node = createSynthesizedNode(251);
60547         node.clauses = createNodeArray(clauses);
60548         return node;
60549     }
60550     ts.createCaseBlock = createCaseBlock;
60551     function updateCaseBlock(node, clauses) {
60552         return node.clauses !== clauses
60553             ? updateNode(createCaseBlock(clauses), node)
60554             : node;
60555     }
60556     ts.updateCaseBlock = updateCaseBlock;
60557     function createNamespaceExportDeclaration(name) {
60558         var node = createSynthesizedNode(252);
60559         node.name = asName(name);
60560         return node;
60561     }
60562     ts.createNamespaceExportDeclaration = createNamespaceExportDeclaration;
60563     function updateNamespaceExportDeclaration(node, name) {
60564         return node.name !== name
60565             ? updateNode(createNamespaceExportDeclaration(name), node)
60566             : node;
60567     }
60568     ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration;
60569     function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) {
60570         var node = createSynthesizedNode(253);
60571         node.decorators = asNodeArray(decorators);
60572         node.modifiers = asNodeArray(modifiers);
60573         node.name = asName(name);
60574         node.moduleReference = moduleReference;
60575         return node;
60576     }
60577     ts.createImportEqualsDeclaration = createImportEqualsDeclaration;
60578     function updateImportEqualsDeclaration(node, decorators, modifiers, name, moduleReference) {
60579         return node.decorators !== decorators
60580             || node.modifiers !== modifiers
60581             || node.name !== name
60582             || node.moduleReference !== moduleReference
60583             ? updateNode(createImportEqualsDeclaration(decorators, modifiers, name, moduleReference), node)
60584             : node;
60585     }
60586     ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration;
60587     function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) {
60588         var node = createSynthesizedNode(254);
60589         node.decorators = asNodeArray(decorators);
60590         node.modifiers = asNodeArray(modifiers);
60591         node.importClause = importClause;
60592         node.moduleSpecifier = moduleSpecifier;
60593         return node;
60594     }
60595     ts.createImportDeclaration = createImportDeclaration;
60596     function updateImportDeclaration(node, decorators, modifiers, importClause, moduleSpecifier) {
60597         return node.decorators !== decorators
60598             || node.modifiers !== modifiers
60599             || node.importClause !== importClause
60600             || node.moduleSpecifier !== moduleSpecifier
60601             ? updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier), node)
60602             : node;
60603     }
60604     ts.updateImportDeclaration = updateImportDeclaration;
60605     function createImportClause(name, namedBindings, isTypeOnly) {
60606         if (isTypeOnly === void 0) { isTypeOnly = false; }
60607         var node = createSynthesizedNode(255);
60608         node.name = name;
60609         node.namedBindings = namedBindings;
60610         node.isTypeOnly = isTypeOnly;
60611         return node;
60612     }
60613     ts.createImportClause = createImportClause;
60614     function updateImportClause(node, name, namedBindings, isTypeOnly) {
60615         return node.name !== name
60616             || node.namedBindings !== namedBindings
60617             || node.isTypeOnly !== isTypeOnly
60618             ? updateNode(createImportClause(name, namedBindings, isTypeOnly), node)
60619             : node;
60620     }
60621     ts.updateImportClause = updateImportClause;
60622     function createNamespaceImport(name) {
60623         var node = createSynthesizedNode(256);
60624         node.name = name;
60625         return node;
60626     }
60627     ts.createNamespaceImport = createNamespaceImport;
60628     function createNamespaceExport(name) {
60629         var node = createSynthesizedNode(262);
60630         node.name = name;
60631         return node;
60632     }
60633     ts.createNamespaceExport = createNamespaceExport;
60634     function updateNamespaceImport(node, name) {
60635         return node.name !== name
60636             ? updateNode(createNamespaceImport(name), node)
60637             : node;
60638     }
60639     ts.updateNamespaceImport = updateNamespaceImport;
60640     function updateNamespaceExport(node, name) {
60641         return node.name !== name
60642             ? updateNode(createNamespaceExport(name), node)
60643             : node;
60644     }
60645     ts.updateNamespaceExport = updateNamespaceExport;
60646     function createNamedImports(elements) {
60647         var node = createSynthesizedNode(257);
60648         node.elements = createNodeArray(elements);
60649         return node;
60650     }
60651     ts.createNamedImports = createNamedImports;
60652     function updateNamedImports(node, elements) {
60653         return node.elements !== elements
60654             ? updateNode(createNamedImports(elements), node)
60655             : node;
60656     }
60657     ts.updateNamedImports = updateNamedImports;
60658     function createImportSpecifier(propertyName, name) {
60659         var node = createSynthesizedNode(258);
60660         node.propertyName = propertyName;
60661         node.name = name;
60662         return node;
60663     }
60664     ts.createImportSpecifier = createImportSpecifier;
60665     function updateImportSpecifier(node, propertyName, name) {
60666         return node.propertyName !== propertyName
60667             || node.name !== name
60668             ? updateNode(createImportSpecifier(propertyName, name), node)
60669             : node;
60670     }
60671     ts.updateImportSpecifier = updateImportSpecifier;
60672     function createExportAssignment(decorators, modifiers, isExportEquals, expression) {
60673         var node = createSynthesizedNode(259);
60674         node.decorators = asNodeArray(decorators);
60675         node.modifiers = asNodeArray(modifiers);
60676         node.isExportEquals = isExportEquals;
60677         node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(62, expression, false, undefined) : ts.parenthesizeDefaultExpression(expression);
60678         return node;
60679     }
60680     ts.createExportAssignment = createExportAssignment;
60681     function updateExportAssignment(node, decorators, modifiers, expression) {
60682         return node.decorators !== decorators
60683             || node.modifiers !== modifiers
60684             || node.expression !== expression
60685             ? updateNode(createExportAssignment(decorators, modifiers, node.isExportEquals, expression), node)
60686             : node;
60687     }
60688     ts.updateExportAssignment = updateExportAssignment;
60689     function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, isTypeOnly) {
60690         if (isTypeOnly === void 0) { isTypeOnly = false; }
60691         var node = createSynthesizedNode(260);
60692         node.decorators = asNodeArray(decorators);
60693         node.modifiers = asNodeArray(modifiers);
60694         node.isTypeOnly = isTypeOnly;
60695         node.exportClause = exportClause;
60696         node.moduleSpecifier = moduleSpecifier;
60697         return node;
60698     }
60699     ts.createExportDeclaration = createExportDeclaration;
60700     function updateExportDeclaration(node, decorators, modifiers, exportClause, moduleSpecifier, isTypeOnly) {
60701         return node.decorators !== decorators
60702             || node.modifiers !== modifiers
60703             || node.isTypeOnly !== isTypeOnly
60704             || node.exportClause !== exportClause
60705             || node.moduleSpecifier !== moduleSpecifier
60706             ? updateNode(createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, isTypeOnly), node)
60707             : node;
60708     }
60709     ts.updateExportDeclaration = updateExportDeclaration;
60710     function createEmptyExports() {
60711         return createExportDeclaration(undefined, undefined, createNamedExports([]), undefined);
60712     }
60713     ts.createEmptyExports = createEmptyExports;
60714     function createNamedExports(elements) {
60715         var node = createSynthesizedNode(261);
60716         node.elements = createNodeArray(elements);
60717         return node;
60718     }
60719     ts.createNamedExports = createNamedExports;
60720     function updateNamedExports(node, elements) {
60721         return node.elements !== elements
60722             ? updateNode(createNamedExports(elements), node)
60723             : node;
60724     }
60725     ts.updateNamedExports = updateNamedExports;
60726     function createExportSpecifier(propertyName, name) {
60727         var node = createSynthesizedNode(263);
60728         node.propertyName = asName(propertyName);
60729         node.name = asName(name);
60730         return node;
60731     }
60732     ts.createExportSpecifier = createExportSpecifier;
60733     function updateExportSpecifier(node, propertyName, name) {
60734         return node.propertyName !== propertyName
60735             || node.name !== name
60736             ? updateNode(createExportSpecifier(propertyName, name), node)
60737             : node;
60738     }
60739     ts.updateExportSpecifier = updateExportSpecifier;
60740     function createExternalModuleReference(expression) {
60741         var node = createSynthesizedNode(265);
60742         node.expression = expression;
60743         return node;
60744     }
60745     ts.createExternalModuleReference = createExternalModuleReference;
60746     function updateExternalModuleReference(node, expression) {
60747         return node.expression !== expression
60748             ? updateNode(createExternalModuleReference(expression), node)
60749             : node;
60750     }
60751     ts.updateExternalModuleReference = updateExternalModuleReference;
60752     function createJSDocTypeExpression(type) {
60753         var node = createSynthesizedNode(294);
60754         node.type = type;
60755         return node;
60756     }
60757     ts.createJSDocTypeExpression = createJSDocTypeExpression;
60758     function createJSDocTypeTag(typeExpression, comment) {
60759         var tag = createJSDocTag(320, "type");
60760         tag.typeExpression = typeExpression;
60761         tag.comment = comment;
60762         return tag;
60763     }
60764     ts.createJSDocTypeTag = createJSDocTypeTag;
60765     function createJSDocReturnTag(typeExpression, comment) {
60766         var tag = createJSDocTag(318, "returns");
60767         tag.typeExpression = typeExpression;
60768         tag.comment = comment;
60769         return tag;
60770     }
60771     ts.createJSDocReturnTag = createJSDocReturnTag;
60772     function createJSDocThisTag(typeExpression) {
60773         var tag = createJSDocTag(319, "this");
60774         tag.typeExpression = typeExpression;
60775         return tag;
60776     }
60777     ts.createJSDocThisTag = createJSDocThisTag;
60778     function createJSDocParamTag(name, isBracketed, typeExpression, comment) {
60779         var tag = createJSDocTag(317, "param");
60780         tag.typeExpression = typeExpression;
60781         tag.name = name;
60782         tag.isBracketed = isBracketed;
60783         tag.comment = comment;
60784         return tag;
60785     }
60786     ts.createJSDocParamTag = createJSDocParamTag;
60787     function createJSDocClassTag() {
60788         return createJSDocTag(310, "class");
60789     }
60790     ts.createJSDocClassTag = createJSDocClassTag;
60791     function createJSDocComment(comment, tags) {
60792         var node = createSynthesizedNode(303);
60793         node.comment = comment;
60794         node.tags = tags;
60795         return node;
60796     }
60797     ts.createJSDocComment = createJSDocComment;
60798     function createJSDocTag(kind, tagName) {
60799         var node = createSynthesizedNode(kind);
60800         node.tagName = createIdentifier(tagName);
60801         return node;
60802     }
60803     function createJsxElement(openingElement, children, closingElement) {
60804         var node = createSynthesizedNode(266);
60805         node.openingElement = openingElement;
60806         node.children = createNodeArray(children);
60807         node.closingElement = closingElement;
60808         return node;
60809     }
60810     ts.createJsxElement = createJsxElement;
60811     function updateJsxElement(node, openingElement, children, closingElement) {
60812         return node.openingElement !== openingElement
60813             || node.children !== children
60814             || node.closingElement !== closingElement
60815             ? updateNode(createJsxElement(openingElement, children, closingElement), node)
60816             : node;
60817     }
60818     ts.updateJsxElement = updateJsxElement;
60819     function createJsxSelfClosingElement(tagName, typeArguments, attributes) {
60820         var node = createSynthesizedNode(267);
60821         node.tagName = tagName;
60822         node.typeArguments = asNodeArray(typeArguments);
60823         node.attributes = attributes;
60824         return node;
60825     }
60826     ts.createJsxSelfClosingElement = createJsxSelfClosingElement;
60827     function updateJsxSelfClosingElement(node, tagName, typeArguments, attributes) {
60828         return node.tagName !== tagName
60829             || node.typeArguments !== typeArguments
60830             || node.attributes !== attributes
60831             ? updateNode(createJsxSelfClosingElement(tagName, typeArguments, attributes), node)
60832             : node;
60833     }
60834     ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement;
60835     function createJsxOpeningElement(tagName, typeArguments, attributes) {
60836         var node = createSynthesizedNode(268);
60837         node.tagName = tagName;
60838         node.typeArguments = asNodeArray(typeArguments);
60839         node.attributes = attributes;
60840         return node;
60841     }
60842     ts.createJsxOpeningElement = createJsxOpeningElement;
60843     function updateJsxOpeningElement(node, tagName, typeArguments, attributes) {
60844         return node.tagName !== tagName
60845             || node.typeArguments !== typeArguments
60846             || node.attributes !== attributes
60847             ? updateNode(createJsxOpeningElement(tagName, typeArguments, attributes), node)
60848             : node;
60849     }
60850     ts.updateJsxOpeningElement = updateJsxOpeningElement;
60851     function createJsxClosingElement(tagName) {
60852         var node = createSynthesizedNode(269);
60853         node.tagName = tagName;
60854         return node;
60855     }
60856     ts.createJsxClosingElement = createJsxClosingElement;
60857     function updateJsxClosingElement(node, tagName) {
60858         return node.tagName !== tagName
60859             ? updateNode(createJsxClosingElement(tagName), node)
60860             : node;
60861     }
60862     ts.updateJsxClosingElement = updateJsxClosingElement;
60863     function createJsxFragment(openingFragment, children, closingFragment) {
60864         var node = createSynthesizedNode(270);
60865         node.openingFragment = openingFragment;
60866         node.children = createNodeArray(children);
60867         node.closingFragment = closingFragment;
60868         return node;
60869     }
60870     ts.createJsxFragment = createJsxFragment;
60871     function createJsxText(text, containsOnlyTriviaWhiteSpaces) {
60872         var node = createSynthesizedNode(11);
60873         node.text = text;
60874         node.containsOnlyTriviaWhiteSpaces = !!containsOnlyTriviaWhiteSpaces;
60875         return node;
60876     }
60877     ts.createJsxText = createJsxText;
60878     function updateJsxText(node, text, containsOnlyTriviaWhiteSpaces) {
60879         return node.text !== text
60880             || node.containsOnlyTriviaWhiteSpaces !== containsOnlyTriviaWhiteSpaces
60881             ? updateNode(createJsxText(text, containsOnlyTriviaWhiteSpaces), node)
60882             : node;
60883     }
60884     ts.updateJsxText = updateJsxText;
60885     function createJsxOpeningFragment() {
60886         return createSynthesizedNode(271);
60887     }
60888     ts.createJsxOpeningFragment = createJsxOpeningFragment;
60889     function createJsxJsxClosingFragment() {
60890         return createSynthesizedNode(272);
60891     }
60892     ts.createJsxJsxClosingFragment = createJsxJsxClosingFragment;
60893     function updateJsxFragment(node, openingFragment, children, closingFragment) {
60894         return node.openingFragment !== openingFragment
60895             || node.children !== children
60896             || node.closingFragment !== closingFragment
60897             ? updateNode(createJsxFragment(openingFragment, children, closingFragment), node)
60898             : node;
60899     }
60900     ts.updateJsxFragment = updateJsxFragment;
60901     function createJsxAttribute(name, initializer) {
60902         var node = createSynthesizedNode(273);
60903         node.name = name;
60904         node.initializer = initializer;
60905         return node;
60906     }
60907     ts.createJsxAttribute = createJsxAttribute;
60908     function updateJsxAttribute(node, name, initializer) {
60909         return node.name !== name
60910             || node.initializer !== initializer
60911             ? updateNode(createJsxAttribute(name, initializer), node)
60912             : node;
60913     }
60914     ts.updateJsxAttribute = updateJsxAttribute;
60915     function createJsxAttributes(properties) {
60916         var node = createSynthesizedNode(274);
60917         node.properties = createNodeArray(properties);
60918         return node;
60919     }
60920     ts.createJsxAttributes = createJsxAttributes;
60921     function updateJsxAttributes(node, properties) {
60922         return node.properties !== properties
60923             ? updateNode(createJsxAttributes(properties), node)
60924             : node;
60925     }
60926     ts.updateJsxAttributes = updateJsxAttributes;
60927     function createJsxSpreadAttribute(expression) {
60928         var node = createSynthesizedNode(275);
60929         node.expression = expression;
60930         return node;
60931     }
60932     ts.createJsxSpreadAttribute = createJsxSpreadAttribute;
60933     function updateJsxSpreadAttribute(node, expression) {
60934         return node.expression !== expression
60935             ? updateNode(createJsxSpreadAttribute(expression), node)
60936             : node;
60937     }
60938     ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute;
60939     function createJsxExpression(dotDotDotToken, expression) {
60940         var node = createSynthesizedNode(276);
60941         node.dotDotDotToken = dotDotDotToken;
60942         node.expression = expression;
60943         return node;
60944     }
60945     ts.createJsxExpression = createJsxExpression;
60946     function updateJsxExpression(node, expression) {
60947         return node.expression !== expression
60948             ? updateNode(createJsxExpression(node.dotDotDotToken, expression), node)
60949             : node;
60950     }
60951     ts.updateJsxExpression = updateJsxExpression;
60952     function createCaseClause(expression, statements) {
60953         var node = createSynthesizedNode(277);
60954         node.expression = ts.parenthesizeExpressionForList(expression);
60955         node.statements = createNodeArray(statements);
60956         return node;
60957     }
60958     ts.createCaseClause = createCaseClause;
60959     function updateCaseClause(node, expression, statements) {
60960         return node.expression !== expression
60961             || node.statements !== statements
60962             ? updateNode(createCaseClause(expression, statements), node)
60963             : node;
60964     }
60965     ts.updateCaseClause = updateCaseClause;
60966     function createDefaultClause(statements) {
60967         var node = createSynthesizedNode(278);
60968         node.statements = createNodeArray(statements);
60969         return node;
60970     }
60971     ts.createDefaultClause = createDefaultClause;
60972     function updateDefaultClause(node, statements) {
60973         return node.statements !== statements
60974             ? updateNode(createDefaultClause(statements), node)
60975             : node;
60976     }
60977     ts.updateDefaultClause = updateDefaultClause;
60978     function createHeritageClause(token, types) {
60979         var node = createSynthesizedNode(279);
60980         node.token = token;
60981         node.types = createNodeArray(types);
60982         return node;
60983     }
60984     ts.createHeritageClause = createHeritageClause;
60985     function updateHeritageClause(node, types) {
60986         return node.types !== types
60987             ? updateNode(createHeritageClause(node.token, types), node)
60988             : node;
60989     }
60990     ts.updateHeritageClause = updateHeritageClause;
60991     function createCatchClause(variableDeclaration, block) {
60992         var node = createSynthesizedNode(280);
60993         node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration;
60994         node.block = block;
60995         return node;
60996     }
60997     ts.createCatchClause = createCatchClause;
60998     function updateCatchClause(node, variableDeclaration, block) {
60999         return node.variableDeclaration !== variableDeclaration
61000             || node.block !== block
61001             ? updateNode(createCatchClause(variableDeclaration, block), node)
61002             : node;
61003     }
61004     ts.updateCatchClause = updateCatchClause;
61005     function createPropertyAssignment(name, initializer) {
61006         var node = createSynthesizedNode(281);
61007         node.name = asName(name);
61008         node.questionToken = undefined;
61009         node.initializer = ts.parenthesizeExpressionForList(initializer);
61010         return node;
61011     }
61012     ts.createPropertyAssignment = createPropertyAssignment;
61013     function updatePropertyAssignment(node, name, initializer) {
61014         return node.name !== name
61015             || node.initializer !== initializer
61016             ? updateNode(createPropertyAssignment(name, initializer), node)
61017             : node;
61018     }
61019     ts.updatePropertyAssignment = updatePropertyAssignment;
61020     function createShorthandPropertyAssignment(name, objectAssignmentInitializer) {
61021         var node = createSynthesizedNode(282);
61022         node.name = asName(name);
61023         node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined;
61024         return node;
61025     }
61026     ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment;
61027     function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) {
61028         return node.name !== name
61029             || node.objectAssignmentInitializer !== objectAssignmentInitializer
61030             ? updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node)
61031             : node;
61032     }
61033     ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment;
61034     function createSpreadAssignment(expression) {
61035         var node = createSynthesizedNode(283);
61036         node.expression = ts.parenthesizeExpressionForList(expression);
61037         return node;
61038     }
61039     ts.createSpreadAssignment = createSpreadAssignment;
61040     function updateSpreadAssignment(node, expression) {
61041         return node.expression !== expression
61042             ? updateNode(createSpreadAssignment(expression), node)
61043             : node;
61044     }
61045     ts.updateSpreadAssignment = updateSpreadAssignment;
61046     function createEnumMember(name, initializer) {
61047         var node = createSynthesizedNode(284);
61048         node.name = asName(name);
61049         node.initializer = initializer && ts.parenthesizeExpressionForList(initializer);
61050         return node;
61051     }
61052     ts.createEnumMember = createEnumMember;
61053     function updateEnumMember(node, name, initializer) {
61054         return node.name !== name
61055             || node.initializer !== initializer
61056             ? updateNode(createEnumMember(name, initializer), node)
61057             : node;
61058     }
61059     ts.updateEnumMember = updateEnumMember;
61060     function updateSourceFileNode(node, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) {
61061         if (node.statements !== statements ||
61062             (isDeclarationFile !== undefined && node.isDeclarationFile !== isDeclarationFile) ||
61063             (referencedFiles !== undefined && node.referencedFiles !== referencedFiles) ||
61064             (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) ||
61065             (libReferences !== undefined && node.libReferenceDirectives !== libReferences) ||
61066             (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) {
61067             var updated = createSynthesizedNode(290);
61068             updated.flags |= node.flags;
61069             updated.statements = createNodeArray(statements);
61070             updated.endOfFileToken = node.endOfFileToken;
61071             updated.fileName = node.fileName;
61072             updated.path = node.path;
61073             updated.text = node.text;
61074             updated.isDeclarationFile = isDeclarationFile === undefined ? node.isDeclarationFile : isDeclarationFile;
61075             updated.referencedFiles = referencedFiles === undefined ? node.referencedFiles : referencedFiles;
61076             updated.typeReferenceDirectives = typeReferences === undefined ? node.typeReferenceDirectives : typeReferences;
61077             updated.hasNoDefaultLib = hasNoDefaultLib === undefined ? node.hasNoDefaultLib : hasNoDefaultLib;
61078             updated.libReferenceDirectives = libReferences === undefined ? node.libReferenceDirectives : libReferences;
61079             if (node.amdDependencies !== undefined)
61080                 updated.amdDependencies = node.amdDependencies;
61081             if (node.moduleName !== undefined)
61082                 updated.moduleName = node.moduleName;
61083             if (node.languageVariant !== undefined)
61084                 updated.languageVariant = node.languageVariant;
61085             if (node.renamedDependencies !== undefined)
61086                 updated.renamedDependencies = node.renamedDependencies;
61087             if (node.languageVersion !== undefined)
61088                 updated.languageVersion = node.languageVersion;
61089             if (node.scriptKind !== undefined)
61090                 updated.scriptKind = node.scriptKind;
61091             if (node.externalModuleIndicator !== undefined)
61092                 updated.externalModuleIndicator = node.externalModuleIndicator;
61093             if (node.commonJsModuleIndicator !== undefined)
61094                 updated.commonJsModuleIndicator = node.commonJsModuleIndicator;
61095             if (node.identifiers !== undefined)
61096                 updated.identifiers = node.identifiers;
61097             if (node.nodeCount !== undefined)
61098                 updated.nodeCount = node.nodeCount;
61099             if (node.identifierCount !== undefined)
61100                 updated.identifierCount = node.identifierCount;
61101             if (node.symbolCount !== undefined)
61102                 updated.symbolCount = node.symbolCount;
61103             if (node.parseDiagnostics !== undefined)
61104                 updated.parseDiagnostics = node.parseDiagnostics;
61105             if (node.bindDiagnostics !== undefined)
61106                 updated.bindDiagnostics = node.bindDiagnostics;
61107             if (node.bindSuggestionDiagnostics !== undefined)
61108                 updated.bindSuggestionDiagnostics = node.bindSuggestionDiagnostics;
61109             if (node.lineMap !== undefined)
61110                 updated.lineMap = node.lineMap;
61111             if (node.classifiableNames !== undefined)
61112                 updated.classifiableNames = node.classifiableNames;
61113             if (node.resolvedModules !== undefined)
61114                 updated.resolvedModules = node.resolvedModules;
61115             if (node.resolvedTypeReferenceDirectiveNames !== undefined)
61116                 updated.resolvedTypeReferenceDirectiveNames = node.resolvedTypeReferenceDirectiveNames;
61117             if (node.imports !== undefined)
61118                 updated.imports = node.imports;
61119             if (node.moduleAugmentations !== undefined)
61120                 updated.moduleAugmentations = node.moduleAugmentations;
61121             if (node.pragmas !== undefined)
61122                 updated.pragmas = node.pragmas;
61123             if (node.localJsxFactory !== undefined)
61124                 updated.localJsxFactory = node.localJsxFactory;
61125             if (node.localJsxNamespace !== undefined)
61126                 updated.localJsxNamespace = node.localJsxNamespace;
61127             return updateNode(updated, node);
61128         }
61129         return node;
61130     }
61131     ts.updateSourceFileNode = updateSourceFileNode;
61132     function getMutableClone(node) {
61133         var clone = getSynthesizedClone(node);
61134         clone.pos = node.pos;
61135         clone.end = node.end;
61136         clone.parent = node.parent;
61137         return clone;
61138     }
61139     ts.getMutableClone = getMutableClone;
61140     function createNotEmittedStatement(original) {
61141         var node = createSynthesizedNode(325);
61142         node.original = original;
61143         setTextRange(node, original);
61144         return node;
61145     }
61146     ts.createNotEmittedStatement = createNotEmittedStatement;
61147     function createEndOfDeclarationMarker(original) {
61148         var node = createSynthesizedNode(329);
61149         node.emitNode = {};
61150         node.original = original;
61151         return node;
61152     }
61153     ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker;
61154     function createMergeDeclarationMarker(original) {
61155         var node = createSynthesizedNode(328);
61156         node.emitNode = {};
61157         node.original = original;
61158         return node;
61159     }
61160     ts.createMergeDeclarationMarker = createMergeDeclarationMarker;
61161     function createPartiallyEmittedExpression(expression, original) {
61162         var node = createSynthesizedNode(326);
61163         node.expression = expression;
61164         node.original = original;
61165         setTextRange(node, original);
61166         return node;
61167     }
61168     ts.createPartiallyEmittedExpression = createPartiallyEmittedExpression;
61169     function updatePartiallyEmittedExpression(node, expression) {
61170         if (node.expression !== expression) {
61171             return updateNode(createPartiallyEmittedExpression(expression, node.original), node);
61172         }
61173         return node;
61174     }
61175     ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression;
61176     function flattenCommaElements(node) {
61177         if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) {
61178             if (node.kind === 327) {
61179                 return node.elements;
61180             }
61181             if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27) {
61182                 return [node.left, node.right];
61183             }
61184         }
61185         return node;
61186     }
61187     function createCommaList(elements) {
61188         var node = createSynthesizedNode(327);
61189         node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements));
61190         return node;
61191     }
61192     ts.createCommaList = createCommaList;
61193     function updateCommaList(node, elements) {
61194         return node.elements !== elements
61195             ? updateNode(createCommaList(elements), node)
61196             : node;
61197     }
61198     ts.updateCommaList = updateCommaList;
61199     function createSyntheticReferenceExpression(expression, thisArg) {
61200         var node = createSynthesizedNode(330);
61201         node.expression = expression;
61202         node.thisArg = thisArg;
61203         return node;
61204     }
61205     ts.createSyntheticReferenceExpression = createSyntheticReferenceExpression;
61206     function updateSyntheticReferenceExpression(node, expression, thisArg) {
61207         return node.expression !== expression
61208             || node.thisArg !== thisArg
61209             ? updateNode(createSyntheticReferenceExpression(expression, thisArg), node)
61210             : node;
61211     }
61212     ts.updateSyntheticReferenceExpression = updateSyntheticReferenceExpression;
61213     function createBundle(sourceFiles, prepends) {
61214         if (prepends === void 0) { prepends = ts.emptyArray; }
61215         var node = ts.createNode(291);
61216         node.prepends = prepends;
61217         node.sourceFiles = sourceFiles;
61218         return node;
61219     }
61220     ts.createBundle = createBundle;
61221     var allUnscopedEmitHelpers;
61222     function getAllUnscopedEmitHelpers() {
61223         return allUnscopedEmitHelpers || (allUnscopedEmitHelpers = ts.arrayToMap([
61224             ts.valuesHelper,
61225             ts.readHelper,
61226             ts.spreadHelper,
61227             ts.spreadArraysHelper,
61228             ts.restHelper,
61229             ts.decorateHelper,
61230             ts.metadataHelper,
61231             ts.paramHelper,
61232             ts.awaiterHelper,
61233             ts.assignHelper,
61234             ts.awaitHelper,
61235             ts.asyncGeneratorHelper,
61236             ts.asyncDelegator,
61237             ts.asyncValues,
61238             ts.extendsHelper,
61239             ts.templateObjectHelper,
61240             ts.generatorHelper,
61241             ts.importStarHelper,
61242             ts.importDefaultHelper,
61243             ts.classPrivateFieldGetHelper,
61244             ts.classPrivateFieldSetHelper,
61245             ts.createBindingHelper,
61246             ts.setModuleDefaultHelper
61247         ], function (helper) { return helper.name; }));
61248     }
61249     function createUnparsedSource() {
61250         var node = ts.createNode(292);
61251         node.prologues = ts.emptyArray;
61252         node.referencedFiles = ts.emptyArray;
61253         node.libReferenceDirectives = ts.emptyArray;
61254         node.getLineAndCharacterOfPosition = function (pos) { return ts.getLineAndCharacterOfPosition(node, pos); };
61255         return node;
61256     }
61257     function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, mapTextOrStripInternal) {
61258         var node = createUnparsedSource();
61259         var stripInternal;
61260         var bundleFileInfo;
61261         if (!ts.isString(textOrInputFiles)) {
61262             ts.Debug.assert(mapPathOrType === "js" || mapPathOrType === "dts");
61263             node.fileName = (mapPathOrType === "js" ? textOrInputFiles.javascriptPath : textOrInputFiles.declarationPath) || "";
61264             node.sourceMapPath = mapPathOrType === "js" ? textOrInputFiles.javascriptMapPath : textOrInputFiles.declarationMapPath;
61265             Object.defineProperties(node, {
61266                 text: { get: function () { return mapPathOrType === "js" ? textOrInputFiles.javascriptText : textOrInputFiles.declarationText; } },
61267                 sourceMapText: { get: function () { return mapPathOrType === "js" ? textOrInputFiles.javascriptMapText : textOrInputFiles.declarationMapText; } },
61268             });
61269             if (textOrInputFiles.buildInfo && textOrInputFiles.buildInfo.bundle) {
61270                 node.oldFileOfCurrentEmit = textOrInputFiles.oldFileOfCurrentEmit;
61271                 ts.Debug.assert(mapTextOrStripInternal === undefined || typeof mapTextOrStripInternal === "boolean");
61272                 stripInternal = mapTextOrStripInternal;
61273                 bundleFileInfo = mapPathOrType === "js" ? textOrInputFiles.buildInfo.bundle.js : textOrInputFiles.buildInfo.bundle.dts;
61274                 if (node.oldFileOfCurrentEmit) {
61275                     parseOldFileOfCurrentEmit(node, ts.Debug.checkDefined(bundleFileInfo));
61276                     return node;
61277                 }
61278             }
61279         }
61280         else {
61281             node.fileName = "";
61282             node.text = textOrInputFiles;
61283             node.sourceMapPath = mapPathOrType;
61284             node.sourceMapText = mapTextOrStripInternal;
61285         }
61286         ts.Debug.assert(!node.oldFileOfCurrentEmit);
61287         parseUnparsedSourceFile(node, bundleFileInfo, stripInternal);
61288         return node;
61289     }
61290     ts.createUnparsedSourceFile = createUnparsedSourceFile;
61291     function parseUnparsedSourceFile(node, bundleFileInfo, stripInternal) {
61292         var prologues;
61293         var helpers;
61294         var referencedFiles;
61295         var typeReferenceDirectives;
61296         var libReferenceDirectives;
61297         var texts;
61298         for (var _i = 0, _a = bundleFileInfo ? bundleFileInfo.sections : ts.emptyArray; _i < _a.length; _i++) {
61299             var section = _a[_i];
61300             switch (section.kind) {
61301                 case "prologue":
61302                     (prologues || (prologues = [])).push(createUnparsedNode(section, node));
61303                     break;
61304                 case "emitHelpers":
61305                     (helpers || (helpers = [])).push(getAllUnscopedEmitHelpers().get(section.data));
61306                     break;
61307                 case "no-default-lib":
61308                     node.hasNoDefaultLib = true;
61309                     break;
61310                 case "reference":
61311                     (referencedFiles || (referencedFiles = [])).push({ pos: -1, end: -1, fileName: section.data });
61312                     break;
61313                 case "type":
61314                     (typeReferenceDirectives || (typeReferenceDirectives = [])).push(section.data);
61315                     break;
61316                 case "lib":
61317                     (libReferenceDirectives || (libReferenceDirectives = [])).push({ pos: -1, end: -1, fileName: section.data });
61318                     break;
61319                 case "prepend":
61320                     var prependNode = createUnparsedNode(section, node);
61321                     var prependTexts = void 0;
61322                     for (var _b = 0, _c = section.texts; _b < _c.length; _b++) {
61323                         var text = _c[_b];
61324                         if (!stripInternal || text.kind !== "internal") {
61325                             (prependTexts || (prependTexts = [])).push(createUnparsedNode(text, node));
61326                         }
61327                     }
61328                     prependNode.texts = prependTexts || ts.emptyArray;
61329                     (texts || (texts = [])).push(prependNode);
61330                     break;
61331                 case "internal":
61332                     if (stripInternal) {
61333                         if (!texts)
61334                             texts = [];
61335                         break;
61336                     }
61337                 case "text":
61338                     (texts || (texts = [])).push(createUnparsedNode(section, node));
61339                     break;
61340                 default:
61341                     ts.Debug.assertNever(section);
61342             }
61343         }
61344         node.prologues = prologues || ts.emptyArray;
61345         node.helpers = helpers;
61346         node.referencedFiles = referencedFiles || ts.emptyArray;
61347         node.typeReferenceDirectives = typeReferenceDirectives;
61348         node.libReferenceDirectives = libReferenceDirectives || ts.emptyArray;
61349         node.texts = texts || [createUnparsedNode({ kind: "text", pos: 0, end: node.text.length }, node)];
61350     }
61351     function parseOldFileOfCurrentEmit(node, bundleFileInfo) {
61352         ts.Debug.assert(!!node.oldFileOfCurrentEmit);
61353         var texts;
61354         var syntheticReferences;
61355         for (var _i = 0, _a = bundleFileInfo.sections; _i < _a.length; _i++) {
61356             var section = _a[_i];
61357             switch (section.kind) {
61358                 case "internal":
61359                 case "text":
61360                     (texts || (texts = [])).push(createUnparsedNode(section, node));
61361                     break;
61362                 case "no-default-lib":
61363                 case "reference":
61364                 case "type":
61365                 case "lib":
61366                     (syntheticReferences || (syntheticReferences = [])).push(createUnparsedSyntheticReference(section, node));
61367                     break;
61368                 case "prologue":
61369                 case "emitHelpers":
61370                 case "prepend":
61371                     break;
61372                 default:
61373                     ts.Debug.assertNever(section);
61374             }
61375         }
61376         node.texts = texts || ts.emptyArray;
61377         node.helpers = ts.map(bundleFileInfo.sources && bundleFileInfo.sources.helpers, function (name) { return getAllUnscopedEmitHelpers().get(name); });
61378         node.syntheticReferences = syntheticReferences;
61379         return node;
61380     }
61381     function mapBundleFileSectionKindToSyntaxKind(kind) {
61382         switch (kind) {
61383             case "prologue": return 285;
61384             case "prepend": return 286;
61385             case "internal": return 288;
61386             case "text": return 287;
61387             case "emitHelpers":
61388             case "no-default-lib":
61389             case "reference":
61390             case "type":
61391             case "lib":
61392                 return ts.Debug.fail("BundleFileSectionKind: " + kind + " not yet mapped to SyntaxKind");
61393             default:
61394                 return ts.Debug.assertNever(kind);
61395         }
61396     }
61397     function createUnparsedNode(section, parent) {
61398         var node = ts.createNode(mapBundleFileSectionKindToSyntaxKind(section.kind), section.pos, section.end);
61399         node.parent = parent;
61400         node.data = section.data;
61401         return node;
61402     }
61403     function createUnparsedSyntheticReference(section, parent) {
61404         var node = ts.createNode(289, section.pos, section.end);
61405         node.parent = parent;
61406         node.data = section.data;
61407         node.section = section;
61408         return node;
61409     }
61410     function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) {
61411         var node = ts.createNode(293);
61412         if (!ts.isString(javascriptTextOrReadFileText)) {
61413             var cache_1 = ts.createMap();
61414             var textGetter_1 = function (path) {
61415                 if (path === undefined)
61416                     return undefined;
61417                 var value = cache_1.get(path);
61418                 if (value === undefined) {
61419                     value = javascriptTextOrReadFileText(path);
61420                     cache_1.set(path, value !== undefined ? value : false);
61421                 }
61422                 return value !== false ? value : undefined;
61423             };
61424             var definedTextGetter_1 = function (path) {
61425                 var result = textGetter_1(path);
61426                 return result !== undefined ? result : "/* Input file " + path + " was missing */\r\n";
61427             };
61428             var buildInfo_1;
61429             var getAndCacheBuildInfo_1 = function (getText) {
61430                 if (buildInfo_1 === undefined) {
61431                     var result = getText();
61432                     buildInfo_1 = result !== undefined ? ts.getBuildInfo(result) : false;
61433                 }
61434                 return buildInfo_1 || undefined;
61435             };
61436             node.javascriptPath = declarationTextOrJavascriptPath;
61437             node.javascriptMapPath = javascriptMapPath;
61438             node.declarationPath = ts.Debug.checkDefined(javascriptMapTextOrDeclarationPath);
61439             node.declarationMapPath = declarationMapPath;
61440             node.buildInfoPath = declarationMapTextOrBuildInfoPath;
61441             Object.defineProperties(node, {
61442                 javascriptText: { get: function () { return definedTextGetter_1(declarationTextOrJavascriptPath); } },
61443                 javascriptMapText: { get: function () { return textGetter_1(javascriptMapPath); } },
61444                 declarationText: { get: function () { return definedTextGetter_1(ts.Debug.checkDefined(javascriptMapTextOrDeclarationPath)); } },
61445                 declarationMapText: { get: function () { return textGetter_1(declarationMapPath); } },
61446                 buildInfo: { get: function () { return getAndCacheBuildInfo_1(function () { return textGetter_1(declarationMapTextOrBuildInfoPath); }); } }
61447             });
61448         }
61449         else {
61450             node.javascriptText = javascriptTextOrReadFileText;
61451             node.javascriptMapPath = javascriptMapPath;
61452             node.javascriptMapText = javascriptMapTextOrDeclarationPath;
61453             node.declarationText = declarationTextOrJavascriptPath;
61454             node.declarationMapPath = declarationMapPath;
61455             node.declarationMapText = declarationMapTextOrBuildInfoPath;
61456             node.javascriptPath = javascriptPath;
61457             node.declarationPath = declarationPath;
61458             node.buildInfoPath = buildInfoPath;
61459             node.buildInfo = buildInfo;
61460             node.oldFileOfCurrentEmit = oldFileOfCurrentEmit;
61461         }
61462         return node;
61463     }
61464     ts.createInputFiles = createInputFiles;
61465     function updateBundle(node, sourceFiles, prepends) {
61466         if (prepends === void 0) { prepends = ts.emptyArray; }
61467         if (node.sourceFiles !== sourceFiles || node.prepends !== prepends) {
61468             return createBundle(sourceFiles, prepends);
61469         }
61470         return node;
61471     }
61472     ts.updateBundle = updateBundle;
61473     function createImmediatelyInvokedFunctionExpression(statements, param, paramValue) {
61474         return createCall(createFunctionExpression(undefined, undefined, undefined, undefined, param ? [param] : [], undefined, createBlock(statements, true)), undefined, paramValue ? [paramValue] : []);
61475     }
61476     ts.createImmediatelyInvokedFunctionExpression = createImmediatelyInvokedFunctionExpression;
61477     function createImmediatelyInvokedArrowFunction(statements, param, paramValue) {
61478         return createCall(createArrowFunction(undefined, undefined, param ? [param] : [], undefined, undefined, createBlock(statements, true)), undefined, paramValue ? [paramValue] : []);
61479     }
61480     ts.createImmediatelyInvokedArrowFunction = createImmediatelyInvokedArrowFunction;
61481     function createComma(left, right) {
61482         return createBinary(left, 27, right);
61483     }
61484     ts.createComma = createComma;
61485     function createLessThan(left, right) {
61486         return createBinary(left, 29, right);
61487     }
61488     ts.createLessThan = createLessThan;
61489     function createAssignment(left, right) {
61490         return createBinary(left, 62, right);
61491     }
61492     ts.createAssignment = createAssignment;
61493     function createStrictEquality(left, right) {
61494         return createBinary(left, 36, right);
61495     }
61496     ts.createStrictEquality = createStrictEquality;
61497     function createStrictInequality(left, right) {
61498         return createBinary(left, 37, right);
61499     }
61500     ts.createStrictInequality = createStrictInequality;
61501     function createAdd(left, right) {
61502         return createBinary(left, 39, right);
61503     }
61504     ts.createAdd = createAdd;
61505     function createSubtract(left, right) {
61506         return createBinary(left, 40, right);
61507     }
61508     ts.createSubtract = createSubtract;
61509     function createPostfixIncrement(operand) {
61510         return createPostfix(operand, 45);
61511     }
61512     ts.createPostfixIncrement = createPostfixIncrement;
61513     function createLogicalAnd(left, right) {
61514         return createBinary(left, 55, right);
61515     }
61516     ts.createLogicalAnd = createLogicalAnd;
61517     function createLogicalOr(left, right) {
61518         return createBinary(left, 56, right);
61519     }
61520     ts.createLogicalOr = createLogicalOr;
61521     function createNullishCoalesce(left, right) {
61522         return createBinary(left, 60, right);
61523     }
61524     ts.createNullishCoalesce = createNullishCoalesce;
61525     function createLogicalNot(operand) {
61526         return createPrefix(53, operand);
61527     }
61528     ts.createLogicalNot = createLogicalNot;
61529     function createVoidZero() {
61530         return createVoid(createLiteral(0));
61531     }
61532     ts.createVoidZero = createVoidZero;
61533     function createExportDefault(expression) {
61534         return createExportAssignment(undefined, undefined, false, expression);
61535     }
61536     ts.createExportDefault = createExportDefault;
61537     function createExternalModuleExport(exportName) {
61538         return createExportDeclaration(undefined, undefined, createNamedExports([createExportSpecifier(undefined, exportName)]));
61539     }
61540     ts.createExternalModuleExport = createExternalModuleExport;
61541     function asName(name) {
61542         return ts.isString(name) ? createIdentifier(name) : name;
61543     }
61544     function asExpression(value) {
61545         return typeof value === "string" ? createStringLiteral(value) :
61546             typeof value === "number" ? createNumericLiteral("" + value) :
61547                 typeof value === "boolean" ? value ? createTrue() : createFalse() :
61548                     value;
61549     }
61550     function asNodeArray(array) {
61551         return array ? createNodeArray(array) : undefined;
61552     }
61553     function asToken(value) {
61554         return typeof value === "number" ? createToken(value) : value;
61555     }
61556     function asEmbeddedStatement(statement) {
61557         return statement && ts.isNotEmittedStatement(statement) ? setTextRange(setOriginalNode(createEmptyStatement(), statement), statement) : statement;
61558     }
61559     function disposeEmitNodes(sourceFile) {
61560         sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile));
61561         var emitNode = sourceFile && sourceFile.emitNode;
61562         var annotatedNodes = emitNode && emitNode.annotatedNodes;
61563         if (annotatedNodes) {
61564             for (var _i = 0, annotatedNodes_1 = annotatedNodes; _i < annotatedNodes_1.length; _i++) {
61565                 var node = annotatedNodes_1[_i];
61566                 node.emitNode = undefined;
61567             }
61568         }
61569     }
61570     ts.disposeEmitNodes = disposeEmitNodes;
61571     function getOrCreateEmitNode(node) {
61572         if (!node.emitNode) {
61573             if (ts.isParseTreeNode(node)) {
61574                 if (node.kind === 290) {
61575                     return node.emitNode = { annotatedNodes: [node] };
61576                 }
61577                 var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node)));
61578                 getOrCreateEmitNode(sourceFile).annotatedNodes.push(node);
61579             }
61580             node.emitNode = {};
61581         }
61582         return node.emitNode;
61583     }
61584     ts.getOrCreateEmitNode = getOrCreateEmitNode;
61585     function removeAllComments(node) {
61586         var emitNode = getOrCreateEmitNode(node);
61587         emitNode.flags |= 1536;
61588         emitNode.leadingComments = undefined;
61589         emitNode.trailingComments = undefined;
61590         return node;
61591     }
61592     ts.removeAllComments = removeAllComments;
61593     function setTextRange(range, location) {
61594         if (location) {
61595             range.pos = location.pos;
61596             range.end = location.end;
61597         }
61598         return range;
61599     }
61600     ts.setTextRange = setTextRange;
61601     function setEmitFlags(node, emitFlags) {
61602         getOrCreateEmitNode(node).flags = emitFlags;
61603         return node;
61604     }
61605     ts.setEmitFlags = setEmitFlags;
61606     function addEmitFlags(node, emitFlags) {
61607         var emitNode = getOrCreateEmitNode(node);
61608         emitNode.flags = emitNode.flags | emitFlags;
61609         return node;
61610     }
61611     ts.addEmitFlags = addEmitFlags;
61612     function getSourceMapRange(node) {
61613         var emitNode = node.emitNode;
61614         return (emitNode && emitNode.sourceMapRange) || node;
61615     }
61616     ts.getSourceMapRange = getSourceMapRange;
61617     function setSourceMapRange(node, range) {
61618         getOrCreateEmitNode(node).sourceMapRange = range;
61619         return node;
61620     }
61621     ts.setSourceMapRange = setSourceMapRange;
61622     var SourceMapSource;
61623     function createSourceMapSource(fileName, text, skipTrivia) {
61624         return new (SourceMapSource || (SourceMapSource = ts.objectAllocator.getSourceMapSourceConstructor()))(fileName, text, skipTrivia);
61625     }
61626     ts.createSourceMapSource = createSourceMapSource;
61627     function getTokenSourceMapRange(node, token) {
61628         var emitNode = node.emitNode;
61629         var tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges;
61630         return tokenSourceMapRanges && tokenSourceMapRanges[token];
61631     }
61632     ts.getTokenSourceMapRange = getTokenSourceMapRange;
61633     function setTokenSourceMapRange(node, token, range) {
61634         var emitNode = getOrCreateEmitNode(node);
61635         var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = []);
61636         tokenSourceMapRanges[token] = range;
61637         return node;
61638     }
61639     ts.setTokenSourceMapRange = setTokenSourceMapRange;
61640     function getStartsOnNewLine(node) {
61641         var emitNode = node.emitNode;
61642         return emitNode && emitNode.startsOnNewLine;
61643     }
61644     ts.getStartsOnNewLine = getStartsOnNewLine;
61645     function setStartsOnNewLine(node, newLine) {
61646         getOrCreateEmitNode(node).startsOnNewLine = newLine;
61647         return node;
61648     }
61649     ts.setStartsOnNewLine = setStartsOnNewLine;
61650     function getCommentRange(node) {
61651         var emitNode = node.emitNode;
61652         return (emitNode && emitNode.commentRange) || node;
61653     }
61654     ts.getCommentRange = getCommentRange;
61655     function setCommentRange(node, range) {
61656         getOrCreateEmitNode(node).commentRange = range;
61657         return node;
61658     }
61659     ts.setCommentRange = setCommentRange;
61660     function getSyntheticLeadingComments(node) {
61661         var emitNode = node.emitNode;
61662         return emitNode && emitNode.leadingComments;
61663     }
61664     ts.getSyntheticLeadingComments = getSyntheticLeadingComments;
61665     function setSyntheticLeadingComments(node, comments) {
61666         getOrCreateEmitNode(node).leadingComments = comments;
61667         return node;
61668     }
61669     ts.setSyntheticLeadingComments = setSyntheticLeadingComments;
61670     function addSyntheticLeadingComment(node, kind, text, hasTrailingNewLine) {
61671         return setSyntheticLeadingComments(node, ts.append(getSyntheticLeadingComments(node), { kind: kind, pos: -1, end: -1, hasTrailingNewLine: hasTrailingNewLine, text: text }));
61672     }
61673     ts.addSyntheticLeadingComment = addSyntheticLeadingComment;
61674     function getSyntheticTrailingComments(node) {
61675         var emitNode = node.emitNode;
61676         return emitNode && emitNode.trailingComments;
61677     }
61678     ts.getSyntheticTrailingComments = getSyntheticTrailingComments;
61679     function setSyntheticTrailingComments(node, comments) {
61680         getOrCreateEmitNode(node).trailingComments = comments;
61681         return node;
61682     }
61683     ts.setSyntheticTrailingComments = setSyntheticTrailingComments;
61684     function addSyntheticTrailingComment(node, kind, text, hasTrailingNewLine) {
61685         return setSyntheticTrailingComments(node, ts.append(getSyntheticTrailingComments(node), { kind: kind, pos: -1, end: -1, hasTrailingNewLine: hasTrailingNewLine, text: text }));
61686     }
61687     ts.addSyntheticTrailingComment = addSyntheticTrailingComment;
61688     function moveSyntheticComments(node, original) {
61689         setSyntheticLeadingComments(node, getSyntheticLeadingComments(original));
61690         setSyntheticTrailingComments(node, getSyntheticTrailingComments(original));
61691         var emit = getOrCreateEmitNode(original);
61692         emit.leadingComments = undefined;
61693         emit.trailingComments = undefined;
61694         return node;
61695     }
61696     ts.moveSyntheticComments = moveSyntheticComments;
61697     function ignoreSourceNewlines(node) {
61698         getOrCreateEmitNode(node).flags |= 134217728;
61699         return node;
61700     }
61701     ts.ignoreSourceNewlines = ignoreSourceNewlines;
61702     function getConstantValue(node) {
61703         var emitNode = node.emitNode;
61704         return emitNode && emitNode.constantValue;
61705     }
61706     ts.getConstantValue = getConstantValue;
61707     function setConstantValue(node, value) {
61708         var emitNode = getOrCreateEmitNode(node);
61709         emitNode.constantValue = value;
61710         return node;
61711     }
61712     ts.setConstantValue = setConstantValue;
61713     function addEmitHelper(node, helper) {
61714         var emitNode = getOrCreateEmitNode(node);
61715         emitNode.helpers = ts.append(emitNode.helpers, helper);
61716         return node;
61717     }
61718     ts.addEmitHelper = addEmitHelper;
61719     function addEmitHelpers(node, helpers) {
61720         if (ts.some(helpers)) {
61721             var emitNode = getOrCreateEmitNode(node);
61722             for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) {
61723                 var helper = helpers_1[_i];
61724                 emitNode.helpers = ts.appendIfUnique(emitNode.helpers, helper);
61725             }
61726         }
61727         return node;
61728     }
61729     ts.addEmitHelpers = addEmitHelpers;
61730     function removeEmitHelper(node, helper) {
61731         var emitNode = node.emitNode;
61732         if (emitNode) {
61733             var helpers = emitNode.helpers;
61734             if (helpers) {
61735                 return ts.orderedRemoveItem(helpers, helper);
61736             }
61737         }
61738         return false;
61739     }
61740     ts.removeEmitHelper = removeEmitHelper;
61741     function getEmitHelpers(node) {
61742         var emitNode = node.emitNode;
61743         return emitNode && emitNode.helpers;
61744     }
61745     ts.getEmitHelpers = getEmitHelpers;
61746     function moveEmitHelpers(source, target, predicate) {
61747         var sourceEmitNode = source.emitNode;
61748         var sourceEmitHelpers = sourceEmitNode && sourceEmitNode.helpers;
61749         if (!ts.some(sourceEmitHelpers))
61750             return;
61751         var targetEmitNode = getOrCreateEmitNode(target);
61752         var helpersRemoved = 0;
61753         for (var i = 0; i < sourceEmitHelpers.length; i++) {
61754             var helper = sourceEmitHelpers[i];
61755             if (predicate(helper)) {
61756                 helpersRemoved++;
61757                 targetEmitNode.helpers = ts.appendIfUnique(targetEmitNode.helpers, helper);
61758             }
61759             else if (helpersRemoved > 0) {
61760                 sourceEmitHelpers[i - helpersRemoved] = helper;
61761             }
61762         }
61763         if (helpersRemoved > 0) {
61764             sourceEmitHelpers.length -= helpersRemoved;
61765         }
61766     }
61767     ts.moveEmitHelpers = moveEmitHelpers;
61768     function compareEmitHelpers(x, y) {
61769         if (x === y)
61770             return 0;
61771         if (x.priority === y.priority)
61772             return 0;
61773         if (x.priority === undefined)
61774             return 1;
61775         if (y.priority === undefined)
61776             return -1;
61777         return ts.compareValues(x.priority, y.priority);
61778     }
61779     ts.compareEmitHelpers = compareEmitHelpers;
61780     function setOriginalNode(node, original) {
61781         node.original = original;
61782         if (original) {
61783             var emitNode = original.emitNode;
61784             if (emitNode)
61785                 node.emitNode = mergeEmitNode(emitNode, node.emitNode);
61786         }
61787         return node;
61788     }
61789     ts.setOriginalNode = setOriginalNode;
61790     function mergeEmitNode(sourceEmitNode, destEmitNode) {
61791         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;
61792         if (!destEmitNode)
61793             destEmitNode = {};
61794         if (leadingComments)
61795             destEmitNode.leadingComments = ts.addRange(leadingComments.slice(), destEmitNode.leadingComments);
61796         if (trailingComments)
61797             destEmitNode.trailingComments = ts.addRange(trailingComments.slice(), destEmitNode.trailingComments);
61798         if (flags)
61799             destEmitNode.flags = flags;
61800         if (commentRange)
61801             destEmitNode.commentRange = commentRange;
61802         if (sourceMapRange)
61803             destEmitNode.sourceMapRange = sourceMapRange;
61804         if (tokenSourceMapRanges)
61805             destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges);
61806         if (constantValue !== undefined)
61807             destEmitNode.constantValue = constantValue;
61808         if (helpers)
61809             destEmitNode.helpers = ts.addRange(destEmitNode.helpers, helpers);
61810         if (startsOnNewLine !== undefined)
61811             destEmitNode.startsOnNewLine = startsOnNewLine;
61812         return destEmitNode;
61813     }
61814     function mergeTokenSourceMapRanges(sourceRanges, destRanges) {
61815         if (!destRanges)
61816             destRanges = [];
61817         for (var key in sourceRanges) {
61818             destRanges[key] = sourceRanges[key];
61819         }
61820         return destRanges;
61821     }
61822 })(ts || (ts = {}));
61823 var ts;
61824 (function (ts) {
61825     ts.nullTransformationContext = {
61826         enableEmitNotification: ts.noop,
61827         enableSubstitution: ts.noop,
61828         endLexicalEnvironment: ts.returnUndefined,
61829         getCompilerOptions: function () { return ({}); },
61830         getEmitHost: ts.notImplemented,
61831         getEmitResolver: ts.notImplemented,
61832         setLexicalEnvironmentFlags: ts.noop,
61833         getLexicalEnvironmentFlags: function () { return 0; },
61834         hoistFunctionDeclaration: ts.noop,
61835         hoistVariableDeclaration: ts.noop,
61836         addInitializationStatement: ts.noop,
61837         isEmitNotificationEnabled: ts.notImplemented,
61838         isSubstitutionEnabled: ts.notImplemented,
61839         onEmitNode: ts.noop,
61840         onSubstituteNode: ts.notImplemented,
61841         readEmitHelpers: ts.notImplemented,
61842         requestEmitHelper: ts.noop,
61843         resumeLexicalEnvironment: ts.noop,
61844         startLexicalEnvironment: ts.noop,
61845         suspendLexicalEnvironment: ts.noop,
61846         addDiagnostic: ts.noop,
61847     };
61848     function createTypeCheck(value, tag) {
61849         return tag === "undefined"
61850             ? ts.createStrictEquality(value, ts.createVoidZero())
61851             : ts.createStrictEquality(ts.createTypeOf(value), ts.createLiteral(tag));
61852     }
61853     ts.createTypeCheck = createTypeCheck;
61854     function createMemberAccessForPropertyName(target, memberName, location) {
61855         if (ts.isComputedPropertyName(memberName)) {
61856             return ts.setTextRange(ts.createElementAccess(target, memberName.expression), location);
61857         }
61858         else {
61859             var expression = ts.setTextRange((ts.isIdentifier(memberName) || ts.isPrivateIdentifier(memberName))
61860                 ? ts.createPropertyAccess(target, memberName)
61861                 : ts.createElementAccess(target, memberName), memberName);
61862             ts.getOrCreateEmitNode(expression).flags |= 64;
61863             return expression;
61864         }
61865     }
61866     ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName;
61867     function createFunctionCall(func, thisArg, argumentsList, location) {
61868         return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "call"), undefined, __spreadArrays([
61869             thisArg
61870         ], argumentsList)), location);
61871     }
61872     ts.createFunctionCall = createFunctionCall;
61873     function createFunctionApply(func, thisArg, argumentsExpression, location) {
61874         return ts.setTextRange(ts.createCall(ts.createPropertyAccess(func, "apply"), undefined, [
61875             thisArg,
61876             argumentsExpression
61877         ]), location);
61878     }
61879     ts.createFunctionApply = createFunctionApply;
61880     function createArraySlice(array, start) {
61881         var argumentsList = [];
61882         if (start !== undefined) {
61883             argumentsList.push(typeof start === "number" ? ts.createLiteral(start) : start);
61884         }
61885         return ts.createCall(ts.createPropertyAccess(array, "slice"), undefined, argumentsList);
61886     }
61887     ts.createArraySlice = createArraySlice;
61888     function createArrayConcat(array, values) {
61889         return ts.createCall(ts.createPropertyAccess(array, "concat"), undefined, values);
61890     }
61891     ts.createArrayConcat = createArrayConcat;
61892     function createMathPow(left, right, location) {
61893         return ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Math"), "pow"), undefined, [left, right]), location);
61894     }
61895     ts.createMathPow = createMathPow;
61896     function createReactNamespace(reactNamespace, parent) {
61897         var react = ts.createIdentifier(reactNamespace || "React");
61898         react.flags &= ~8;
61899         react.parent = ts.getParseTreeNode(parent);
61900         return react;
61901     }
61902     function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) {
61903         if (ts.isQualifiedName(jsxFactory)) {
61904             var left = createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent);
61905             var right = ts.createIdentifier(ts.idText(jsxFactory.right));
61906             right.escapedText = jsxFactory.right.escapedText;
61907             return ts.createPropertyAccess(left, right);
61908         }
61909         else {
61910             return createReactNamespace(ts.idText(jsxFactory), parent);
61911         }
61912     }
61913     function createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parent) {
61914         return jsxFactoryEntity ?
61915             createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) :
61916             ts.createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement");
61917     }
61918     function createExpressionForJsxElement(jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) {
61919         var argumentsList = [tagName];
61920         if (props) {
61921             argumentsList.push(props);
61922         }
61923         if (children && children.length > 0) {
61924             if (!props) {
61925                 argumentsList.push(ts.createNull());
61926             }
61927             if (children.length > 1) {
61928                 for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
61929                     var child = children_2[_i];
61930                     startOnNewLine(child);
61931                     argumentsList.push(child);
61932                 }
61933             }
61934             else {
61935                 argumentsList.push(children[0]);
61936             }
61937         }
61938         return ts.setTextRange(ts.createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList), location);
61939     }
61940     ts.createExpressionForJsxElement = createExpressionForJsxElement;
61941     function createExpressionForJsxFragment(jsxFactoryEntity, reactNamespace, children, parentElement, location) {
61942         var tagName = ts.createPropertyAccess(createReactNamespace(reactNamespace, parentElement), "Fragment");
61943         var argumentsList = [tagName];
61944         argumentsList.push(ts.createNull());
61945         if (children && children.length > 0) {
61946             if (children.length > 1) {
61947                 for (var _i = 0, children_3 = children; _i < children_3.length; _i++) {
61948                     var child = children_3[_i];
61949                     startOnNewLine(child);
61950                     argumentsList.push(child);
61951                 }
61952             }
61953             else {
61954                 argumentsList.push(children[0]);
61955             }
61956         }
61957         return ts.setTextRange(ts.createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList), location);
61958     }
61959     ts.createExpressionForJsxFragment = createExpressionForJsxFragment;
61960     function getUnscopedHelperName(name) {
61961         return ts.setEmitFlags(ts.createIdentifier(name), 4096 | 2);
61962     }
61963     ts.getUnscopedHelperName = getUnscopedHelperName;
61964     ts.valuesHelper = {
61965         name: "typescript:values",
61966         importName: "__values",
61967         scoped: false,
61968         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            };"
61969     };
61970     function createValuesHelper(context, expression, location) {
61971         context.requestEmitHelper(ts.valuesHelper);
61972         return ts.setTextRange(ts.createCall(getUnscopedHelperName("__values"), undefined, [expression]), location);
61973     }
61974     ts.createValuesHelper = createValuesHelper;
61975     ts.readHelper = {
61976         name: "typescript:read",
61977         importName: "__read",
61978         scoped: false,
61979         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            };"
61980     };
61981     function createReadHelper(context, iteratorRecord, count, location) {
61982         context.requestEmitHelper(ts.readHelper);
61983         return ts.setTextRange(ts.createCall(getUnscopedHelperName("__read"), undefined, count !== undefined
61984             ? [iteratorRecord, ts.createLiteral(count)]
61985             : [iteratorRecord]), location);
61986     }
61987     ts.createReadHelper = createReadHelper;
61988     ts.spreadHelper = {
61989         name: "typescript:spread",
61990         importName: "__spread",
61991         scoped: false,
61992         dependencies: [ts.readHelper],
61993         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            };"
61994     };
61995     function createSpreadHelper(context, argumentList, location) {
61996         context.requestEmitHelper(ts.spreadHelper);
61997         return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spread"), undefined, argumentList), location);
61998     }
61999     ts.createSpreadHelper = createSpreadHelper;
62000     ts.spreadArraysHelper = {
62001         name: "typescript:spreadArrays",
62002         importName: "__spreadArrays",
62003         scoped: false,
62004         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            };"
62005     };
62006     function createSpreadArraysHelper(context, argumentList, location) {
62007         context.requestEmitHelper(ts.spreadArraysHelper);
62008         return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spreadArrays"), undefined, argumentList), location);
62009     }
62010     ts.createSpreadArraysHelper = createSpreadArraysHelper;
62011     function createForOfBindingStatement(node, boundValue) {
62012         if (ts.isVariableDeclarationList(node)) {
62013             var firstDeclaration = ts.first(node.declarations);
62014             var updatedDeclaration = ts.updateVariableDeclaration(firstDeclaration, firstDeclaration.name, undefined, boundValue);
62015             return ts.setTextRange(ts.createVariableStatement(undefined, ts.updateVariableDeclarationList(node, [updatedDeclaration])), node);
62016         }
62017         else {
62018             var updatedExpression = ts.setTextRange(ts.createAssignment(node, boundValue), node);
62019             return ts.setTextRange(ts.createStatement(updatedExpression), node);
62020         }
62021     }
62022     ts.createForOfBindingStatement = createForOfBindingStatement;
62023     function insertLeadingStatement(dest, source) {
62024         if (ts.isBlock(dest)) {
62025             return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray(__spreadArrays([source], dest.statements)), dest.statements));
62026         }
62027         else {
62028             return ts.createBlock(ts.createNodeArray([dest, source]), true);
62029         }
62030     }
62031     ts.insertLeadingStatement = insertLeadingStatement;
62032     function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) {
62033         if (!outermostLabeledStatement) {
62034             return node;
62035         }
62036         var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 238
62037             ? restoreEnclosingLabel(node, outermostLabeledStatement.statement)
62038             : node);
62039         if (afterRestoreLabelCallback) {
62040             afterRestoreLabelCallback(outermostLabeledStatement);
62041         }
62042         return updated;
62043     }
62044     ts.restoreEnclosingLabel = restoreEnclosingLabel;
62045     function shouldBeCapturedInTempVariable(node, cacheIdentifiers) {
62046         var target = ts.skipParentheses(node);
62047         switch (target.kind) {
62048             case 75:
62049                 return cacheIdentifiers;
62050             case 104:
62051             case 8:
62052             case 9:
62053             case 10:
62054                 return false;
62055             case 192:
62056                 var elements = target.elements;
62057                 if (elements.length === 0) {
62058                     return false;
62059                 }
62060                 return true;
62061             case 193:
62062                 return target.properties.length > 0;
62063             default:
62064                 return true;
62065         }
62066     }
62067     function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) {
62068         if (cacheIdentifiers === void 0) { cacheIdentifiers = false; }
62069         var callee = skipOuterExpressions(expression, 15);
62070         var thisArg;
62071         var target;
62072         if (ts.isSuperProperty(callee)) {
62073             thisArg = ts.createThis();
62074             target = callee;
62075         }
62076         else if (callee.kind === 102) {
62077             thisArg = ts.createThis();
62078             target = languageVersion < 2
62079                 ? ts.setTextRange(ts.createIdentifier("_super"), callee)
62080                 : callee;
62081         }
62082         else if (ts.getEmitFlags(callee) & 4096) {
62083             thisArg = ts.createVoidZero();
62084             target = parenthesizeForAccess(callee);
62085         }
62086         else {
62087             switch (callee.kind) {
62088                 case 194: {
62089                     if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) {
62090                         thisArg = ts.createTempVariable(recordTempVariable);
62091                         target = ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.name);
62092                         ts.setTextRange(target, callee);
62093                     }
62094                     else {
62095                         thisArg = callee.expression;
62096                         target = callee;
62097                     }
62098                     break;
62099                 }
62100                 case 195: {
62101                     if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) {
62102                         thisArg = ts.createTempVariable(recordTempVariable);
62103                         target = ts.createElementAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression);
62104                         ts.setTextRange(target, callee);
62105                     }
62106                     else {
62107                         thisArg = callee.expression;
62108                         target = callee;
62109                     }
62110                     break;
62111                 }
62112                 default: {
62113                     thisArg = ts.createVoidZero();
62114                     target = parenthesizeForAccess(expression);
62115                     break;
62116                 }
62117             }
62118         }
62119         return { target: target, thisArg: thisArg };
62120     }
62121     ts.createCallBinding = createCallBinding;
62122     function inlineExpressions(expressions) {
62123         return expressions.length > 10
62124             ? ts.createCommaList(expressions)
62125             : ts.reduceLeft(expressions, ts.createComma);
62126     }
62127     ts.inlineExpressions = inlineExpressions;
62128     function createExpressionFromEntityName(node) {
62129         if (ts.isQualifiedName(node)) {
62130             var left = createExpressionFromEntityName(node.left);
62131             var right = ts.getMutableClone(node.right);
62132             return ts.setTextRange(ts.createPropertyAccess(left, right), node);
62133         }
62134         else {
62135             return ts.getMutableClone(node);
62136         }
62137     }
62138     ts.createExpressionFromEntityName = createExpressionFromEntityName;
62139     function createExpressionForPropertyName(memberName) {
62140         if (ts.isIdentifier(memberName)) {
62141             return ts.createLiteral(memberName);
62142         }
62143         else if (ts.isComputedPropertyName(memberName)) {
62144             return ts.getMutableClone(memberName.expression);
62145         }
62146         else {
62147             return ts.getMutableClone(memberName);
62148         }
62149     }
62150     ts.createExpressionForPropertyName = createExpressionForPropertyName;
62151     function createExpressionForObjectLiteralElementLike(node, property, receiver) {
62152         if (property.name && ts.isPrivateIdentifier(property.name)) {
62153             ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals.");
62154         }
62155         switch (property.kind) {
62156             case 163:
62157             case 164:
62158                 return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine);
62159             case 281:
62160                 return createExpressionForPropertyAssignment(property, receiver);
62161             case 282:
62162                 return createExpressionForShorthandPropertyAssignment(property, receiver);
62163             case 161:
62164                 return createExpressionForMethodDeclaration(property, receiver);
62165         }
62166     }
62167     ts.createExpressionForObjectLiteralElementLike = createExpressionForObjectLiteralElementLike;
62168     function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) {
62169         var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor;
62170         if (property === firstAccessor) {
62171             var properties_7 = [];
62172             if (getAccessor) {
62173                 var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body);
62174                 ts.setTextRange(getterFunction, getAccessor);
62175                 ts.setOriginalNode(getterFunction, getAccessor);
62176                 var getter = ts.createPropertyAssignment("get", getterFunction);
62177                 properties_7.push(getter);
62178             }
62179             if (setAccessor) {
62180                 var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body);
62181                 ts.setTextRange(setterFunction, setAccessor);
62182                 ts.setOriginalNode(setterFunction, setAccessor);
62183                 var setter = ts.createPropertyAssignment("set", setterFunction);
62184                 properties_7.push(setter);
62185             }
62186             properties_7.push(ts.createPropertyAssignment("enumerable", getAccessor || setAccessor ? ts.createFalse() : ts.createTrue()));
62187             properties_7.push(ts.createPropertyAssignment("configurable", ts.createTrue()));
62188             var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [
62189                 receiver,
62190                 createExpressionForPropertyName(property.name),
62191                 ts.createObjectLiteral(properties_7, multiLine)
62192             ]), firstAccessor);
62193             return ts.aggregateTransformFlags(expression);
62194         }
62195         return undefined;
62196     }
62197     function createExpressionForPropertyAssignment(property, receiver) {
62198         return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), property.initializer), property), property));
62199     }
62200     function createExpressionForShorthandPropertyAssignment(property, receiver) {
62201         return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), ts.getSynthesizedClone(property.name)), property), property));
62202     }
62203     function createExpressionForMethodDeclaration(method, receiver) {
62204         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));
62205     }
62206     function getInternalName(node, allowComments, allowSourceMaps) {
62207         return getName(node, allowComments, allowSourceMaps, 16384 | 32768);
62208     }
62209     ts.getInternalName = getInternalName;
62210     function isInternalName(node) {
62211         return (ts.getEmitFlags(node) & 32768) !== 0;
62212     }
62213     ts.isInternalName = isInternalName;
62214     function getLocalName(node, allowComments, allowSourceMaps) {
62215         return getName(node, allowComments, allowSourceMaps, 16384);
62216     }
62217     ts.getLocalName = getLocalName;
62218     function isLocalName(node) {
62219         return (ts.getEmitFlags(node) & 16384) !== 0;
62220     }
62221     ts.isLocalName = isLocalName;
62222     function getExportName(node, allowComments, allowSourceMaps) {
62223         return getName(node, allowComments, allowSourceMaps, 8192);
62224     }
62225     ts.getExportName = getExportName;
62226     function isExportName(node) {
62227         return (ts.getEmitFlags(node) & 8192) !== 0;
62228     }
62229     ts.isExportName = isExportName;
62230     function getDeclarationName(node, allowComments, allowSourceMaps) {
62231         return getName(node, allowComments, allowSourceMaps);
62232     }
62233     ts.getDeclarationName = getDeclarationName;
62234     function getName(node, allowComments, allowSourceMaps, emitFlags) {
62235         if (emitFlags === void 0) { emitFlags = 0; }
62236         var nodeName = ts.getNameOfDeclaration(node);
62237         if (nodeName && ts.isIdentifier(nodeName) && !ts.isGeneratedIdentifier(nodeName)) {
62238             var name = ts.getMutableClone(nodeName);
62239             emitFlags |= ts.getEmitFlags(nodeName);
62240             if (!allowSourceMaps)
62241                 emitFlags |= 48;
62242             if (!allowComments)
62243                 emitFlags |= 1536;
62244             if (emitFlags)
62245                 ts.setEmitFlags(name, emitFlags);
62246             return name;
62247         }
62248         return ts.getGeneratedNameForNode(node);
62249     }
62250     function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) {
62251         if (ns && ts.hasModifier(node, 1)) {
62252             return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps);
62253         }
62254         return getExportName(node, allowComments, allowSourceMaps);
62255     }
62256     ts.getExternalModuleOrNamespaceExportName = getExternalModuleOrNamespaceExportName;
62257     function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) {
62258         var qualifiedName = ts.createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : ts.getSynthesizedClone(name));
62259         ts.setTextRange(qualifiedName, name);
62260         var emitFlags = 0;
62261         if (!allowSourceMaps)
62262             emitFlags |= 48;
62263         if (!allowComments)
62264             emitFlags |= 1536;
62265         if (emitFlags)
62266             ts.setEmitFlags(qualifiedName, emitFlags);
62267         return qualifiedName;
62268     }
62269     ts.getNamespaceMemberName = getNamespaceMemberName;
62270     function convertToFunctionBody(node, multiLine) {
62271         return ts.isBlock(node) ? node : ts.setTextRange(ts.createBlock([ts.setTextRange(ts.createReturn(node), node)], multiLine), node);
62272     }
62273     ts.convertToFunctionBody = convertToFunctionBody;
62274     function convertFunctionDeclarationToExpression(node) {
62275         if (!node.body)
62276             return ts.Debug.fail();
62277         var updated = ts.createFunctionExpression(node.modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body);
62278         ts.setOriginalNode(updated, node);
62279         ts.setTextRange(updated, node);
62280         if (ts.getStartsOnNewLine(node)) {
62281             ts.setStartsOnNewLine(updated, true);
62282         }
62283         ts.aggregateTransformFlags(updated);
62284         return updated;
62285     }
62286     ts.convertFunctionDeclarationToExpression = convertFunctionDeclarationToExpression;
62287     function isUseStrictPrologue(node) {
62288         return ts.isStringLiteral(node.expression) && node.expression.text === "use strict";
62289     }
62290     function addPrologue(target, source, ensureUseStrict, visitor) {
62291         var offset = addStandardPrologue(target, source, ensureUseStrict);
62292         return addCustomPrologue(target, source, offset, visitor);
62293     }
62294     ts.addPrologue = addPrologue;
62295     function addStandardPrologue(target, source, ensureUseStrict) {
62296         ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array");
62297         var foundUseStrict = false;
62298         var statementOffset = 0;
62299         var numStatements = source.length;
62300         while (statementOffset < numStatements) {
62301             var statement = source[statementOffset];
62302             if (ts.isPrologueDirective(statement)) {
62303                 if (isUseStrictPrologue(statement)) {
62304                     foundUseStrict = true;
62305                 }
62306                 target.push(statement);
62307             }
62308             else {
62309                 break;
62310             }
62311             statementOffset++;
62312         }
62313         if (ensureUseStrict && !foundUseStrict) {
62314             target.push(startOnNewLine(ts.createStatement(ts.createLiteral("use strict"))));
62315         }
62316         return statementOffset;
62317     }
62318     ts.addStandardPrologue = addStandardPrologue;
62319     function addCustomPrologue(target, source, statementOffset, visitor, filter) {
62320         if (filter === void 0) { filter = ts.returnTrue; }
62321         var numStatements = source.length;
62322         while (statementOffset !== undefined && statementOffset < numStatements) {
62323             var statement = source[statementOffset];
62324             if (ts.getEmitFlags(statement) & 1048576 && filter(statement)) {
62325                 ts.append(target, visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement);
62326             }
62327             else {
62328                 break;
62329             }
62330             statementOffset++;
62331         }
62332         return statementOffset;
62333     }
62334     ts.addCustomPrologue = addCustomPrologue;
62335     function findUseStrictPrologue(statements) {
62336         for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) {
62337             var statement = statements_4[_i];
62338             if (ts.isPrologueDirective(statement)) {
62339                 if (isUseStrictPrologue(statement)) {
62340                     return statement;
62341                 }
62342             }
62343             else {
62344                 break;
62345             }
62346         }
62347         return undefined;
62348     }
62349     ts.findUseStrictPrologue = findUseStrictPrologue;
62350     function startsWithUseStrict(statements) {
62351         var firstStatement = ts.firstOrUndefined(statements);
62352         return firstStatement !== undefined
62353             && ts.isPrologueDirective(firstStatement)
62354             && isUseStrictPrologue(firstStatement);
62355     }
62356     ts.startsWithUseStrict = startsWithUseStrict;
62357     function ensureUseStrict(statements) {
62358         var foundUseStrict = findUseStrictPrologue(statements);
62359         if (!foundUseStrict) {
62360             return ts.setTextRange(ts.createNodeArray(__spreadArrays([
62361                 startOnNewLine(ts.createStatement(ts.createLiteral("use strict")))
62362             ], statements)), statements);
62363         }
62364         return statements;
62365     }
62366     ts.ensureUseStrict = ensureUseStrict;
62367     function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) {
62368         var skipped = ts.skipPartiallyEmittedExpressions(operand);
62369         if (skipped.kind === 200) {
62370             return operand;
62371         }
62372         return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand)
62373             ? ts.createParen(operand)
62374             : operand;
62375     }
62376     ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand;
62377     function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) {
62378         var binaryOperatorPrecedence = ts.getOperatorPrecedence(209, binaryOperator);
62379         var binaryOperatorAssociativity = ts.getOperatorAssociativity(209, binaryOperator);
62380         var emittedOperand = ts.skipPartiallyEmittedExpressions(operand);
62381         if (!isLeftSideOfBinary && operand.kind === 202 && binaryOperatorPrecedence > 3) {
62382             return true;
62383         }
62384         var operandPrecedence = ts.getExpressionPrecedence(emittedOperand);
62385         switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) {
62386             case -1:
62387                 if (!isLeftSideOfBinary
62388                     && binaryOperatorAssociativity === 1
62389                     && operand.kind === 212) {
62390                     return false;
62391                 }
62392                 return true;
62393             case 1:
62394                 return false;
62395             case 0:
62396                 if (isLeftSideOfBinary) {
62397                     return binaryOperatorAssociativity === 1;
62398                 }
62399                 else {
62400                     if (ts.isBinaryExpression(emittedOperand)
62401                         && emittedOperand.operatorToken.kind === binaryOperator) {
62402                         if (operatorHasAssociativeProperty(binaryOperator)) {
62403                             return false;
62404                         }
62405                         if (binaryOperator === 39) {
62406                             var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0;
62407                             if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) {
62408                                 return false;
62409                             }
62410                         }
62411                     }
62412                     var operandAssociativity = ts.getExpressionAssociativity(emittedOperand);
62413                     return operandAssociativity === 0;
62414                 }
62415         }
62416     }
62417     function operatorHasAssociativeProperty(binaryOperator) {
62418         return binaryOperator === 41
62419             || binaryOperator === 51
62420             || binaryOperator === 50
62421             || binaryOperator === 52;
62422     }
62423     function getLiteralKindOfBinaryPlusOperand(node) {
62424         node = ts.skipPartiallyEmittedExpressions(node);
62425         if (ts.isLiteralKind(node.kind)) {
62426             return node.kind;
62427         }
62428         if (node.kind === 209 && node.operatorToken.kind === 39) {
62429             if (node.cachedLiteralKind !== undefined) {
62430                 return node.cachedLiteralKind;
62431             }
62432             var leftKind = getLiteralKindOfBinaryPlusOperand(node.left);
62433             var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind :
62434                 0;
62435             node.cachedLiteralKind = literalKind;
62436             return literalKind;
62437         }
62438         return 0;
62439     }
62440     function parenthesizeForConditionalHead(condition) {
62441         var conditionalPrecedence = ts.getOperatorPrecedence(210, 57);
62442         var emittedCondition = ts.skipPartiallyEmittedExpressions(condition);
62443         var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition);
62444         if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1) {
62445             return ts.createParen(condition);
62446         }
62447         return condition;
62448     }
62449     ts.parenthesizeForConditionalHead = parenthesizeForConditionalHead;
62450     function parenthesizeSubexpressionOfConditionalExpression(e) {
62451         var emittedExpression = ts.skipPartiallyEmittedExpressions(e);
62452         return isCommaSequence(emittedExpression)
62453             ? ts.createParen(e)
62454             : e;
62455     }
62456     ts.parenthesizeSubexpressionOfConditionalExpression = parenthesizeSubexpressionOfConditionalExpression;
62457     function parenthesizeDefaultExpression(e) {
62458         var check = ts.skipPartiallyEmittedExpressions(e);
62459         var needsParens = isCommaSequence(check);
62460         if (!needsParens) {
62461             switch (getLeftmostExpression(check, false).kind) {
62462                 case 214:
62463                 case 201:
62464                     needsParens = true;
62465             }
62466         }
62467         return needsParens ? ts.createParen(e) : e;
62468     }
62469     ts.parenthesizeDefaultExpression = parenthesizeDefaultExpression;
62470     function parenthesizeForNew(expression) {
62471         var leftmostExpr = getLeftmostExpression(expression, true);
62472         switch (leftmostExpr.kind) {
62473             case 196:
62474                 return ts.createParen(expression);
62475             case 197:
62476                 return !leftmostExpr.arguments
62477                     ? ts.createParen(expression)
62478                     : expression;
62479         }
62480         return parenthesizeForAccess(expression);
62481     }
62482     ts.parenthesizeForNew = parenthesizeForNew;
62483     function parenthesizeForAccess(expression) {
62484         var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
62485         if (ts.isLeftHandSideExpression(emittedExpression)
62486             && (emittedExpression.kind !== 197 || emittedExpression.arguments)) {
62487             return expression;
62488         }
62489         return ts.setTextRange(ts.createParen(expression), expression);
62490     }
62491     ts.parenthesizeForAccess = parenthesizeForAccess;
62492     function parenthesizePostfixOperand(operand) {
62493         return ts.isLeftHandSideExpression(operand)
62494             ? operand
62495             : ts.setTextRange(ts.createParen(operand), operand);
62496     }
62497     ts.parenthesizePostfixOperand = parenthesizePostfixOperand;
62498     function parenthesizePrefixOperand(operand) {
62499         return ts.isUnaryExpression(operand)
62500             ? operand
62501             : ts.setTextRange(ts.createParen(operand), operand);
62502     }
62503     ts.parenthesizePrefixOperand = parenthesizePrefixOperand;
62504     function parenthesizeListElements(elements) {
62505         var result;
62506         for (var i = 0; i < elements.length; i++) {
62507             var element = parenthesizeExpressionForList(elements[i]);
62508             if (result !== undefined || element !== elements[i]) {
62509                 if (result === undefined) {
62510                     result = elements.slice(0, i);
62511                 }
62512                 result.push(element);
62513             }
62514         }
62515         if (result !== undefined) {
62516             return ts.setTextRange(ts.createNodeArray(result, elements.hasTrailingComma), elements);
62517         }
62518         return elements;
62519     }
62520     ts.parenthesizeListElements = parenthesizeListElements;
62521     function parenthesizeExpressionForList(expression) {
62522         var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
62523         var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression);
62524         var commaPrecedence = ts.getOperatorPrecedence(209, 27);
62525         return expressionPrecedence > commaPrecedence
62526             ? expression
62527             : ts.setTextRange(ts.createParen(expression), expression);
62528     }
62529     ts.parenthesizeExpressionForList = parenthesizeExpressionForList;
62530     function parenthesizeExpressionForExpressionStatement(expression) {
62531         var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
62532         if (ts.isCallExpression(emittedExpression)) {
62533             var callee = emittedExpression.expression;
62534             var kind = ts.skipPartiallyEmittedExpressions(callee).kind;
62535             if (kind === 201 || kind === 202) {
62536                 var mutableCall = ts.getMutableClone(emittedExpression);
62537                 mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee);
62538                 return recreateOuterExpressions(expression, mutableCall, 8);
62539             }
62540         }
62541         var leftmostExpressionKind = getLeftmostExpression(emittedExpression, false).kind;
62542         if (leftmostExpressionKind === 193 || leftmostExpressionKind === 201) {
62543             return ts.setTextRange(ts.createParen(expression), expression);
62544         }
62545         return expression;
62546     }
62547     ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement;
62548     function parenthesizeConditionalTypeMember(member) {
62549         return member.kind === 180 ? ts.createParenthesizedType(member) : member;
62550     }
62551     ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember;
62552     function parenthesizeElementTypeMember(member) {
62553         switch (member.kind) {
62554             case 178:
62555             case 179:
62556             case 170:
62557             case 171:
62558                 return ts.createParenthesizedType(member);
62559         }
62560         return parenthesizeConditionalTypeMember(member);
62561     }
62562     ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember;
62563     function parenthesizeArrayTypeMember(member) {
62564         switch (member.kind) {
62565             case 172:
62566             case 184:
62567             case 181:
62568                 return ts.createParenthesizedType(member);
62569         }
62570         return parenthesizeElementTypeMember(member);
62571     }
62572     ts.parenthesizeArrayTypeMember = parenthesizeArrayTypeMember;
62573     function parenthesizeElementTypeMembers(members) {
62574         return ts.createNodeArray(ts.sameMap(members, parenthesizeElementTypeMember));
62575     }
62576     ts.parenthesizeElementTypeMembers = parenthesizeElementTypeMembers;
62577     function parenthesizeTypeParameters(typeParameters) {
62578         if (ts.some(typeParameters)) {
62579             var params = [];
62580             for (var i = 0; i < typeParameters.length; ++i) {
62581                 var entry = typeParameters[i];
62582                 params.push(i === 0 && ts.isFunctionOrConstructorTypeNode(entry) && entry.typeParameters ?
62583                     ts.createParenthesizedType(entry) :
62584                     entry);
62585             }
62586             return ts.createNodeArray(params);
62587         }
62588     }
62589     ts.parenthesizeTypeParameters = parenthesizeTypeParameters;
62590     function getLeftmostExpression(node, stopAtCallExpressions) {
62591         while (true) {
62592             switch (node.kind) {
62593                 case 208:
62594                     node = node.operand;
62595                     continue;
62596                 case 209:
62597                     node = node.left;
62598                     continue;
62599                 case 210:
62600                     node = node.condition;
62601                     continue;
62602                 case 198:
62603                     node = node.tag;
62604                     continue;
62605                 case 196:
62606                     if (stopAtCallExpressions) {
62607                         return node;
62608                     }
62609                 case 217:
62610                 case 195:
62611                 case 194:
62612                 case 218:
62613                 case 326:
62614                     node = node.expression;
62615                     continue;
62616             }
62617             return node;
62618         }
62619     }
62620     ts.getLeftmostExpression = getLeftmostExpression;
62621     function parenthesizeConciseBody(body) {
62622         if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, false).kind === 193)) {
62623             return ts.setTextRange(ts.createParen(body), body);
62624         }
62625         return body;
62626     }
62627     ts.parenthesizeConciseBody = parenthesizeConciseBody;
62628     function isCommaSequence(node) {
62629         return node.kind === 209 && node.operatorToken.kind === 27 ||
62630             node.kind === 327;
62631     }
62632     ts.isCommaSequence = isCommaSequence;
62633     function isOuterExpression(node, kinds) {
62634         if (kinds === void 0) { kinds = 15; }
62635         switch (node.kind) {
62636             case 200:
62637                 return (kinds & 1) !== 0;
62638             case 199:
62639             case 217:
62640                 return (kinds & 2) !== 0;
62641             case 218:
62642                 return (kinds & 4) !== 0;
62643             case 326:
62644                 return (kinds & 8) !== 0;
62645         }
62646         return false;
62647     }
62648     ts.isOuterExpression = isOuterExpression;
62649     function skipOuterExpressions(node, kinds) {
62650         if (kinds === void 0) { kinds = 15; }
62651         while (isOuterExpression(node, kinds)) {
62652             node = node.expression;
62653         }
62654         return node;
62655     }
62656     ts.skipOuterExpressions = skipOuterExpressions;
62657     function skipAssertions(node) {
62658         return skipOuterExpressions(node, 6);
62659     }
62660     ts.skipAssertions = skipAssertions;
62661     function updateOuterExpression(outerExpression, expression) {
62662         switch (outerExpression.kind) {
62663             case 200: return ts.updateParen(outerExpression, expression);
62664             case 199: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression);
62665             case 217: return ts.updateAsExpression(outerExpression, expression, outerExpression.type);
62666             case 218: return ts.updateNonNullExpression(outerExpression, expression);
62667             case 326: return ts.updatePartiallyEmittedExpression(outerExpression, expression);
62668         }
62669     }
62670     function isIgnorableParen(node) {
62671         return node.kind === 200
62672             && ts.nodeIsSynthesized(node)
62673             && ts.nodeIsSynthesized(ts.getSourceMapRange(node))
62674             && ts.nodeIsSynthesized(ts.getCommentRange(node))
62675             && !ts.some(ts.getSyntheticLeadingComments(node))
62676             && !ts.some(ts.getSyntheticTrailingComments(node));
62677     }
62678     function recreateOuterExpressions(outerExpression, innerExpression, kinds) {
62679         if (kinds === void 0) { kinds = 15; }
62680         if (outerExpression && isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) {
62681             return updateOuterExpression(outerExpression, recreateOuterExpressions(outerExpression.expression, innerExpression));
62682         }
62683         return innerExpression;
62684     }
62685     ts.recreateOuterExpressions = recreateOuterExpressions;
62686     function startOnNewLine(node) {
62687         return ts.setStartsOnNewLine(node, true);
62688     }
62689     ts.startOnNewLine = startOnNewLine;
62690     function getExternalHelpersModuleName(node) {
62691         var parseNode = ts.getOriginalNode(node, ts.isSourceFile);
62692         var emitNode = parseNode && parseNode.emitNode;
62693         return emitNode && emitNode.externalHelpersModuleName;
62694     }
62695     ts.getExternalHelpersModuleName = getExternalHelpersModuleName;
62696     function hasRecordedExternalHelpers(sourceFile) {
62697         var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile);
62698         var emitNode = parseNode && parseNode.emitNode;
62699         return !!emitNode && (!!emitNode.externalHelpersModuleName || !!emitNode.externalHelpers);
62700     }
62701     ts.hasRecordedExternalHelpers = hasRecordedExternalHelpers;
62702     function createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault) {
62703         if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
62704             var namedBindings = void 0;
62705             var moduleKind = ts.getEmitModuleKind(compilerOptions);
62706             if (moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) {
62707                 var helpers = ts.getEmitHelpers(sourceFile);
62708                 if (helpers) {
62709                     var helperNames = [];
62710                     for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) {
62711                         var helper = helpers_2[_i];
62712                         if (!helper.scoped) {
62713                             var importName = helper.importName;
62714                             if (importName) {
62715                                 ts.pushIfUnique(helperNames, importName);
62716                             }
62717                         }
62718                     }
62719                     if (ts.some(helperNames)) {
62720                         helperNames.sort(ts.compareStringsCaseSensitive);
62721                         namedBindings = ts.createNamedImports(ts.map(helperNames, function (name) { return ts.isFileLevelUniqueName(sourceFile, name)
62722                             ? ts.createImportSpecifier(undefined, ts.createIdentifier(name))
62723                             : ts.createImportSpecifier(ts.createIdentifier(name), getUnscopedHelperName(name)); }));
62724                         var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile);
62725                         var emitNode = ts.getOrCreateEmitNode(parseNode);
62726                         emitNode.externalHelpers = true;
62727                     }
62728                 }
62729             }
62730             else {
62731                 var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar || hasImportDefault);
62732                 if (externalHelpersModuleName) {
62733                     namedBindings = ts.createNamespaceImport(externalHelpersModuleName);
62734                 }
62735             }
62736             if (namedBindings) {
62737                 var externalHelpersImportDeclaration = ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, namedBindings), ts.createLiteral(ts.externalHelpersModuleNameText));
62738                 ts.addEmitFlags(externalHelpersImportDeclaration, 67108864);
62739                 return externalHelpersImportDeclaration;
62740             }
62741         }
62742     }
62743     ts.createExternalHelpersImportDeclarationIfNeeded = createExternalHelpersImportDeclarationIfNeeded;
62744     function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault) {
62745         if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(node, compilerOptions)) {
62746             var externalHelpersModuleName = getExternalHelpersModuleName(node);
62747             if (externalHelpersModuleName) {
62748                 return externalHelpersModuleName;
62749             }
62750             var moduleKind = ts.getEmitModuleKind(compilerOptions);
62751             var create = (hasExportStarsToExportValues || (compilerOptions.esModuleInterop && hasImportStarOrImportDefault))
62752                 && moduleKind !== ts.ModuleKind.System
62753                 && moduleKind < ts.ModuleKind.ES2015;
62754             if (!create) {
62755                 var helpers = ts.getEmitHelpers(node);
62756                 if (helpers) {
62757                     for (var _i = 0, helpers_3 = helpers; _i < helpers_3.length; _i++) {
62758                         var helper = helpers_3[_i];
62759                         if (!helper.scoped) {
62760                             create = true;
62761                             break;
62762                         }
62763                     }
62764                 }
62765             }
62766             if (create) {
62767                 var parseNode = ts.getOriginalNode(node, ts.isSourceFile);
62768                 var emitNode = ts.getOrCreateEmitNode(parseNode);
62769                 return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = ts.createUniqueName(ts.externalHelpersModuleNameText));
62770             }
62771         }
62772     }
62773     ts.getOrCreateExternalHelpersModuleNameIfNeeded = getOrCreateExternalHelpersModuleNameIfNeeded;
62774     function getLocalNameForExternalImport(node, sourceFile) {
62775         var namespaceDeclaration = ts.getNamespaceDeclarationNode(node);
62776         if (namespaceDeclaration && !ts.isDefaultImport(node)) {
62777             var name = namespaceDeclaration.name;
62778             return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name));
62779         }
62780         if (node.kind === 254 && node.importClause) {
62781             return ts.getGeneratedNameForNode(node);
62782         }
62783         if (node.kind === 260 && node.moduleSpecifier) {
62784             return ts.getGeneratedNameForNode(node);
62785         }
62786         return undefined;
62787     }
62788     ts.getLocalNameForExternalImport = getLocalNameForExternalImport;
62789     function getExternalModuleNameLiteral(importNode, sourceFile, host, resolver, compilerOptions) {
62790         var moduleName = ts.getExternalModuleName(importNode);
62791         if (moduleName.kind === 10) {
62792             return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions)
62793                 || tryRenameExternalModule(moduleName, sourceFile)
62794                 || ts.getSynthesizedClone(moduleName);
62795         }
62796         return undefined;
62797     }
62798     ts.getExternalModuleNameLiteral = getExternalModuleNameLiteral;
62799     function tryRenameExternalModule(moduleName, sourceFile) {
62800         var rename = sourceFile.renamedDependencies && sourceFile.renamedDependencies.get(moduleName.text);
62801         return rename && ts.createLiteral(rename);
62802     }
62803     function tryGetModuleNameFromFile(file, host, options) {
62804         if (!file) {
62805             return undefined;
62806         }
62807         if (file.moduleName) {
62808             return ts.createLiteral(file.moduleName);
62809         }
62810         if (!file.isDeclarationFile && (options.out || options.outFile)) {
62811             return ts.createLiteral(ts.getExternalModuleNameFromPath(host, file.fileName));
62812         }
62813         return undefined;
62814     }
62815     ts.tryGetModuleNameFromFile = tryGetModuleNameFromFile;
62816     function tryGetModuleNameFromDeclaration(declaration, host, resolver, compilerOptions) {
62817         return tryGetModuleNameFromFile(resolver.getExternalModuleFileFromDeclaration(declaration), host, compilerOptions);
62818     }
62819     function getInitializerOfBindingOrAssignmentElement(bindingElement) {
62820         if (ts.isDeclarationBindingElement(bindingElement)) {
62821             return bindingElement.initializer;
62822         }
62823         if (ts.isPropertyAssignment(bindingElement)) {
62824             var initializer = bindingElement.initializer;
62825             return ts.isAssignmentExpression(initializer, true)
62826                 ? initializer.right
62827                 : undefined;
62828         }
62829         if (ts.isShorthandPropertyAssignment(bindingElement)) {
62830             return bindingElement.objectAssignmentInitializer;
62831         }
62832         if (ts.isAssignmentExpression(bindingElement, true)) {
62833             return bindingElement.right;
62834         }
62835         if (ts.isSpreadElement(bindingElement)) {
62836             return getInitializerOfBindingOrAssignmentElement(bindingElement.expression);
62837         }
62838     }
62839     ts.getInitializerOfBindingOrAssignmentElement = getInitializerOfBindingOrAssignmentElement;
62840     function getTargetOfBindingOrAssignmentElement(bindingElement) {
62841         if (ts.isDeclarationBindingElement(bindingElement)) {
62842             return bindingElement.name;
62843         }
62844         if (ts.isObjectLiteralElementLike(bindingElement)) {
62845             switch (bindingElement.kind) {
62846                 case 281:
62847                     return getTargetOfBindingOrAssignmentElement(bindingElement.initializer);
62848                 case 282:
62849                     return bindingElement.name;
62850                 case 283:
62851                     return getTargetOfBindingOrAssignmentElement(bindingElement.expression);
62852             }
62853             return undefined;
62854         }
62855         if (ts.isAssignmentExpression(bindingElement, true)) {
62856             return getTargetOfBindingOrAssignmentElement(bindingElement.left);
62857         }
62858         if (ts.isSpreadElement(bindingElement)) {
62859             return getTargetOfBindingOrAssignmentElement(bindingElement.expression);
62860         }
62861         return bindingElement;
62862     }
62863     ts.getTargetOfBindingOrAssignmentElement = getTargetOfBindingOrAssignmentElement;
62864     function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) {
62865         switch (bindingElement.kind) {
62866             case 156:
62867             case 191:
62868                 return bindingElement.dotDotDotToken;
62869             case 213:
62870             case 283:
62871                 return bindingElement;
62872         }
62873         return undefined;
62874     }
62875     ts.getRestIndicatorOfBindingOrAssignmentElement = getRestIndicatorOfBindingOrAssignmentElement;
62876     function getPropertyNameOfBindingOrAssignmentElement(bindingElement) {
62877         var propertyName = tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement);
62878         ts.Debug.assert(!!propertyName || ts.isSpreadAssignment(bindingElement), "Invalid property name for binding element.");
62879         return propertyName;
62880     }
62881     ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement;
62882     function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) {
62883         switch (bindingElement.kind) {
62884             case 191:
62885                 if (bindingElement.propertyName) {
62886                     var propertyName = bindingElement.propertyName;
62887                     if (ts.isPrivateIdentifier(propertyName)) {
62888                         return ts.Debug.failBadSyntaxKind(propertyName);
62889                     }
62890                     return ts.isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression)
62891                         ? propertyName.expression
62892                         : propertyName;
62893                 }
62894                 break;
62895             case 281:
62896                 if (bindingElement.name) {
62897                     var propertyName = bindingElement.name;
62898                     if (ts.isPrivateIdentifier(propertyName)) {
62899                         return ts.Debug.failBadSyntaxKind(propertyName);
62900                     }
62901                     return ts.isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression)
62902                         ? propertyName.expression
62903                         : propertyName;
62904                 }
62905                 break;
62906             case 283:
62907                 if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) {
62908                     return ts.Debug.failBadSyntaxKind(bindingElement.name);
62909                 }
62910                 return bindingElement.name;
62911         }
62912         var target = getTargetOfBindingOrAssignmentElement(bindingElement);
62913         if (target && ts.isPropertyName(target)) {
62914             return target;
62915         }
62916     }
62917     ts.tryGetPropertyNameOfBindingOrAssignmentElement = tryGetPropertyNameOfBindingOrAssignmentElement;
62918     function isStringOrNumericLiteral(node) {
62919         var kind = node.kind;
62920         return kind === 10
62921             || kind === 8;
62922     }
62923     function getElementsOfBindingOrAssignmentPattern(name) {
62924         switch (name.kind) {
62925             case 189:
62926             case 190:
62927             case 192:
62928                 return name.elements;
62929             case 193:
62930                 return name.properties;
62931         }
62932     }
62933     ts.getElementsOfBindingOrAssignmentPattern = getElementsOfBindingOrAssignmentPattern;
62934     function convertToArrayAssignmentElement(element) {
62935         if (ts.isBindingElement(element)) {
62936             if (element.dotDotDotToken) {
62937                 ts.Debug.assertNode(element.name, ts.isIdentifier);
62938                 return ts.setOriginalNode(ts.setTextRange(ts.createSpread(element.name), element), element);
62939             }
62940             var expression = convertToAssignmentElementTarget(element.name);
62941             return element.initializer
62942                 ? ts.setOriginalNode(ts.setTextRange(ts.createAssignment(expression, element.initializer), element), element)
62943                 : expression;
62944         }
62945         ts.Debug.assertNode(element, ts.isExpression);
62946         return element;
62947     }
62948     ts.convertToArrayAssignmentElement = convertToArrayAssignmentElement;
62949     function convertToObjectAssignmentElement(element) {
62950         if (ts.isBindingElement(element)) {
62951             if (element.dotDotDotToken) {
62952                 ts.Debug.assertNode(element.name, ts.isIdentifier);
62953                 return ts.setOriginalNode(ts.setTextRange(ts.createSpreadAssignment(element.name), element), element);
62954             }
62955             if (element.propertyName) {
62956                 var expression = convertToAssignmentElementTarget(element.name);
62957                 return ts.setOriginalNode(ts.setTextRange(ts.createPropertyAssignment(element.propertyName, element.initializer ? ts.createAssignment(expression, element.initializer) : expression), element), element);
62958             }
62959             ts.Debug.assertNode(element.name, ts.isIdentifier);
62960             return ts.setOriginalNode(ts.setTextRange(ts.createShorthandPropertyAssignment(element.name, element.initializer), element), element);
62961         }
62962         ts.Debug.assertNode(element, ts.isObjectLiteralElementLike);
62963         return element;
62964     }
62965     ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement;
62966     function convertToAssignmentPattern(node) {
62967         switch (node.kind) {
62968             case 190:
62969             case 192:
62970                 return convertToArrayAssignmentPattern(node);
62971             case 189:
62972             case 193:
62973                 return convertToObjectAssignmentPattern(node);
62974         }
62975     }
62976     ts.convertToAssignmentPattern = convertToAssignmentPattern;
62977     function convertToObjectAssignmentPattern(node) {
62978         if (ts.isObjectBindingPattern(node)) {
62979             return ts.setOriginalNode(ts.setTextRange(ts.createObjectLiteral(ts.map(node.elements, convertToObjectAssignmentElement)), node), node);
62980         }
62981         ts.Debug.assertNode(node, ts.isObjectLiteralExpression);
62982         return node;
62983     }
62984     ts.convertToObjectAssignmentPattern = convertToObjectAssignmentPattern;
62985     function convertToArrayAssignmentPattern(node) {
62986         if (ts.isArrayBindingPattern(node)) {
62987             return ts.setOriginalNode(ts.setTextRange(ts.createArrayLiteral(ts.map(node.elements, convertToArrayAssignmentElement)), node), node);
62988         }
62989         ts.Debug.assertNode(node, ts.isArrayLiteralExpression);
62990         return node;
62991     }
62992     ts.convertToArrayAssignmentPattern = convertToArrayAssignmentPattern;
62993     function convertToAssignmentElementTarget(node) {
62994         if (ts.isBindingPattern(node)) {
62995             return convertToAssignmentPattern(node);
62996         }
62997         ts.Debug.assertNode(node, ts.isExpression);
62998         return node;
62999     }
63000     ts.convertToAssignmentElementTarget = convertToAssignmentElementTarget;
63001 })(ts || (ts = {}));
63002 var ts;
63003 (function (ts) {
63004     var isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration);
63005     function visitNode(node, visitor, test, lift) {
63006         if (node === undefined || visitor === undefined) {
63007             return node;
63008         }
63009         ts.aggregateTransformFlags(node);
63010         var visited = visitor(node);
63011         if (visited === node) {
63012             return node;
63013         }
63014         var visitedNode;
63015         if (visited === undefined) {
63016             return undefined;
63017         }
63018         else if (ts.isArray(visited)) {
63019             visitedNode = (lift || extractSingleNode)(visited);
63020         }
63021         else {
63022             visitedNode = visited;
63023         }
63024         ts.Debug.assertNode(visitedNode, test);
63025         ts.aggregateTransformFlags(visitedNode);
63026         return visitedNode;
63027     }
63028     ts.visitNode = visitNode;
63029     function visitNodes(nodes, visitor, test, start, count) {
63030         if (nodes === undefined || visitor === undefined) {
63031             return nodes;
63032         }
63033         var updated;
63034         var length = nodes.length;
63035         if (start === undefined || start < 0) {
63036             start = 0;
63037         }
63038         if (count === undefined || count > length - start) {
63039             count = length - start;
63040         }
63041         if (start > 0 || count < length) {
63042             updated = ts.createNodeArray([], nodes.hasTrailingComma && start + count === length);
63043         }
63044         for (var i = 0; i < count; i++) {
63045             var node = nodes[i + start];
63046             ts.aggregateTransformFlags(node);
63047             var visited = node !== undefined ? visitor(node) : undefined;
63048             if (updated !== undefined || visited === undefined || visited !== node) {
63049                 if (updated === undefined) {
63050                     updated = ts.createNodeArray(nodes.slice(0, i), nodes.hasTrailingComma);
63051                     ts.setTextRange(updated, nodes);
63052                 }
63053                 if (visited) {
63054                     if (ts.isArray(visited)) {
63055                         for (var _i = 0, visited_1 = visited; _i < visited_1.length; _i++) {
63056                             var visitedNode = visited_1[_i];
63057                             ts.Debug.assertNode(visitedNode, test);
63058                             ts.aggregateTransformFlags(visitedNode);
63059                             updated.push(visitedNode);
63060                         }
63061                     }
63062                     else {
63063                         ts.Debug.assertNode(visited, test);
63064                         ts.aggregateTransformFlags(visited);
63065                         updated.push(visited);
63066                     }
63067                 }
63068             }
63069         }
63070         return updated || nodes;
63071     }
63072     ts.visitNodes = visitNodes;
63073     function visitLexicalEnvironment(statements, visitor, context, start, ensureUseStrict) {
63074         context.startLexicalEnvironment();
63075         statements = visitNodes(statements, visitor, ts.isStatement, start);
63076         if (ensureUseStrict)
63077             statements = ts.ensureUseStrict(statements);
63078         return ts.mergeLexicalEnvironment(statements, context.endLexicalEnvironment());
63079     }
63080     ts.visitLexicalEnvironment = visitLexicalEnvironment;
63081     function visitParameterList(nodes, visitor, context, nodesVisitor) {
63082         if (nodesVisitor === void 0) { nodesVisitor = visitNodes; }
63083         var updated;
63084         context.startLexicalEnvironment();
63085         if (nodes) {
63086             context.setLexicalEnvironmentFlags(1, true);
63087             updated = nodesVisitor(nodes, visitor, ts.isParameterDeclaration);
63088             if (context.getLexicalEnvironmentFlags() & 2 &&
63089                 ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2) {
63090                 updated = addDefaultValueAssignmentsIfNeeded(updated, context);
63091             }
63092             context.setLexicalEnvironmentFlags(1, false);
63093         }
63094         context.suspendLexicalEnvironment();
63095         return updated;
63096     }
63097     ts.visitParameterList = visitParameterList;
63098     function addDefaultValueAssignmentsIfNeeded(parameters, context) {
63099         var result;
63100         for (var i = 0; i < parameters.length; i++) {
63101             var parameter = parameters[i];
63102             var updated = addDefaultValueAssignmentIfNeeded(parameter, context);
63103             if (result || updated !== parameter) {
63104                 if (!result)
63105                     result = parameters.slice(0, i);
63106                 result[i] = updated;
63107             }
63108         }
63109         if (result) {
63110             return ts.setTextRange(ts.createNodeArray(result, parameters.hasTrailingComma), parameters);
63111         }
63112         return parameters;
63113     }
63114     function addDefaultValueAssignmentIfNeeded(parameter, context) {
63115         return parameter.dotDotDotToken ? parameter :
63116             ts.isBindingPattern(parameter.name) ? addDefaultValueAssignmentForBindingPattern(parameter, context) :
63117                 parameter.initializer ? addDefaultValueAssignmentForInitializer(parameter, parameter.name, parameter.initializer, context) :
63118                     parameter;
63119     }
63120     function addDefaultValueAssignmentForBindingPattern(parameter, context) {
63121         context.addInitializationStatement(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
63122             ts.createVariableDeclaration(parameter.name, parameter.type, parameter.initializer ?
63123                 ts.createConditional(ts.createStrictEquality(ts.getGeneratedNameForNode(parameter), ts.createVoidZero()), parameter.initializer, ts.getGeneratedNameForNode(parameter)) :
63124                 ts.getGeneratedNameForNode(parameter)),
63125         ])));
63126         return ts.updateParameter(parameter, parameter.decorators, parameter.modifiers, parameter.dotDotDotToken, ts.getGeneratedNameForNode(parameter), parameter.questionToken, parameter.type, undefined);
63127     }
63128     function addDefaultValueAssignmentForInitializer(parameter, name, initializer, context) {
63129         context.addInitializationStatement(ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.setTextRange(ts.createBlock([
63130             ts.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer) | 1536)), parameter), 1536))
63131         ]), parameter), 1 | 32 | 384 | 1536)));
63132         return ts.updateParameter(parameter, parameter.decorators, parameter.modifiers, parameter.dotDotDotToken, parameter.name, parameter.questionToken, parameter.type, undefined);
63133     }
63134     function visitFunctionBody(node, visitor, context) {
63135         context.resumeLexicalEnvironment();
63136         var updated = visitNode(node, visitor, ts.isConciseBody);
63137         var declarations = context.endLexicalEnvironment();
63138         if (ts.some(declarations)) {
63139             var block = ts.convertToFunctionBody(updated);
63140             var statements = ts.mergeLexicalEnvironment(block.statements, declarations);
63141             return ts.updateBlock(block, statements);
63142         }
63143         return updated;
63144     }
63145     ts.visitFunctionBody = visitFunctionBody;
63146     function visitEachChild(node, visitor, context, nodesVisitor, tokenVisitor) {
63147         if (nodesVisitor === void 0) { nodesVisitor = visitNodes; }
63148         if (node === undefined) {
63149             return undefined;
63150         }
63151         var kind = node.kind;
63152         if ((kind > 0 && kind <= 152) || kind === 183) {
63153             return node;
63154         }
63155         switch (kind) {
63156             case 75:
63157                 return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration));
63158             case 153:
63159                 return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier));
63160             case 154:
63161                 return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression));
63162             case 155:
63163                 return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode));
63164             case 156:
63165                 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));
63166             case 157:
63167                 return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression));
63168             case 158:
63169                 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));
63170             case 159:
63171                 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));
63172             case 160:
63173                 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));
63174             case 161:
63175                 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));
63176             case 162:
63177                 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));
63178             case 163:
63179                 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));
63180             case 164:
63181                 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));
63182             case 165:
63183                 return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode));
63184             case 166:
63185                 return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode));
63186             case 167:
63187                 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));
63188             case 168:
63189                 return ts.updateTypePredicateNodeWithModifier(node, visitNode(node.assertsModifier, visitor), visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode));
63190             case 169:
63191                 return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode));
63192             case 170:
63193                 return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode));
63194             case 171:
63195                 return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode));
63196             case 172:
63197                 return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName));
63198             case 173:
63199                 return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement));
63200             case 174:
63201                 return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode));
63202             case 175:
63203                 return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode));
63204             case 176:
63205                 return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode));
63206             case 177:
63207                 return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode));
63208             case 178:
63209                 return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode));
63210             case 179:
63211                 return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode));
63212             case 180:
63213                 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));
63214             case 181:
63215                 return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration));
63216             case 188:
63217                 return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf);
63218             case 182:
63219                 return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode));
63220             case 184:
63221                 return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode));
63222             case 185:
63223                 return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode));
63224             case 186:
63225                 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));
63226             case 187:
63227                 return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression));
63228             case 189:
63229                 return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement));
63230             case 190:
63231                 return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement));
63232             case 191:
63233                 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));
63234             case 192:
63235                 return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression));
63236             case 193:
63237                 return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike));
63238             case 194:
63239                 if (node.flags & 32) {
63240                     return ts.updatePropertyAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier));
63241                 }
63242                 return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifierOrPrivateIdentifier));
63243             case 195:
63244                 if (node.flags & 32) {
63245                     return ts.updateElementAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, tokenVisitor, ts.isToken), visitNode(node.argumentExpression, visitor, ts.isExpression));
63246                 }
63247                 return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression));
63248             case 196:
63249                 if (node.flags & 32) {
63250                     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));
63251                 }
63252                 return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
63253             case 197:
63254                 return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
63255             case 198:
63256                 return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral));
63257             case 199:
63258                 return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression));
63259             case 200:
63260                 return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression));
63261             case 201:
63262                 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));
63263             case 202:
63264                 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));
63265             case 203:
63266                 return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression));
63267             case 204:
63268                 return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression));
63269             case 205:
63270                 return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression));
63271             case 206:
63272                 return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression));
63273             case 207:
63274                 return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression));
63275             case 208:
63276                 return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression));
63277             case 209:
63278                 return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, tokenVisitor, ts.isToken));
63279             case 210:
63280                 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));
63281             case 211:
63282                 return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan));
63283             case 212:
63284                 return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression));
63285             case 213:
63286                 return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression));
63287             case 214:
63288                 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));
63289             case 216:
63290                 return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression));
63291             case 217:
63292                 return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode));
63293             case 218:
63294                 return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression));
63295             case 219:
63296                 return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier));
63297             case 221:
63298                 return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail));
63299             case 223:
63300                 return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement));
63301             case 225:
63302                 return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList));
63303             case 226:
63304                 return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression));
63305             case 227:
63306                 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));
63307             case 228:
63308                 return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression));
63309             case 229:
63310                 return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
63311             case 230:
63312                 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));
63313             case 231:
63314                 return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
63315             case 232:
63316                 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));
63317             case 233:
63318                 return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier));
63319             case 234:
63320                 return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier));
63321             case 235:
63322                 return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression));
63323             case 236:
63324                 return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
63325             case 237:
63326                 return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock));
63327             case 238:
63328                 return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
63329             case 239:
63330                 return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression));
63331             case 240:
63332                 return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock));
63333             case 242:
63334                 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));
63335             case 243:
63336                 return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration));
63337             case 244:
63338                 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));
63339             case 245:
63340                 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));
63341             case 246:
63342                 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));
63343             case 247:
63344                 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));
63345             case 248:
63346                 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));
63347             case 249:
63348                 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));
63349             case 250:
63350                 return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement));
63351             case 251:
63352                 return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause));
63353             case 252:
63354                 return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier));
63355             case 253:
63356                 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));
63357             case 254:
63358                 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));
63359             case 255:
63360                 return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings), node.isTypeOnly);
63361             case 256:
63362                 return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier));
63363             case 262:
63364                 return ts.updateNamespaceExport(node, visitNode(node.name, visitor, ts.isIdentifier));
63365             case 257:
63366                 return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier));
63367             case 258:
63368                 return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier));
63369             case 259:
63370                 return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression));
63371             case 260:
63372                 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);
63373             case 261:
63374                 return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier));
63375             case 263:
63376                 return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier));
63377             case 265:
63378                 return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression));
63379             case 266:
63380                 return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement));
63381             case 267:
63382                 return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes));
63383             case 268:
63384                 return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes));
63385             case 269:
63386                 return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression));
63387             case 270:
63388                 return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment));
63389             case 273:
63390                 return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression));
63391             case 274:
63392                 return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike));
63393             case 275:
63394                 return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression));
63395             case 276:
63396                 return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression));
63397             case 277:
63398                 return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement));
63399             case 278:
63400                 return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement));
63401             case 279:
63402                 return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments));
63403             case 280:
63404                 return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock));
63405             case 281:
63406                 return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression));
63407             case 282:
63408                 return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression));
63409             case 283:
63410                 return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression));
63411             case 284:
63412                 return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression));
63413             case 290:
63414                 return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context));
63415             case 326:
63416                 return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression));
63417             case 327:
63418                 return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression));
63419             default:
63420                 return node;
63421         }
63422     }
63423     ts.visitEachChild = visitEachChild;
63424     function extractSingleNode(nodes) {
63425         ts.Debug.assert(nodes.length <= 1, "Too many nodes written to output.");
63426         return ts.singleOrUndefined(nodes);
63427     }
63428 })(ts || (ts = {}));
63429 var ts;
63430 (function (ts) {
63431     function reduceNode(node, f, initial) {
63432         return node ? f(initial, node) : initial;
63433     }
63434     function reduceNodeArray(nodes, f, initial) {
63435         return nodes ? f(initial, nodes) : initial;
63436     }
63437     function reduceEachChild(node, initial, cbNode, cbNodeArray) {
63438         if (node === undefined) {
63439             return initial;
63440         }
63441         var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft;
63442         var cbNodes = cbNodeArray || cbNode;
63443         var kind = node.kind;
63444         if ((kind > 0 && kind <= 152)) {
63445             return initial;
63446         }
63447         if ((kind >= 168 && kind <= 187)) {
63448             return initial;
63449         }
63450         var result = initial;
63451         switch (node.kind) {
63452             case 222:
63453             case 224:
63454             case 215:
63455             case 241:
63456             case 325:
63457                 break;
63458             case 153:
63459                 result = reduceNode(node.left, cbNode, result);
63460                 result = reduceNode(node.right, cbNode, result);
63461                 break;
63462             case 154:
63463                 result = reduceNode(node.expression, cbNode, result);
63464                 break;
63465             case 156:
63466                 result = reduceNodes(node.decorators, cbNodes, result);
63467                 result = reduceNodes(node.modifiers, cbNodes, result);
63468                 result = reduceNode(node.name, cbNode, result);
63469                 result = reduceNode(node.type, cbNode, result);
63470                 result = reduceNode(node.initializer, cbNode, result);
63471                 break;
63472             case 157:
63473                 result = reduceNode(node.expression, cbNode, result);
63474                 break;
63475             case 158:
63476                 result = reduceNodes(node.modifiers, cbNodes, result);
63477                 result = reduceNode(node.name, cbNode, result);
63478                 result = reduceNode(node.questionToken, cbNode, result);
63479                 result = reduceNode(node.type, cbNode, result);
63480                 result = reduceNode(node.initializer, cbNode, result);
63481                 break;
63482             case 159:
63483                 result = reduceNodes(node.decorators, cbNodes, result);
63484                 result = reduceNodes(node.modifiers, cbNodes, result);
63485                 result = reduceNode(node.name, cbNode, result);
63486                 result = reduceNode(node.type, cbNode, result);
63487                 result = reduceNode(node.initializer, cbNode, result);
63488                 break;
63489             case 161:
63490                 result = reduceNodes(node.decorators, cbNodes, result);
63491                 result = reduceNodes(node.modifiers, cbNodes, result);
63492                 result = reduceNode(node.name, cbNode, result);
63493                 result = reduceNodes(node.typeParameters, cbNodes, result);
63494                 result = reduceNodes(node.parameters, cbNodes, result);
63495                 result = reduceNode(node.type, cbNode, result);
63496                 result = reduceNode(node.body, cbNode, result);
63497                 break;
63498             case 162:
63499                 result = reduceNodes(node.modifiers, cbNodes, result);
63500                 result = reduceNodes(node.parameters, cbNodes, result);
63501                 result = reduceNode(node.body, cbNode, result);
63502                 break;
63503             case 163:
63504                 result = reduceNodes(node.decorators, cbNodes, result);
63505                 result = reduceNodes(node.modifiers, cbNodes, result);
63506                 result = reduceNode(node.name, cbNode, result);
63507                 result = reduceNodes(node.parameters, cbNodes, result);
63508                 result = reduceNode(node.type, cbNode, result);
63509                 result = reduceNode(node.body, cbNode, result);
63510                 break;
63511             case 164:
63512                 result = reduceNodes(node.decorators, cbNodes, result);
63513                 result = reduceNodes(node.modifiers, cbNodes, result);
63514                 result = reduceNode(node.name, cbNode, result);
63515                 result = reduceNodes(node.parameters, cbNodes, result);
63516                 result = reduceNode(node.body, cbNode, result);
63517                 break;
63518             case 189:
63519             case 190:
63520                 result = reduceNodes(node.elements, cbNodes, result);
63521                 break;
63522             case 191:
63523                 result = reduceNode(node.propertyName, cbNode, result);
63524                 result = reduceNode(node.name, cbNode, result);
63525                 result = reduceNode(node.initializer, cbNode, result);
63526                 break;
63527             case 192:
63528                 result = reduceNodes(node.elements, cbNodes, result);
63529                 break;
63530             case 193:
63531                 result = reduceNodes(node.properties, cbNodes, result);
63532                 break;
63533             case 194:
63534                 result = reduceNode(node.expression, cbNode, result);
63535                 result = reduceNode(node.name, cbNode, result);
63536                 break;
63537             case 195:
63538                 result = reduceNode(node.expression, cbNode, result);
63539                 result = reduceNode(node.argumentExpression, cbNode, result);
63540                 break;
63541             case 196:
63542                 result = reduceNode(node.expression, cbNode, result);
63543                 result = reduceNodes(node.typeArguments, cbNodes, result);
63544                 result = reduceNodes(node.arguments, cbNodes, result);
63545                 break;
63546             case 197:
63547                 result = reduceNode(node.expression, cbNode, result);
63548                 result = reduceNodes(node.typeArguments, cbNodes, result);
63549                 result = reduceNodes(node.arguments, cbNodes, result);
63550                 break;
63551             case 198:
63552                 result = reduceNode(node.tag, cbNode, result);
63553                 result = reduceNodes(node.typeArguments, cbNodes, result);
63554                 result = reduceNode(node.template, cbNode, result);
63555                 break;
63556             case 199:
63557                 result = reduceNode(node.type, cbNode, result);
63558                 result = reduceNode(node.expression, cbNode, result);
63559                 break;
63560             case 201:
63561                 result = reduceNodes(node.modifiers, cbNodes, result);
63562                 result = reduceNode(node.name, cbNode, result);
63563                 result = reduceNodes(node.typeParameters, cbNodes, result);
63564                 result = reduceNodes(node.parameters, cbNodes, result);
63565                 result = reduceNode(node.type, cbNode, result);
63566                 result = reduceNode(node.body, cbNode, result);
63567                 break;
63568             case 202:
63569                 result = reduceNodes(node.modifiers, cbNodes, result);
63570                 result = reduceNodes(node.typeParameters, cbNodes, result);
63571                 result = reduceNodes(node.parameters, cbNodes, result);
63572                 result = reduceNode(node.type, cbNode, result);
63573                 result = reduceNode(node.body, cbNode, result);
63574                 break;
63575             case 200:
63576             case 203:
63577             case 204:
63578             case 205:
63579             case 206:
63580             case 212:
63581             case 213:
63582             case 218:
63583                 result = reduceNode(node.expression, cbNode, result);
63584                 break;
63585             case 207:
63586             case 208:
63587                 result = reduceNode(node.operand, cbNode, result);
63588                 break;
63589             case 209:
63590                 result = reduceNode(node.left, cbNode, result);
63591                 result = reduceNode(node.right, cbNode, result);
63592                 break;
63593             case 210:
63594                 result = reduceNode(node.condition, cbNode, result);
63595                 result = reduceNode(node.whenTrue, cbNode, result);
63596                 result = reduceNode(node.whenFalse, cbNode, result);
63597                 break;
63598             case 211:
63599                 result = reduceNode(node.head, cbNode, result);
63600                 result = reduceNodes(node.templateSpans, cbNodes, result);
63601                 break;
63602             case 214:
63603                 result = reduceNodes(node.modifiers, cbNodes, result);
63604                 result = reduceNode(node.name, cbNode, result);
63605                 result = reduceNodes(node.typeParameters, cbNodes, result);
63606                 result = reduceNodes(node.heritageClauses, cbNodes, result);
63607                 result = reduceNodes(node.members, cbNodes, result);
63608                 break;
63609             case 216:
63610                 result = reduceNode(node.expression, cbNode, result);
63611                 result = reduceNodes(node.typeArguments, cbNodes, result);
63612                 break;
63613             case 217:
63614                 result = reduceNode(node.expression, cbNode, result);
63615                 result = reduceNode(node.type, cbNode, result);
63616                 break;
63617             case 221:
63618                 result = reduceNode(node.expression, cbNode, result);
63619                 result = reduceNode(node.literal, cbNode, result);
63620                 break;
63621             case 223:
63622                 result = reduceNodes(node.statements, cbNodes, result);
63623                 break;
63624             case 225:
63625                 result = reduceNodes(node.modifiers, cbNodes, result);
63626                 result = reduceNode(node.declarationList, cbNode, result);
63627                 break;
63628             case 226:
63629                 result = reduceNode(node.expression, cbNode, result);
63630                 break;
63631             case 227:
63632                 result = reduceNode(node.expression, cbNode, result);
63633                 result = reduceNode(node.thenStatement, cbNode, result);
63634                 result = reduceNode(node.elseStatement, cbNode, result);
63635                 break;
63636             case 228:
63637                 result = reduceNode(node.statement, cbNode, result);
63638                 result = reduceNode(node.expression, cbNode, result);
63639                 break;
63640             case 229:
63641             case 236:
63642                 result = reduceNode(node.expression, cbNode, result);
63643                 result = reduceNode(node.statement, cbNode, result);
63644                 break;
63645             case 230:
63646                 result = reduceNode(node.initializer, cbNode, result);
63647                 result = reduceNode(node.condition, cbNode, result);
63648                 result = reduceNode(node.incrementor, cbNode, result);
63649                 result = reduceNode(node.statement, cbNode, result);
63650                 break;
63651             case 231:
63652             case 232:
63653                 result = reduceNode(node.initializer, cbNode, result);
63654                 result = reduceNode(node.expression, cbNode, result);
63655                 result = reduceNode(node.statement, cbNode, result);
63656                 break;
63657             case 235:
63658             case 239:
63659                 result = reduceNode(node.expression, cbNode, result);
63660                 break;
63661             case 237:
63662                 result = reduceNode(node.expression, cbNode, result);
63663                 result = reduceNode(node.caseBlock, cbNode, result);
63664                 break;
63665             case 238:
63666                 result = reduceNode(node.label, cbNode, result);
63667                 result = reduceNode(node.statement, cbNode, result);
63668                 break;
63669             case 240:
63670                 result = reduceNode(node.tryBlock, cbNode, result);
63671                 result = reduceNode(node.catchClause, cbNode, result);
63672                 result = reduceNode(node.finallyBlock, cbNode, result);
63673                 break;
63674             case 242:
63675                 result = reduceNode(node.name, cbNode, result);
63676                 result = reduceNode(node.type, cbNode, result);
63677                 result = reduceNode(node.initializer, cbNode, result);
63678                 break;
63679             case 243:
63680                 result = reduceNodes(node.declarations, cbNodes, result);
63681                 break;
63682             case 244:
63683                 result = reduceNodes(node.decorators, cbNodes, result);
63684                 result = reduceNodes(node.modifiers, cbNodes, result);
63685                 result = reduceNode(node.name, cbNode, result);
63686                 result = reduceNodes(node.typeParameters, cbNodes, result);
63687                 result = reduceNodes(node.parameters, cbNodes, result);
63688                 result = reduceNode(node.type, cbNode, result);
63689                 result = reduceNode(node.body, cbNode, result);
63690                 break;
63691             case 245:
63692                 result = reduceNodes(node.decorators, cbNodes, result);
63693                 result = reduceNodes(node.modifiers, cbNodes, result);
63694                 result = reduceNode(node.name, cbNode, result);
63695                 result = reduceNodes(node.typeParameters, cbNodes, result);
63696                 result = reduceNodes(node.heritageClauses, cbNodes, result);
63697                 result = reduceNodes(node.members, cbNodes, result);
63698                 break;
63699             case 248:
63700                 result = reduceNodes(node.decorators, cbNodes, result);
63701                 result = reduceNodes(node.modifiers, cbNodes, result);
63702                 result = reduceNode(node.name, cbNode, result);
63703                 result = reduceNodes(node.members, cbNodes, result);
63704                 break;
63705             case 249:
63706                 result = reduceNodes(node.decorators, cbNodes, result);
63707                 result = reduceNodes(node.modifiers, cbNodes, result);
63708                 result = reduceNode(node.name, cbNode, result);
63709                 result = reduceNode(node.body, cbNode, result);
63710                 break;
63711             case 250:
63712                 result = reduceNodes(node.statements, cbNodes, result);
63713                 break;
63714             case 251:
63715                 result = reduceNodes(node.clauses, cbNodes, result);
63716                 break;
63717             case 253:
63718                 result = reduceNodes(node.decorators, cbNodes, result);
63719                 result = reduceNodes(node.modifiers, cbNodes, result);
63720                 result = reduceNode(node.name, cbNode, result);
63721                 result = reduceNode(node.moduleReference, cbNode, result);
63722                 break;
63723             case 254:
63724                 result = reduceNodes(node.decorators, cbNodes, result);
63725                 result = reduceNodes(node.modifiers, cbNodes, result);
63726                 result = reduceNode(node.importClause, cbNode, result);
63727                 result = reduceNode(node.moduleSpecifier, cbNode, result);
63728                 break;
63729             case 255:
63730                 result = reduceNode(node.name, cbNode, result);
63731                 result = reduceNode(node.namedBindings, cbNode, result);
63732                 break;
63733             case 256:
63734                 result = reduceNode(node.name, cbNode, result);
63735                 break;
63736             case 262:
63737                 result = reduceNode(node.name, cbNode, result);
63738                 break;
63739             case 257:
63740             case 261:
63741                 result = reduceNodes(node.elements, cbNodes, result);
63742                 break;
63743             case 258:
63744             case 263:
63745                 result = reduceNode(node.propertyName, cbNode, result);
63746                 result = reduceNode(node.name, cbNode, result);
63747                 break;
63748             case 259:
63749                 result = ts.reduceLeft(node.decorators, cbNode, result);
63750                 result = ts.reduceLeft(node.modifiers, cbNode, result);
63751                 result = reduceNode(node.expression, cbNode, result);
63752                 break;
63753             case 260:
63754                 result = ts.reduceLeft(node.decorators, cbNode, result);
63755                 result = ts.reduceLeft(node.modifiers, cbNode, result);
63756                 result = reduceNode(node.exportClause, cbNode, result);
63757                 result = reduceNode(node.moduleSpecifier, cbNode, result);
63758                 break;
63759             case 265:
63760                 result = reduceNode(node.expression, cbNode, result);
63761                 break;
63762             case 266:
63763                 result = reduceNode(node.openingElement, cbNode, result);
63764                 result = ts.reduceLeft(node.children, cbNode, result);
63765                 result = reduceNode(node.closingElement, cbNode, result);
63766                 break;
63767             case 270:
63768                 result = reduceNode(node.openingFragment, cbNode, result);
63769                 result = ts.reduceLeft(node.children, cbNode, result);
63770                 result = reduceNode(node.closingFragment, cbNode, result);
63771                 break;
63772             case 267:
63773             case 268:
63774                 result = reduceNode(node.tagName, cbNode, result);
63775                 result = reduceNodes(node.typeArguments, cbNode, result);
63776                 result = reduceNode(node.attributes, cbNode, result);
63777                 break;
63778             case 274:
63779                 result = reduceNodes(node.properties, cbNodes, result);
63780                 break;
63781             case 269:
63782                 result = reduceNode(node.tagName, cbNode, result);
63783                 break;
63784             case 273:
63785                 result = reduceNode(node.name, cbNode, result);
63786                 result = reduceNode(node.initializer, cbNode, result);
63787                 break;
63788             case 275:
63789                 result = reduceNode(node.expression, cbNode, result);
63790                 break;
63791             case 276:
63792                 result = reduceNode(node.expression, cbNode, result);
63793                 break;
63794             case 277:
63795                 result = reduceNode(node.expression, cbNode, result);
63796             case 278:
63797                 result = reduceNodes(node.statements, cbNodes, result);
63798                 break;
63799             case 279:
63800                 result = reduceNodes(node.types, cbNodes, result);
63801                 break;
63802             case 280:
63803                 result = reduceNode(node.variableDeclaration, cbNode, result);
63804                 result = reduceNode(node.block, cbNode, result);
63805                 break;
63806             case 281:
63807                 result = reduceNode(node.name, cbNode, result);
63808                 result = reduceNode(node.initializer, cbNode, result);
63809                 break;
63810             case 282:
63811                 result = reduceNode(node.name, cbNode, result);
63812                 result = reduceNode(node.objectAssignmentInitializer, cbNode, result);
63813                 break;
63814             case 283:
63815                 result = reduceNode(node.expression, cbNode, result);
63816                 break;
63817             case 284:
63818                 result = reduceNode(node.name, cbNode, result);
63819                 result = reduceNode(node.initializer, cbNode, result);
63820                 break;
63821             case 290:
63822                 result = reduceNodes(node.statements, cbNodes, result);
63823                 break;
63824             case 326:
63825                 result = reduceNode(node.expression, cbNode, result);
63826                 break;
63827             case 327:
63828                 result = reduceNodes(node.elements, cbNodes, result);
63829                 break;
63830             default:
63831                 break;
63832         }
63833         return result;
63834     }
63835     ts.reduceEachChild = reduceEachChild;
63836     function findSpanEnd(array, test, start) {
63837         var i = start;
63838         while (i < array.length && test(array[i])) {
63839             i++;
63840         }
63841         return i;
63842     }
63843     function mergeLexicalEnvironment(statements, declarations) {
63844         if (!ts.some(declarations)) {
63845             return statements;
63846         }
63847         var leftStandardPrologueEnd = findSpanEnd(statements, ts.isPrologueDirective, 0);
63848         var leftHoistedFunctionsEnd = findSpanEnd(statements, ts.isHoistedFunction, leftStandardPrologueEnd);
63849         var leftHoistedVariablesEnd = findSpanEnd(statements, ts.isHoistedVariableStatement, leftHoistedFunctionsEnd);
63850         var rightStandardPrologueEnd = findSpanEnd(declarations, ts.isPrologueDirective, 0);
63851         var rightHoistedFunctionsEnd = findSpanEnd(declarations, ts.isHoistedFunction, rightStandardPrologueEnd);
63852         var rightHoistedVariablesEnd = findSpanEnd(declarations, ts.isHoistedVariableStatement, rightHoistedFunctionsEnd);
63853         var rightCustomPrologueEnd = findSpanEnd(declarations, ts.isCustomPrologue, rightHoistedVariablesEnd);
63854         ts.Debug.assert(rightCustomPrologueEnd === declarations.length, "Expected declarations to be valid standard or custom prologues");
63855         var left = ts.isNodeArray(statements) ? statements.slice() : statements;
63856         if (rightCustomPrologueEnd > rightHoistedVariablesEnd) {
63857             left.splice.apply(left, __spreadArrays([leftHoistedVariablesEnd, 0], declarations.slice(rightHoistedVariablesEnd, rightCustomPrologueEnd)));
63858         }
63859         if (rightHoistedVariablesEnd > rightHoistedFunctionsEnd) {
63860             left.splice.apply(left, __spreadArrays([leftHoistedFunctionsEnd, 0], declarations.slice(rightHoistedFunctionsEnd, rightHoistedVariablesEnd)));
63861         }
63862         if (rightHoistedFunctionsEnd > rightStandardPrologueEnd) {
63863             left.splice.apply(left, __spreadArrays([leftStandardPrologueEnd, 0], declarations.slice(rightStandardPrologueEnd, rightHoistedFunctionsEnd)));
63864         }
63865         if (rightStandardPrologueEnd > 0) {
63866             if (leftStandardPrologueEnd === 0) {
63867                 left.splice.apply(left, __spreadArrays([0, 0], declarations.slice(0, rightStandardPrologueEnd)));
63868             }
63869             else {
63870                 var leftPrologues = ts.createMap();
63871                 for (var i = 0; i < leftStandardPrologueEnd; i++) {
63872                     var leftPrologue = statements[i];
63873                     leftPrologues.set(leftPrologue.expression.text, true);
63874                 }
63875                 for (var i = rightStandardPrologueEnd - 1; i >= 0; i--) {
63876                     var rightPrologue = declarations[i];
63877                     if (!leftPrologues.has(rightPrologue.expression.text)) {
63878                         left.unshift(rightPrologue);
63879                     }
63880                 }
63881             }
63882         }
63883         if (ts.isNodeArray(statements)) {
63884             return ts.setTextRange(ts.createNodeArray(left, statements.hasTrailingComma), statements);
63885         }
63886         return statements;
63887     }
63888     ts.mergeLexicalEnvironment = mergeLexicalEnvironment;
63889     function liftToBlock(nodes) {
63890         ts.Debug.assert(ts.every(nodes, ts.isStatement), "Cannot lift nodes to a Block.");
63891         return ts.singleOrUndefined(nodes) || ts.createBlock(nodes);
63892     }
63893     ts.liftToBlock = liftToBlock;
63894     function aggregateTransformFlags(node) {
63895         aggregateTransformFlagsForNode(node);
63896         return node;
63897     }
63898     ts.aggregateTransformFlags = aggregateTransformFlags;
63899     function aggregateTransformFlagsForNode(node) {
63900         if (node === undefined) {
63901             return 0;
63902         }
63903         if (node.transformFlags & 536870912) {
63904             return node.transformFlags & ~ts.getTransformFlagsSubtreeExclusions(node.kind);
63905         }
63906         var subtreeFlags = aggregateTransformFlagsForSubtree(node);
63907         return ts.computeTransformFlagsForNode(node, subtreeFlags);
63908     }
63909     function aggregateTransformFlagsForNodeArray(nodes) {
63910         if (nodes === undefined) {
63911             return 0;
63912         }
63913         var subtreeFlags = 0;
63914         var nodeArrayFlags = 0;
63915         for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) {
63916             var node = nodes_3[_i];
63917             subtreeFlags |= aggregateTransformFlagsForNode(node);
63918             nodeArrayFlags |= node.transformFlags & ~536870912;
63919         }
63920         nodes.transformFlags = nodeArrayFlags | 536870912;
63921         return subtreeFlags;
63922     }
63923     function aggregateTransformFlagsForSubtree(node) {
63924         if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 216)) {
63925             return 0;
63926         }
63927         return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes);
63928     }
63929     function aggregateTransformFlagsForChildNode(transformFlags, node) {
63930         return transformFlags | aggregateTransformFlagsForNode(node);
63931     }
63932     function aggregateTransformFlagsForChildNodes(transformFlags, nodes) {
63933         return transformFlags | aggregateTransformFlagsForNodeArray(nodes);
63934     }
63935 })(ts || (ts = {}));
63936 var ts;
63937 (function (ts) {
63938     function createSourceMapGenerator(host, file, sourceRoot, sourcesDirectoryPath, generatorOptions) {
63939         var _a = generatorOptions.extendedDiagnostics
63940             ? ts.performance.createTimer("Source Map", "beforeSourcemap", "afterSourcemap")
63941             : ts.performance.nullTimer, enter = _a.enter, exit = _a.exit;
63942         var rawSources = [];
63943         var sources = [];
63944         var sourceToSourceIndexMap = ts.createMap();
63945         var sourcesContent;
63946         var names = [];
63947         var nameToNameIndexMap;
63948         var mappings = "";
63949         var lastGeneratedLine = 0;
63950         var lastGeneratedCharacter = 0;
63951         var lastSourceIndex = 0;
63952         var lastSourceLine = 0;
63953         var lastSourceCharacter = 0;
63954         var lastNameIndex = 0;
63955         var hasLast = false;
63956         var pendingGeneratedLine = 0;
63957         var pendingGeneratedCharacter = 0;
63958         var pendingSourceIndex = 0;
63959         var pendingSourceLine = 0;
63960         var pendingSourceCharacter = 0;
63961         var pendingNameIndex = 0;
63962         var hasPending = false;
63963         var hasPendingSource = false;
63964         var hasPendingName = false;
63965         return {
63966             getSources: function () { return rawSources; },
63967             addSource: addSource,
63968             setSourceContent: setSourceContent,
63969             addName: addName,
63970             addMapping: addMapping,
63971             appendSourceMap: appendSourceMap,
63972             toJSON: toJSON,
63973             toString: function () { return JSON.stringify(toJSON()); }
63974         };
63975         function addSource(fileName) {
63976             enter();
63977             var source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true);
63978             var sourceIndex = sourceToSourceIndexMap.get(source);
63979             if (sourceIndex === undefined) {
63980                 sourceIndex = sources.length;
63981                 sources.push(source);
63982                 rawSources.push(fileName);
63983                 sourceToSourceIndexMap.set(source, sourceIndex);
63984             }
63985             exit();
63986             return sourceIndex;
63987         }
63988         function setSourceContent(sourceIndex, content) {
63989             enter();
63990             if (content !== null) {
63991                 if (!sourcesContent)
63992                     sourcesContent = [];
63993                 while (sourcesContent.length < sourceIndex) {
63994                     sourcesContent.push(null);
63995                 }
63996                 sourcesContent[sourceIndex] = content;
63997             }
63998             exit();
63999         }
64000         function addName(name) {
64001             enter();
64002             if (!nameToNameIndexMap)
64003                 nameToNameIndexMap = ts.createMap();
64004             var nameIndex = nameToNameIndexMap.get(name);
64005             if (nameIndex === undefined) {
64006                 nameIndex = names.length;
64007                 names.push(name);
64008                 nameToNameIndexMap.set(name, nameIndex);
64009             }
64010             exit();
64011             return nameIndex;
64012         }
64013         function isNewGeneratedPosition(generatedLine, generatedCharacter) {
64014             return !hasPending
64015                 || pendingGeneratedLine !== generatedLine
64016                 || pendingGeneratedCharacter !== generatedCharacter;
64017         }
64018         function isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter) {
64019             return sourceIndex !== undefined
64020                 && sourceLine !== undefined
64021                 && sourceCharacter !== undefined
64022                 && pendingSourceIndex === sourceIndex
64023                 && (pendingSourceLine > sourceLine
64024                     || pendingSourceLine === sourceLine && pendingSourceCharacter > sourceCharacter);
64025         }
64026         function addMapping(generatedLine, generatedCharacter, sourceIndex, sourceLine, sourceCharacter, nameIndex) {
64027             ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack");
64028             ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative");
64029             ts.Debug.assert(sourceIndex === undefined || sourceIndex >= 0, "sourceIndex cannot be negative");
64030             ts.Debug.assert(sourceLine === undefined || sourceLine >= 0, "sourceLine cannot be negative");
64031             ts.Debug.assert(sourceCharacter === undefined || sourceCharacter >= 0, "sourceCharacter cannot be negative");
64032             enter();
64033             if (isNewGeneratedPosition(generatedLine, generatedCharacter) ||
64034                 isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter)) {
64035                 commitPendingMapping();
64036                 pendingGeneratedLine = generatedLine;
64037                 pendingGeneratedCharacter = generatedCharacter;
64038                 hasPendingSource = false;
64039                 hasPendingName = false;
64040                 hasPending = true;
64041             }
64042             if (sourceIndex !== undefined && sourceLine !== undefined && sourceCharacter !== undefined) {
64043                 pendingSourceIndex = sourceIndex;
64044                 pendingSourceLine = sourceLine;
64045                 pendingSourceCharacter = sourceCharacter;
64046                 hasPendingSource = true;
64047                 if (nameIndex !== undefined) {
64048                     pendingNameIndex = nameIndex;
64049                     hasPendingName = true;
64050                 }
64051             }
64052             exit();
64053         }
64054         function appendSourceMap(generatedLine, generatedCharacter, map, sourceMapPath, start, end) {
64055             ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack");
64056             ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative");
64057             enter();
64058             var sourceIndexToNewSourceIndexMap = [];
64059             var nameIndexToNewNameIndexMap;
64060             var mappingIterator = decodeMappings(map.mappings);
64061             for (var iterResult = mappingIterator.next(); !iterResult.done; iterResult = mappingIterator.next()) {
64062                 var raw = iterResult.value;
64063                 if (end && (raw.generatedLine > end.line ||
64064                     (raw.generatedLine === end.line && raw.generatedCharacter > end.character))) {
64065                     break;
64066                 }
64067                 if (start && (raw.generatedLine < start.line ||
64068                     (start.line === raw.generatedLine && raw.generatedCharacter < start.character))) {
64069                     continue;
64070                 }
64071                 var newSourceIndex = void 0;
64072                 var newSourceLine = void 0;
64073                 var newSourceCharacter = void 0;
64074                 var newNameIndex = void 0;
64075                 if (raw.sourceIndex !== undefined) {
64076                     newSourceIndex = sourceIndexToNewSourceIndexMap[raw.sourceIndex];
64077                     if (newSourceIndex === undefined) {
64078                         var rawPath = map.sources[raw.sourceIndex];
64079                         var relativePath = map.sourceRoot ? ts.combinePaths(map.sourceRoot, rawPath) : rawPath;
64080                         var combinedPath = ts.combinePaths(ts.getDirectoryPath(sourceMapPath), relativePath);
64081                         sourceIndexToNewSourceIndexMap[raw.sourceIndex] = newSourceIndex = addSource(combinedPath);
64082                         if (map.sourcesContent && typeof map.sourcesContent[raw.sourceIndex] === "string") {
64083                             setSourceContent(newSourceIndex, map.sourcesContent[raw.sourceIndex]);
64084                         }
64085                     }
64086                     newSourceLine = raw.sourceLine;
64087                     newSourceCharacter = raw.sourceCharacter;
64088                     if (map.names && raw.nameIndex !== undefined) {
64089                         if (!nameIndexToNewNameIndexMap)
64090                             nameIndexToNewNameIndexMap = [];
64091                         newNameIndex = nameIndexToNewNameIndexMap[raw.nameIndex];
64092                         if (newNameIndex === undefined) {
64093                             nameIndexToNewNameIndexMap[raw.nameIndex] = newNameIndex = addName(map.names[raw.nameIndex]);
64094                         }
64095                     }
64096                 }
64097                 var rawGeneratedLine = raw.generatedLine - (start ? start.line : 0);
64098                 var newGeneratedLine = rawGeneratedLine + generatedLine;
64099                 var rawGeneratedCharacter = start && start.line === raw.generatedLine ? raw.generatedCharacter - start.character : raw.generatedCharacter;
64100                 var newGeneratedCharacter = rawGeneratedLine === 0 ? rawGeneratedCharacter + generatedCharacter : rawGeneratedCharacter;
64101                 addMapping(newGeneratedLine, newGeneratedCharacter, newSourceIndex, newSourceLine, newSourceCharacter, newNameIndex);
64102             }
64103             exit();
64104         }
64105         function shouldCommitMapping() {
64106             return !hasLast
64107                 || lastGeneratedLine !== pendingGeneratedLine
64108                 || lastGeneratedCharacter !== pendingGeneratedCharacter
64109                 || lastSourceIndex !== pendingSourceIndex
64110                 || lastSourceLine !== pendingSourceLine
64111                 || lastSourceCharacter !== pendingSourceCharacter
64112                 || lastNameIndex !== pendingNameIndex;
64113         }
64114         function commitPendingMapping() {
64115             if (!hasPending || !shouldCommitMapping()) {
64116                 return;
64117             }
64118             enter();
64119             if (lastGeneratedLine < pendingGeneratedLine) {
64120                 do {
64121                     mappings += ";";
64122                     lastGeneratedLine++;
64123                     lastGeneratedCharacter = 0;
64124                 } while (lastGeneratedLine < pendingGeneratedLine);
64125             }
64126             else {
64127                 ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack");
64128                 if (hasLast) {
64129                     mappings += ",";
64130                 }
64131             }
64132             mappings += base64VLQFormatEncode(pendingGeneratedCharacter - lastGeneratedCharacter);
64133             lastGeneratedCharacter = pendingGeneratedCharacter;
64134             if (hasPendingSource) {
64135                 mappings += base64VLQFormatEncode(pendingSourceIndex - lastSourceIndex);
64136                 lastSourceIndex = pendingSourceIndex;
64137                 mappings += base64VLQFormatEncode(pendingSourceLine - lastSourceLine);
64138                 lastSourceLine = pendingSourceLine;
64139                 mappings += base64VLQFormatEncode(pendingSourceCharacter - lastSourceCharacter);
64140                 lastSourceCharacter = pendingSourceCharacter;
64141                 if (hasPendingName) {
64142                     mappings += base64VLQFormatEncode(pendingNameIndex - lastNameIndex);
64143                     lastNameIndex = pendingNameIndex;
64144                 }
64145             }
64146             hasLast = true;
64147             exit();
64148         }
64149         function toJSON() {
64150             commitPendingMapping();
64151             return {
64152                 version: 3,
64153                 file: file,
64154                 sourceRoot: sourceRoot,
64155                 sources: sources,
64156                 names: names,
64157                 mappings: mappings,
64158                 sourcesContent: sourcesContent,
64159             };
64160         }
64161     }
64162     ts.createSourceMapGenerator = createSourceMapGenerator;
64163     var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/;
64164     var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/;
64165     function getLineInfo(text, lineStarts) {
64166         return {
64167             getLineCount: function () { return lineStarts.length; },
64168             getLineText: function (line) { return text.substring(lineStarts[line], lineStarts[line + 1]); }
64169         };
64170     }
64171     ts.getLineInfo = getLineInfo;
64172     function tryGetSourceMappingURL(lineInfo) {
64173         for (var index = lineInfo.getLineCount() - 1; index >= 0; index--) {
64174             var line = lineInfo.getLineText(index);
64175             var comment = sourceMapCommentRegExp.exec(line);
64176             if (comment) {
64177                 return comment[1];
64178             }
64179             else if (!line.match(whitespaceOrMapCommentRegExp)) {
64180                 break;
64181             }
64182         }
64183     }
64184     ts.tryGetSourceMappingURL = tryGetSourceMappingURL;
64185     function isStringOrNull(x) {
64186         return typeof x === "string" || x === null;
64187     }
64188     function isRawSourceMap(x) {
64189         return x !== null
64190             && typeof x === "object"
64191             && x.version === 3
64192             && typeof x.file === "string"
64193             && typeof x.mappings === "string"
64194             && ts.isArray(x.sources) && ts.every(x.sources, ts.isString)
64195             && (x.sourceRoot === undefined || x.sourceRoot === null || typeof x.sourceRoot === "string")
64196             && (x.sourcesContent === undefined || x.sourcesContent === null || ts.isArray(x.sourcesContent) && ts.every(x.sourcesContent, isStringOrNull))
64197             && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString));
64198     }
64199     ts.isRawSourceMap = isRawSourceMap;
64200     function tryParseRawSourceMap(text) {
64201         try {
64202             var parsed = JSON.parse(text);
64203             if (isRawSourceMap(parsed)) {
64204                 return parsed;
64205             }
64206         }
64207         catch (_a) {
64208         }
64209         return undefined;
64210     }
64211     ts.tryParseRawSourceMap = tryParseRawSourceMap;
64212     function decodeMappings(mappings) {
64213         var done = false;
64214         var pos = 0;
64215         var generatedLine = 0;
64216         var generatedCharacter = 0;
64217         var sourceIndex = 0;
64218         var sourceLine = 0;
64219         var sourceCharacter = 0;
64220         var nameIndex = 0;
64221         var error;
64222         return {
64223             get pos() { return pos; },
64224             get error() { return error; },
64225             get state() { return captureMapping(true, true); },
64226             next: function () {
64227                 while (!done && pos < mappings.length) {
64228                     var ch = mappings.charCodeAt(pos);
64229                     if (ch === 59) {
64230                         generatedLine++;
64231                         generatedCharacter = 0;
64232                         pos++;
64233                         continue;
64234                     }
64235                     if (ch === 44) {
64236                         pos++;
64237                         continue;
64238                     }
64239                     var hasSource = false;
64240                     var hasName = false;
64241                     generatedCharacter += base64VLQFormatDecode();
64242                     if (hasReportedError())
64243                         return stopIterating();
64244                     if (generatedCharacter < 0)
64245                         return setErrorAndStopIterating("Invalid generatedCharacter found");
64246                     if (!isSourceMappingSegmentEnd()) {
64247                         hasSource = true;
64248                         sourceIndex += base64VLQFormatDecode();
64249                         if (hasReportedError())
64250                             return stopIterating();
64251                         if (sourceIndex < 0)
64252                             return setErrorAndStopIterating("Invalid sourceIndex found");
64253                         if (isSourceMappingSegmentEnd())
64254                             return setErrorAndStopIterating("Unsupported Format: No entries after sourceIndex");
64255                         sourceLine += base64VLQFormatDecode();
64256                         if (hasReportedError())
64257                             return stopIterating();
64258                         if (sourceLine < 0)
64259                             return setErrorAndStopIterating("Invalid sourceLine found");
64260                         if (isSourceMappingSegmentEnd())
64261                             return setErrorAndStopIterating("Unsupported Format: No entries after sourceLine");
64262                         sourceCharacter += base64VLQFormatDecode();
64263                         if (hasReportedError())
64264                             return stopIterating();
64265                         if (sourceCharacter < 0)
64266                             return setErrorAndStopIterating("Invalid sourceCharacter found");
64267                         if (!isSourceMappingSegmentEnd()) {
64268                             hasName = true;
64269                             nameIndex += base64VLQFormatDecode();
64270                             if (hasReportedError())
64271                                 return stopIterating();
64272                             if (nameIndex < 0)
64273                                 return setErrorAndStopIterating("Invalid nameIndex found");
64274                             if (!isSourceMappingSegmentEnd())
64275                                 return setErrorAndStopIterating("Unsupported Error Format: Entries after nameIndex");
64276                         }
64277                     }
64278                     return { value: captureMapping(hasSource, hasName), done: done };
64279                 }
64280                 return stopIterating();
64281             }
64282         };
64283         function captureMapping(hasSource, hasName) {
64284             return {
64285                 generatedLine: generatedLine,
64286                 generatedCharacter: generatedCharacter,
64287                 sourceIndex: hasSource ? sourceIndex : undefined,
64288                 sourceLine: hasSource ? sourceLine : undefined,
64289                 sourceCharacter: hasSource ? sourceCharacter : undefined,
64290                 nameIndex: hasName ? nameIndex : undefined
64291             };
64292         }
64293         function stopIterating() {
64294             done = true;
64295             return { value: undefined, done: true };
64296         }
64297         function setError(message) {
64298             if (error === undefined) {
64299                 error = message;
64300             }
64301         }
64302         function setErrorAndStopIterating(message) {
64303             setError(message);
64304             return stopIterating();
64305         }
64306         function hasReportedError() {
64307             return error !== undefined;
64308         }
64309         function isSourceMappingSegmentEnd() {
64310             return (pos === mappings.length ||
64311                 mappings.charCodeAt(pos) === 44 ||
64312                 mappings.charCodeAt(pos) === 59);
64313         }
64314         function base64VLQFormatDecode() {
64315             var moreDigits = true;
64316             var shiftCount = 0;
64317             var value = 0;
64318             for (; moreDigits; pos++) {
64319                 if (pos >= mappings.length)
64320                     return setError("Error in decoding base64VLQFormatDecode, past the mapping string"), -1;
64321                 var currentByte = base64FormatDecode(mappings.charCodeAt(pos));
64322                 if (currentByte === -1)
64323                     return setError("Invalid character in VLQ"), -1;
64324                 moreDigits = (currentByte & 32) !== 0;
64325                 value = value | ((currentByte & 31) << shiftCount);
64326                 shiftCount += 5;
64327             }
64328             if ((value & 1) === 0) {
64329                 value = value >> 1;
64330             }
64331             else {
64332                 value = value >> 1;
64333                 value = -value;
64334             }
64335             return value;
64336         }
64337     }
64338     ts.decodeMappings = decodeMappings;
64339     function sameMapping(left, right) {
64340         return left === right
64341             || left.generatedLine === right.generatedLine
64342                 && left.generatedCharacter === right.generatedCharacter
64343                 && left.sourceIndex === right.sourceIndex
64344                 && left.sourceLine === right.sourceLine
64345                 && left.sourceCharacter === right.sourceCharacter
64346                 && left.nameIndex === right.nameIndex;
64347     }
64348     ts.sameMapping = sameMapping;
64349     function isSourceMapping(mapping) {
64350         return mapping.sourceIndex !== undefined
64351             && mapping.sourceLine !== undefined
64352             && mapping.sourceCharacter !== undefined;
64353     }
64354     ts.isSourceMapping = isSourceMapping;
64355     function base64FormatEncode(value) {
64356         return value >= 0 && value < 26 ? 65 + value :
64357             value >= 26 && value < 52 ? 97 + value - 26 :
64358                 value >= 52 && value < 62 ? 48 + value - 52 :
64359                     value === 62 ? 43 :
64360                         value === 63 ? 47 :
64361                             ts.Debug.fail(value + ": not a base64 value");
64362     }
64363     function base64FormatDecode(ch) {
64364         return ch >= 65 && ch <= 90 ? ch - 65 :
64365             ch >= 97 && ch <= 122 ? ch - 97 + 26 :
64366                 ch >= 48 && ch <= 57 ? ch - 48 + 52 :
64367                     ch === 43 ? 62 :
64368                         ch === 47 ? 63 :
64369                             -1;
64370     }
64371     function base64VLQFormatEncode(inValue) {
64372         if (inValue < 0) {
64373             inValue = ((-inValue) << 1) + 1;
64374         }
64375         else {
64376             inValue = inValue << 1;
64377         }
64378         var encodedStr = "";
64379         do {
64380             var currentDigit = inValue & 31;
64381             inValue = inValue >> 5;
64382             if (inValue > 0) {
64383                 currentDigit = currentDigit | 32;
64384             }
64385             encodedStr = encodedStr + String.fromCharCode(base64FormatEncode(currentDigit));
64386         } while (inValue > 0);
64387         return encodedStr;
64388     }
64389     function isSourceMappedPosition(value) {
64390         return value.sourceIndex !== undefined
64391             && value.sourcePosition !== undefined;
64392     }
64393     function sameMappedPosition(left, right) {
64394         return left.generatedPosition === right.generatedPosition
64395             && left.sourceIndex === right.sourceIndex
64396             && left.sourcePosition === right.sourcePosition;
64397     }
64398     function compareSourcePositions(left, right) {
64399         ts.Debug.assert(left.sourceIndex === right.sourceIndex);
64400         return ts.compareValues(left.sourcePosition, right.sourcePosition);
64401     }
64402     function compareGeneratedPositions(left, right) {
64403         return ts.compareValues(left.generatedPosition, right.generatedPosition);
64404     }
64405     function getSourcePositionOfMapping(value) {
64406         return value.sourcePosition;
64407     }
64408     function getGeneratedPositionOfMapping(value) {
64409         return value.generatedPosition;
64410     }
64411     function createDocumentPositionMapper(host, map, mapPath) {
64412         var mapDirectory = ts.getDirectoryPath(mapPath);
64413         var sourceRoot = map.sourceRoot ? ts.getNormalizedAbsolutePath(map.sourceRoot, mapDirectory) : mapDirectory;
64414         var generatedAbsoluteFilePath = ts.getNormalizedAbsolutePath(map.file, mapDirectory);
64415         var generatedFile = host.getSourceFileLike(generatedAbsoluteFilePath);
64416         var sourceFileAbsolutePaths = map.sources.map(function (source) { return ts.getNormalizedAbsolutePath(source, sourceRoot); });
64417         var sourceToSourceIndexMap = ts.createMapFromEntries(sourceFileAbsolutePaths.map(function (source, i) { return [host.getCanonicalFileName(source), i]; }));
64418         var decodedMappings;
64419         var generatedMappings;
64420         var sourceMappings;
64421         return {
64422             getSourcePosition: getSourcePosition,
64423             getGeneratedPosition: getGeneratedPosition
64424         };
64425         function processMapping(mapping) {
64426             var generatedPosition = generatedFile !== undefined
64427                 ? ts.getPositionOfLineAndCharacter(generatedFile, mapping.generatedLine, mapping.generatedCharacter, true)
64428                 : -1;
64429             var source;
64430             var sourcePosition;
64431             if (isSourceMapping(mapping)) {
64432                 var sourceFile = host.getSourceFileLike(sourceFileAbsolutePaths[mapping.sourceIndex]);
64433                 source = map.sources[mapping.sourceIndex];
64434                 sourcePosition = sourceFile !== undefined
64435                     ? ts.getPositionOfLineAndCharacter(sourceFile, mapping.sourceLine, mapping.sourceCharacter, true)
64436                     : -1;
64437             }
64438             return {
64439                 generatedPosition: generatedPosition,
64440                 source: source,
64441                 sourceIndex: mapping.sourceIndex,
64442                 sourcePosition: sourcePosition,
64443                 nameIndex: mapping.nameIndex
64444             };
64445         }
64446         function getDecodedMappings() {
64447             if (decodedMappings === undefined) {
64448                 var decoder = decodeMappings(map.mappings);
64449                 var mappings = ts.arrayFrom(decoder, processMapping);
64450                 if (decoder.error !== undefined) {
64451                     if (host.log) {
64452                         host.log("Encountered error while decoding sourcemap: " + decoder.error);
64453                     }
64454                     decodedMappings = ts.emptyArray;
64455                 }
64456                 else {
64457                     decodedMappings = mappings;
64458                 }
64459             }
64460             return decodedMappings;
64461         }
64462         function getSourceMappings(sourceIndex) {
64463             if (sourceMappings === undefined) {
64464                 var lists = [];
64465                 for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) {
64466                     var mapping = _a[_i];
64467                     if (!isSourceMappedPosition(mapping))
64468                         continue;
64469                     var list = lists[mapping.sourceIndex];
64470                     if (!list)
64471                         lists[mapping.sourceIndex] = list = [];
64472                     list.push(mapping);
64473                 }
64474                 sourceMappings = lists.map(function (list) { return ts.sortAndDeduplicate(list, compareSourcePositions, sameMappedPosition); });
64475             }
64476             return sourceMappings[sourceIndex];
64477         }
64478         function getGeneratedMappings() {
64479             if (generatedMappings === undefined) {
64480                 var list = [];
64481                 for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) {
64482                     var mapping = _a[_i];
64483                     list.push(mapping);
64484                 }
64485                 generatedMappings = ts.sortAndDeduplicate(list, compareGeneratedPositions, sameMappedPosition);
64486             }
64487             return generatedMappings;
64488         }
64489         function getGeneratedPosition(loc) {
64490             var sourceIndex = sourceToSourceIndexMap.get(host.getCanonicalFileName(loc.fileName));
64491             if (sourceIndex === undefined)
64492                 return loc;
64493             var sourceMappings = getSourceMappings(sourceIndex);
64494             if (!ts.some(sourceMappings))
64495                 return loc;
64496             var targetIndex = ts.binarySearchKey(sourceMappings, loc.pos, getSourcePositionOfMapping, ts.compareValues);
64497             if (targetIndex < 0) {
64498                 targetIndex = ~targetIndex;
64499             }
64500             var mapping = sourceMappings[targetIndex];
64501             if (mapping === undefined || mapping.sourceIndex !== sourceIndex) {
64502                 return loc;
64503             }
64504             return { fileName: generatedAbsoluteFilePath, pos: mapping.generatedPosition };
64505         }
64506         function getSourcePosition(loc) {
64507             var generatedMappings = getGeneratedMappings();
64508             if (!ts.some(generatedMappings))
64509                 return loc;
64510             var targetIndex = ts.binarySearchKey(generatedMappings, loc.pos, getGeneratedPositionOfMapping, ts.compareValues);
64511             if (targetIndex < 0) {
64512                 targetIndex = ~targetIndex;
64513             }
64514             var mapping = generatedMappings[targetIndex];
64515             if (mapping === undefined || !isSourceMappedPosition(mapping)) {
64516                 return loc;
64517             }
64518             return { fileName: sourceFileAbsolutePaths[mapping.sourceIndex], pos: mapping.sourcePosition };
64519         }
64520     }
64521     ts.createDocumentPositionMapper = createDocumentPositionMapper;
64522     ts.identitySourceMapConsumer = {
64523         getSourcePosition: ts.identity,
64524         getGeneratedPosition: ts.identity
64525     };
64526 })(ts || (ts = {}));
64527 var ts;
64528 (function (ts) {
64529     function getOriginalNodeId(node) {
64530         node = ts.getOriginalNode(node);
64531         return node ? ts.getNodeId(node) : 0;
64532     }
64533     ts.getOriginalNodeId = getOriginalNodeId;
64534     function containsDefaultReference(node) {
64535         if (!node)
64536             return false;
64537         if (!ts.isNamedImports(node))
64538             return false;
64539         return ts.some(node.elements, isNamedDefaultReference);
64540     }
64541     function isNamedDefaultReference(e) {
64542         return e.propertyName !== undefined && e.propertyName.escapedText === "default";
64543     }
64544     function chainBundle(transformSourceFile) {
64545         return transformSourceFileOrBundle;
64546         function transformSourceFileOrBundle(node) {
64547             return node.kind === 290 ? transformSourceFile(node) : transformBundle(node);
64548         }
64549         function transformBundle(node) {
64550             return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends);
64551         }
64552     }
64553     ts.chainBundle = chainBundle;
64554     function getExportNeedsImportStarHelper(node) {
64555         return !!ts.getNamespaceDeclarationNode(node);
64556     }
64557     ts.getExportNeedsImportStarHelper = getExportNeedsImportStarHelper;
64558     function getImportNeedsImportStarHelper(node) {
64559         if (!!ts.getNamespaceDeclarationNode(node)) {
64560             return true;
64561         }
64562         var bindings = node.importClause && node.importClause.namedBindings;
64563         if (!bindings) {
64564             return false;
64565         }
64566         if (!ts.isNamedImports(bindings))
64567             return false;
64568         var defaultRefCount = 0;
64569         for (var _i = 0, _a = bindings.elements; _i < _a.length; _i++) {
64570             var binding = _a[_i];
64571             if (isNamedDefaultReference(binding)) {
64572                 defaultRefCount++;
64573             }
64574         }
64575         return (defaultRefCount > 0 && defaultRefCount !== bindings.elements.length) || (!!(bindings.elements.length - defaultRefCount) && ts.isDefaultImport(node));
64576     }
64577     ts.getImportNeedsImportStarHelper = getImportNeedsImportStarHelper;
64578     function getImportNeedsImportDefaultHelper(node) {
64579         return !getImportNeedsImportStarHelper(node) && (ts.isDefaultImport(node) || (!!node.importClause && ts.isNamedImports(node.importClause.namedBindings) && containsDefaultReference(node.importClause.namedBindings)));
64580     }
64581     ts.getImportNeedsImportDefaultHelper = getImportNeedsImportDefaultHelper;
64582     function collectExternalModuleInfo(sourceFile, resolver, compilerOptions) {
64583         var externalImports = [];
64584         var exportSpecifiers = ts.createMultiMap();
64585         var exportedBindings = [];
64586         var uniqueExports = ts.createMap();
64587         var exportedNames;
64588         var hasExportDefault = false;
64589         var exportEquals;
64590         var hasExportStarsToExportValues = false;
64591         var hasImportStar = false;
64592         var hasImportDefault = false;
64593         for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
64594             var node = _a[_i];
64595             switch (node.kind) {
64596                 case 254:
64597                     externalImports.push(node);
64598                     if (!hasImportStar && getImportNeedsImportStarHelper(node)) {
64599                         hasImportStar = true;
64600                     }
64601                     if (!hasImportDefault && getImportNeedsImportDefaultHelper(node)) {
64602                         hasImportDefault = true;
64603                     }
64604                     break;
64605                 case 253:
64606                     if (node.moduleReference.kind === 265) {
64607                         externalImports.push(node);
64608                     }
64609                     break;
64610                 case 260:
64611                     if (node.moduleSpecifier) {
64612                         if (!node.exportClause) {
64613                             externalImports.push(node);
64614                             hasExportStarsToExportValues = true;
64615                         }
64616                         else {
64617                             externalImports.push(node);
64618                         }
64619                     }
64620                     else {
64621                         for (var _b = 0, _c = ts.cast(node.exportClause, ts.isNamedExports).elements; _b < _c.length; _b++) {
64622                             var specifier = _c[_b];
64623                             if (!uniqueExports.get(ts.idText(specifier.name))) {
64624                                 var name = specifier.propertyName || specifier.name;
64625                                 exportSpecifiers.add(ts.idText(name), specifier);
64626                                 var decl = resolver.getReferencedImportDeclaration(name)
64627                                     || resolver.getReferencedValueDeclaration(name);
64628                                 if (decl) {
64629                                     multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name);
64630                                 }
64631                                 uniqueExports.set(ts.idText(specifier.name), true);
64632                                 exportedNames = ts.append(exportedNames, specifier.name);
64633                             }
64634                         }
64635                     }
64636                     break;
64637                 case 259:
64638                     if (node.isExportEquals && !exportEquals) {
64639                         exportEquals = node;
64640                     }
64641                     break;
64642                 case 225:
64643                     if (ts.hasModifier(node, 1)) {
64644                         for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) {
64645                             var decl = _e[_d];
64646                             exportedNames = collectExportedVariableInfo(decl, uniqueExports, exportedNames);
64647                         }
64648                     }
64649                     break;
64650                 case 244:
64651                     if (ts.hasModifier(node, 1)) {
64652                         if (ts.hasModifier(node, 512)) {
64653                             if (!hasExportDefault) {
64654                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), ts.getDeclarationName(node));
64655                                 hasExportDefault = true;
64656                             }
64657                         }
64658                         else {
64659                             var name = node.name;
64660                             if (!uniqueExports.get(ts.idText(name))) {
64661                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
64662                                 uniqueExports.set(ts.idText(name), true);
64663                                 exportedNames = ts.append(exportedNames, name);
64664                             }
64665                         }
64666                     }
64667                     break;
64668                 case 245:
64669                     if (ts.hasModifier(node, 1)) {
64670                         if (ts.hasModifier(node, 512)) {
64671                             if (!hasExportDefault) {
64672                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), ts.getDeclarationName(node));
64673                                 hasExportDefault = true;
64674                             }
64675                         }
64676                         else {
64677                             var name = node.name;
64678                             if (name && !uniqueExports.get(ts.idText(name))) {
64679                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
64680                                 uniqueExports.set(ts.idText(name), true);
64681                                 exportedNames = ts.append(exportedNames, name);
64682                             }
64683                         }
64684                     }
64685                     break;
64686             }
64687         }
64688         var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault);
64689         if (externalHelpersImportDeclaration) {
64690             externalImports.unshift(externalHelpersImportDeclaration);
64691         }
64692         return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames, externalHelpersImportDeclaration: externalHelpersImportDeclaration };
64693     }
64694     ts.collectExternalModuleInfo = collectExternalModuleInfo;
64695     function collectExportedVariableInfo(decl, uniqueExports, exportedNames) {
64696         if (ts.isBindingPattern(decl.name)) {
64697             for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) {
64698                 var element = _a[_i];
64699                 if (!ts.isOmittedExpression(element)) {
64700                     exportedNames = collectExportedVariableInfo(element, uniqueExports, exportedNames);
64701                 }
64702             }
64703         }
64704         else if (!ts.isGeneratedIdentifier(decl.name)) {
64705             var text = ts.idText(decl.name);
64706             if (!uniqueExports.get(text)) {
64707                 uniqueExports.set(text, true);
64708                 exportedNames = ts.append(exportedNames, decl.name);
64709             }
64710         }
64711         return exportedNames;
64712     }
64713     function multiMapSparseArrayAdd(map, key, value) {
64714         var values = map[key];
64715         if (values) {
64716             values.push(value);
64717         }
64718         else {
64719             map[key] = values = [value];
64720         }
64721         return values;
64722     }
64723     function isSimpleCopiableExpression(expression) {
64724         return ts.isStringLiteralLike(expression) ||
64725             expression.kind === 8 ||
64726             ts.isKeyword(expression.kind) ||
64727             ts.isIdentifier(expression);
64728     }
64729     ts.isSimpleCopiableExpression = isSimpleCopiableExpression;
64730     function isSimpleInlineableExpression(expression) {
64731         return !ts.isIdentifier(expression) && isSimpleCopiableExpression(expression) ||
64732             ts.isWellKnownSymbolSyntactically(expression);
64733     }
64734     ts.isSimpleInlineableExpression = isSimpleInlineableExpression;
64735     function isCompoundAssignment(kind) {
64736         return kind >= 63
64737             && kind <= 74;
64738     }
64739     ts.isCompoundAssignment = isCompoundAssignment;
64740     function getNonAssignmentOperatorForCompoundAssignment(kind) {
64741         switch (kind) {
64742             case 63: return 39;
64743             case 64: return 40;
64744             case 65: return 41;
64745             case 66: return 42;
64746             case 67: return 43;
64747             case 68: return 44;
64748             case 69: return 47;
64749             case 70: return 48;
64750             case 71: return 49;
64751             case 72: return 50;
64752             case 73: return 51;
64753             case 74: return 52;
64754         }
64755     }
64756     ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment;
64757     function addPrologueDirectivesAndInitialSuperCall(ctor, result, visitor) {
64758         if (ctor.body) {
64759             var statements = ctor.body.statements;
64760             var index = ts.addPrologue(result, statements, false, visitor);
64761             if (index === statements.length) {
64762                 return index;
64763             }
64764             var superIndex = ts.findIndex(statements, function (s) { return ts.isExpressionStatement(s) && ts.isSuperCall(s.expression); }, index);
64765             if (superIndex > -1) {
64766                 for (var i = index; i <= superIndex; i++) {
64767                     result.push(ts.visitNode(statements[i], visitor, ts.isStatement));
64768                 }
64769                 return superIndex + 1;
64770             }
64771             return index;
64772         }
64773         return 0;
64774     }
64775     ts.addPrologueDirectivesAndInitialSuperCall = addPrologueDirectivesAndInitialSuperCall;
64776     function helperString(input) {
64777         var args = [];
64778         for (var _i = 1; _i < arguments.length; _i++) {
64779             args[_i - 1] = arguments[_i];
64780         }
64781         return function (uniqueName) {
64782             var result = "";
64783             for (var i = 0; i < args.length; i++) {
64784                 result += input[i];
64785                 result += uniqueName(args[i]);
64786             }
64787             result += input[input.length - 1];
64788             return result;
64789         };
64790     }
64791     ts.helperString = helperString;
64792     function getProperties(node, requireInitializer, isStatic) {
64793         return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); });
64794     }
64795     ts.getProperties = getProperties;
64796     function isInitializedOrStaticProperty(member, requireInitializer, isStatic) {
64797         return ts.isPropertyDeclaration(member)
64798             && (!!member.initializer || !requireInitializer)
64799             && ts.hasStaticModifier(member) === isStatic;
64800     }
64801     function isInitializedProperty(member) {
64802         return member.kind === 159
64803             && member.initializer !== undefined;
64804     }
64805     ts.isInitializedProperty = isInitializedProperty;
64806 })(ts || (ts = {}));
64807 var ts;
64808 (function (ts) {
64809     function flattenDestructuringAssignment(node, visitor, context, level, needsValue, createAssignmentCallback) {
64810         var location = node;
64811         var value;
64812         if (ts.isDestructuringAssignment(node)) {
64813             value = node.right;
64814             while (ts.isEmptyArrayLiteral(node.left) || ts.isEmptyObjectLiteral(node.left)) {
64815                 if (ts.isDestructuringAssignment(value)) {
64816                     location = node = value;
64817                     value = node.right;
64818                 }
64819                 else {
64820                     return ts.visitNode(value, visitor, ts.isExpression);
64821                 }
64822             }
64823         }
64824         var expressions;
64825         var flattenContext = {
64826             context: context,
64827             level: level,
64828             downlevelIteration: !!context.getCompilerOptions().downlevelIteration,
64829             hoistTempVariables: true,
64830             emitExpression: emitExpression,
64831             emitBindingOrAssignment: emitBindingOrAssignment,
64832             createArrayBindingOrAssignmentPattern: makeArrayAssignmentPattern,
64833             createObjectBindingOrAssignmentPattern: makeObjectAssignmentPattern,
64834             createArrayBindingOrAssignmentElement: makeAssignmentElement,
64835             visitor: visitor
64836         };
64837         if (value) {
64838             value = ts.visitNode(value, visitor, ts.isExpression);
64839             if (ts.isIdentifier(value) && bindingOrAssignmentElementAssignsToName(node, value.escapedText) ||
64840                 bindingOrAssignmentElementContainsNonLiteralComputedName(node)) {
64841                 value = ensureIdentifier(flattenContext, value, false, location);
64842             }
64843             else if (needsValue) {
64844                 value = ensureIdentifier(flattenContext, value, true, location);
64845             }
64846             else if (ts.nodeIsSynthesized(node)) {
64847                 location = value;
64848             }
64849         }
64850         flattenBindingOrAssignmentElement(flattenContext, node, value, location, ts.isDestructuringAssignment(node));
64851         if (value && needsValue) {
64852             if (!ts.some(expressions)) {
64853                 return value;
64854             }
64855             expressions.push(value);
64856         }
64857         return ts.aggregateTransformFlags(ts.inlineExpressions(expressions)) || ts.createOmittedExpression();
64858         function emitExpression(expression) {
64859             ts.aggregateTransformFlags(expression);
64860             expressions = ts.append(expressions, expression);
64861         }
64862         function emitBindingOrAssignment(target, value, location, original) {
64863             ts.Debug.assertNode(target, createAssignmentCallback ? ts.isIdentifier : ts.isExpression);
64864             var expression = createAssignmentCallback
64865                 ? createAssignmentCallback(target, value, location)
64866                 : ts.setTextRange(ts.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value), location);
64867             expression.original = original;
64868             emitExpression(expression);
64869         }
64870     }
64871     ts.flattenDestructuringAssignment = flattenDestructuringAssignment;
64872     function bindingOrAssignmentElementAssignsToName(element, escapedName) {
64873         var target = ts.getTargetOfBindingOrAssignmentElement(element);
64874         if (ts.isBindingOrAssignmentPattern(target)) {
64875             return bindingOrAssignmentPatternAssignsToName(target, escapedName);
64876         }
64877         else if (ts.isIdentifier(target)) {
64878             return target.escapedText === escapedName;
64879         }
64880         return false;
64881     }
64882     function bindingOrAssignmentPatternAssignsToName(pattern, escapedName) {
64883         var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
64884         for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) {
64885             var element = elements_3[_i];
64886             if (bindingOrAssignmentElementAssignsToName(element, escapedName)) {
64887                 return true;
64888             }
64889         }
64890         return false;
64891     }
64892     function bindingOrAssignmentElementContainsNonLiteralComputedName(element) {
64893         var propertyName = ts.tryGetPropertyNameOfBindingOrAssignmentElement(element);
64894         if (propertyName && ts.isComputedPropertyName(propertyName) && !ts.isLiteralExpression(propertyName.expression)) {
64895             return true;
64896         }
64897         var target = ts.getTargetOfBindingOrAssignmentElement(element);
64898         return !!target && ts.isBindingOrAssignmentPattern(target) && bindingOrAssignmentPatternContainsNonLiteralComputedName(target);
64899     }
64900     function bindingOrAssignmentPatternContainsNonLiteralComputedName(pattern) {
64901         return !!ts.forEach(ts.getElementsOfBindingOrAssignmentPattern(pattern), bindingOrAssignmentElementContainsNonLiteralComputedName);
64902     }
64903     function flattenDestructuringBinding(node, visitor, context, level, rval, hoistTempVariables, skipInitializer) {
64904         if (hoistTempVariables === void 0) { hoistTempVariables = false; }
64905         var pendingExpressions;
64906         var pendingDeclarations = [];
64907         var declarations = [];
64908         var flattenContext = {
64909             context: context,
64910             level: level,
64911             downlevelIteration: !!context.getCompilerOptions().downlevelIteration,
64912             hoistTempVariables: hoistTempVariables,
64913             emitExpression: emitExpression,
64914             emitBindingOrAssignment: emitBindingOrAssignment,
64915             createArrayBindingOrAssignmentPattern: makeArrayBindingPattern,
64916             createObjectBindingOrAssignmentPattern: makeObjectBindingPattern,
64917             createArrayBindingOrAssignmentElement: makeBindingElement,
64918             visitor: visitor
64919         };
64920         if (ts.isVariableDeclaration(node)) {
64921             var initializer = ts.getInitializerOfBindingOrAssignmentElement(node);
64922             if (initializer && (ts.isIdentifier(initializer) && bindingOrAssignmentElementAssignsToName(node, initializer.escapedText) ||
64923                 bindingOrAssignmentElementContainsNonLiteralComputedName(node))) {
64924                 initializer = ensureIdentifier(flattenContext, initializer, false, initializer);
64925                 node = ts.updateVariableDeclaration(node, node.name, node.type, initializer);
64926             }
64927         }
64928         flattenBindingOrAssignmentElement(flattenContext, node, rval, node, skipInitializer);
64929         if (pendingExpressions) {
64930             var temp = ts.createTempVariable(undefined);
64931             if (hoistTempVariables) {
64932                 var value = ts.inlineExpressions(pendingExpressions);
64933                 pendingExpressions = undefined;
64934                 emitBindingOrAssignment(temp, value, undefined, undefined);
64935             }
64936             else {
64937                 context.hoistVariableDeclaration(temp);
64938                 var pendingDeclaration = ts.last(pendingDeclarations);
64939                 pendingDeclaration.pendingExpressions = ts.append(pendingDeclaration.pendingExpressions, ts.createAssignment(temp, pendingDeclaration.value));
64940                 ts.addRange(pendingDeclaration.pendingExpressions, pendingExpressions);
64941                 pendingDeclaration.value = temp;
64942             }
64943         }
64944         for (var _i = 0, pendingDeclarations_1 = pendingDeclarations; _i < pendingDeclarations_1.length; _i++) {
64945             var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name = _a.name, value = _a.value, location = _a.location, original = _a.original;
64946             var variable = ts.createVariableDeclaration(name, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value);
64947             variable.original = original;
64948             ts.setTextRange(variable, location);
64949             ts.aggregateTransformFlags(variable);
64950             declarations.push(variable);
64951         }
64952         return declarations;
64953         function emitExpression(value) {
64954             pendingExpressions = ts.append(pendingExpressions, value);
64955         }
64956         function emitBindingOrAssignment(target, value, location, original) {
64957             ts.Debug.assertNode(target, ts.isBindingName);
64958             if (pendingExpressions) {
64959                 value = ts.inlineExpressions(ts.append(pendingExpressions, value));
64960                 pendingExpressions = undefined;
64961             }
64962             pendingDeclarations.push({ pendingExpressions: pendingExpressions, name: target, value: value, location: location, original: original });
64963         }
64964     }
64965     ts.flattenDestructuringBinding = flattenDestructuringBinding;
64966     function flattenBindingOrAssignmentElement(flattenContext, element, value, location, skipInitializer) {
64967         if (!skipInitializer) {
64968             var initializer = ts.visitNode(ts.getInitializerOfBindingOrAssignmentElement(element), flattenContext.visitor, ts.isExpression);
64969             if (initializer) {
64970                 value = value ? createDefaultValueCheck(flattenContext, value, initializer, location) : initializer;
64971             }
64972             else if (!value) {
64973                 value = ts.createVoidZero();
64974             }
64975         }
64976         var bindingTarget = ts.getTargetOfBindingOrAssignmentElement(element);
64977         if (ts.isObjectBindingOrAssignmentPattern(bindingTarget)) {
64978             flattenObjectBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location);
64979         }
64980         else if (ts.isArrayBindingOrAssignmentPattern(bindingTarget)) {
64981             flattenArrayBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location);
64982         }
64983         else {
64984             flattenContext.emitBindingOrAssignment(bindingTarget, value, location, element);
64985         }
64986     }
64987     function flattenObjectBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) {
64988         var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
64989         var numElements = elements.length;
64990         if (numElements !== 1) {
64991             var reuseIdentifierExpressions = !ts.isDeclarationBindingElement(parent) || numElements !== 0;
64992             value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location);
64993         }
64994         var bindingElements;
64995         var computedTempVariables;
64996         for (var i = 0; i < numElements; i++) {
64997             var element = elements[i];
64998             if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) {
64999                 var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element);
65000                 if (flattenContext.level >= 1
65001                     && !(element.transformFlags & (8192 | 16384))
65002                     && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (8192 | 16384))
65003                     && !ts.isComputedPropertyName(propertyName)) {
65004                     bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor));
65005                 }
65006                 else {
65007                     if (bindingElements) {
65008                         flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
65009                         bindingElements = undefined;
65010                     }
65011                     var rhsValue = createDestructuringPropertyAccess(flattenContext, value, propertyName);
65012                     if (ts.isComputedPropertyName(propertyName)) {
65013                         computedTempVariables = ts.append(computedTempVariables, rhsValue.argumentExpression);
65014                     }
65015                     flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
65016                 }
65017             }
65018             else if (i === numElements - 1) {
65019                 if (bindingElements) {
65020                     flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
65021                     bindingElements = undefined;
65022                 }
65023                 var rhsValue = createRestCall(flattenContext.context, value, elements, computedTempVariables, pattern);
65024                 flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
65025             }
65026         }
65027         if (bindingElements) {
65028             flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
65029         }
65030     }
65031     function flattenArrayBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) {
65032         var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
65033         var numElements = elements.length;
65034         if (flattenContext.level < 1 && flattenContext.downlevelIteration) {
65035             value = ensureIdentifier(flattenContext, ts.createReadHelper(flattenContext.context, value, numElements > 0 && ts.getRestIndicatorOfBindingOrAssignmentElement(elements[numElements - 1])
65036                 ? undefined
65037                 : numElements, location), false, location);
65038         }
65039         else if (numElements !== 1 && (flattenContext.level < 1 || numElements === 0)
65040             || ts.every(elements, ts.isOmittedExpression)) {
65041             var reuseIdentifierExpressions = !ts.isDeclarationBindingElement(parent) || numElements !== 0;
65042             value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location);
65043         }
65044         var bindingElements;
65045         var restContainingElements;
65046         for (var i = 0; i < numElements; i++) {
65047             var element = elements[i];
65048             if (flattenContext.level >= 1) {
65049                 if (element.transformFlags & 16384) {
65050                     var temp = ts.createTempVariable(undefined);
65051                     if (flattenContext.hoistTempVariables) {
65052                         flattenContext.context.hoistVariableDeclaration(temp);
65053                     }
65054                     restContainingElements = ts.append(restContainingElements, [temp, element]);
65055                     bindingElements = ts.append(bindingElements, flattenContext.createArrayBindingOrAssignmentElement(temp));
65056                 }
65057                 else {
65058                     bindingElements = ts.append(bindingElements, element);
65059                 }
65060             }
65061             else if (ts.isOmittedExpression(element)) {
65062                 continue;
65063             }
65064             else if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) {
65065                 var rhsValue = ts.createElementAccess(value, i);
65066                 flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
65067             }
65068             else if (i === numElements - 1) {
65069                 var rhsValue = ts.createArraySlice(value, i);
65070                 flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
65071             }
65072         }
65073         if (bindingElements) {
65074             flattenContext.emitBindingOrAssignment(flattenContext.createArrayBindingOrAssignmentPattern(bindingElements), value, location, pattern);
65075         }
65076         if (restContainingElements) {
65077             for (var _i = 0, restContainingElements_1 = restContainingElements; _i < restContainingElements_1.length; _i++) {
65078                 var _a = restContainingElements_1[_i], id = _a[0], element = _a[1];
65079                 flattenBindingOrAssignmentElement(flattenContext, element, id, element);
65080             }
65081         }
65082     }
65083     function createDefaultValueCheck(flattenContext, value, defaultValue, location) {
65084         value = ensureIdentifier(flattenContext, value, true, location);
65085         return ts.createConditional(ts.createTypeCheck(value, "undefined"), defaultValue, value);
65086     }
65087     function createDestructuringPropertyAccess(flattenContext, value, propertyName) {
65088         if (ts.isComputedPropertyName(propertyName)) {
65089             var argumentExpression = ensureIdentifier(flattenContext, ts.visitNode(propertyName.expression, flattenContext.visitor), false, propertyName);
65090             return ts.createElementAccess(value, argumentExpression);
65091         }
65092         else if (ts.isStringOrNumericLiteralLike(propertyName)) {
65093             var argumentExpression = ts.getSynthesizedClone(propertyName);
65094             argumentExpression.text = argumentExpression.text;
65095             return ts.createElementAccess(value, argumentExpression);
65096         }
65097         else {
65098             var name = ts.createIdentifier(ts.idText(propertyName));
65099             return ts.createPropertyAccess(value, name);
65100         }
65101     }
65102     function ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location) {
65103         if (ts.isIdentifier(value) && reuseIdentifierExpressions) {
65104             return value;
65105         }
65106         else {
65107             var temp = ts.createTempVariable(undefined);
65108             if (flattenContext.hoistTempVariables) {
65109                 flattenContext.context.hoistVariableDeclaration(temp);
65110                 flattenContext.emitExpression(ts.setTextRange(ts.createAssignment(temp, value), location));
65111             }
65112             else {
65113                 flattenContext.emitBindingOrAssignment(temp, value, location, undefined);
65114             }
65115             return temp;
65116         }
65117     }
65118     function makeArrayBindingPattern(elements) {
65119         ts.Debug.assertEachNode(elements, ts.isArrayBindingElement);
65120         return ts.createArrayBindingPattern(elements);
65121     }
65122     function makeArrayAssignmentPattern(elements) {
65123         return ts.createArrayLiteral(ts.map(elements, ts.convertToArrayAssignmentElement));
65124     }
65125     function makeObjectBindingPattern(elements) {
65126         ts.Debug.assertEachNode(elements, ts.isBindingElement);
65127         return ts.createObjectBindingPattern(elements);
65128     }
65129     function makeObjectAssignmentPattern(elements) {
65130         return ts.createObjectLiteral(ts.map(elements, ts.convertToObjectAssignmentElement));
65131     }
65132     function makeBindingElement(name) {
65133         return ts.createBindingElement(undefined, undefined, name);
65134     }
65135     function makeAssignmentElement(name) {
65136         return name;
65137     }
65138     ts.restHelper = {
65139         name: "typescript:rest",
65140         importName: "__rest",
65141         scoped: false,
65142         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            };"
65143     };
65144     function createRestCall(context, value, elements, computedTempVariables, location) {
65145         context.requestEmitHelper(ts.restHelper);
65146         var propertyNames = [];
65147         var computedTempVariableOffset = 0;
65148         for (var i = 0; i < elements.length - 1; i++) {
65149             var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(elements[i]);
65150             if (propertyName) {
65151                 if (ts.isComputedPropertyName(propertyName)) {
65152                     var temp = computedTempVariables[computedTempVariableOffset];
65153                     computedTempVariableOffset++;
65154                     propertyNames.push(ts.createConditional(ts.createTypeCheck(temp, "symbol"), temp, ts.createAdd(temp, ts.createLiteral(""))));
65155                 }
65156                 else {
65157                     propertyNames.push(ts.createLiteral(propertyName));
65158                 }
65159             }
65160         }
65161         return ts.createCall(ts.getUnscopedHelperName("__rest"), undefined, [
65162             value,
65163             ts.setTextRange(ts.createArrayLiteral(propertyNames), location)
65164         ]);
65165     }
65166 })(ts || (ts = {}));
65167 var ts;
65168 (function (ts) {
65169     var ProcessLevel;
65170     (function (ProcessLevel) {
65171         ProcessLevel[ProcessLevel["LiftRestriction"] = 0] = "LiftRestriction";
65172         ProcessLevel[ProcessLevel["All"] = 1] = "All";
65173     })(ProcessLevel = ts.ProcessLevel || (ts.ProcessLevel = {}));
65174     function processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, level) {
65175         var tag = ts.visitNode(node.tag, visitor, ts.isExpression);
65176         var templateArguments = [undefined];
65177         var cookedStrings = [];
65178         var rawStrings = [];
65179         var template = node.template;
65180         if (level === ProcessLevel.LiftRestriction && !ts.hasInvalidEscape(template))
65181             return node;
65182         if (ts.isNoSubstitutionTemplateLiteral(template)) {
65183             cookedStrings.push(createTemplateCooked(template));
65184             rawStrings.push(getRawLiteral(template, currentSourceFile));
65185         }
65186         else {
65187             cookedStrings.push(createTemplateCooked(template.head));
65188             rawStrings.push(getRawLiteral(template.head, currentSourceFile));
65189             for (var _i = 0, _a = template.templateSpans; _i < _a.length; _i++) {
65190                 var templateSpan = _a[_i];
65191                 cookedStrings.push(createTemplateCooked(templateSpan.literal));
65192                 rawStrings.push(getRawLiteral(templateSpan.literal, currentSourceFile));
65193                 templateArguments.push(ts.visitNode(templateSpan.expression, visitor, ts.isExpression));
65194             }
65195         }
65196         var helperCall = createTemplateObjectHelper(context, ts.createArrayLiteral(cookedStrings), ts.createArrayLiteral(rawStrings));
65197         if (ts.isExternalModule(currentSourceFile)) {
65198             var tempVar = ts.createUniqueName("templateObject");
65199             recordTaggedTemplateString(tempVar);
65200             templateArguments[0] = ts.createLogicalOr(tempVar, ts.createAssignment(tempVar, helperCall));
65201         }
65202         else {
65203             templateArguments[0] = helperCall;
65204         }
65205         return ts.createCall(tag, undefined, templateArguments);
65206     }
65207     ts.processTaggedTemplateExpression = processTaggedTemplateExpression;
65208     function createTemplateCooked(template) {
65209         return template.templateFlags ? ts.createIdentifier("undefined") : ts.createLiteral(template.text);
65210     }
65211     function getRawLiteral(node, currentSourceFile) {
65212         var text = node.rawText;
65213         if (text === undefined) {
65214             text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node);
65215             var isLast = node.kind === 14 || node.kind === 17;
65216             text = text.substring(1, text.length - (isLast ? 1 : 2));
65217         }
65218         text = text.replace(/\r\n?/g, "\n");
65219         return ts.setTextRange(ts.createLiteral(text), node);
65220     }
65221     function createTemplateObjectHelper(context, cooked, raw) {
65222         context.requestEmitHelper(ts.templateObjectHelper);
65223         return ts.createCall(ts.getUnscopedHelperName("__makeTemplateObject"), undefined, [
65224             cooked,
65225             raw
65226         ]);
65227     }
65228     ts.templateObjectHelper = {
65229         name: "typescript:makeTemplateObject",
65230         importName: "__makeTemplateObject",
65231         scoped: false,
65232         priority: 0,
65233         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            };"
65234     };
65235 })(ts || (ts = {}));
65236 var ts;
65237 (function (ts) {
65238     var USE_NEW_TYPE_METADATA_FORMAT = false;
65239     function transformTypeScript(context) {
65240         var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
65241         var resolver = context.getEmitResolver();
65242         var compilerOptions = context.getCompilerOptions();
65243         var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
65244         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
65245         var moduleKind = ts.getEmitModuleKind(compilerOptions);
65246         var previousOnEmitNode = context.onEmitNode;
65247         var previousOnSubstituteNode = context.onSubstituteNode;
65248         context.onEmitNode = onEmitNode;
65249         context.onSubstituteNode = onSubstituteNode;
65250         context.enableSubstitution(194);
65251         context.enableSubstitution(195);
65252         var currentSourceFile;
65253         var currentNamespace;
65254         var currentNamespaceContainerName;
65255         var currentLexicalScope;
65256         var currentNameScope;
65257         var currentScopeFirstDeclarationsOfName;
65258         var currentClassHasParameterProperties;
65259         var enabledSubstitutions;
65260         var classAliases;
65261         var applicableSubstitutions;
65262         return transformSourceFileOrBundle;
65263         function transformSourceFileOrBundle(node) {
65264             if (node.kind === 291) {
65265                 return transformBundle(node);
65266             }
65267             return transformSourceFile(node);
65268         }
65269         function transformBundle(node) {
65270             return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) {
65271                 if (prepend.kind === 293) {
65272                     return ts.createUnparsedSourceFile(prepend, "js");
65273                 }
65274                 return prepend;
65275             }));
65276         }
65277         function transformSourceFile(node) {
65278             if (node.isDeclarationFile) {
65279                 return node;
65280             }
65281             currentSourceFile = node;
65282             var visited = saveStateAndInvoke(node, visitSourceFile);
65283             ts.addEmitHelpers(visited, context.readEmitHelpers());
65284             currentSourceFile = undefined;
65285             return visited;
65286         }
65287         function saveStateAndInvoke(node, f) {
65288             var savedCurrentScope = currentLexicalScope;
65289             var savedCurrentNameScope = currentNameScope;
65290             var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName;
65291             var savedCurrentClassHasParameterProperties = currentClassHasParameterProperties;
65292             onBeforeVisitNode(node);
65293             var visited = f(node);
65294             if (currentLexicalScope !== savedCurrentScope) {
65295                 currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName;
65296             }
65297             currentLexicalScope = savedCurrentScope;
65298             currentNameScope = savedCurrentNameScope;
65299             currentClassHasParameterProperties = savedCurrentClassHasParameterProperties;
65300             return visited;
65301         }
65302         function onBeforeVisitNode(node) {
65303             switch (node.kind) {
65304                 case 290:
65305                 case 251:
65306                 case 250:
65307                 case 223:
65308                     currentLexicalScope = node;
65309                     currentNameScope = undefined;
65310                     currentScopeFirstDeclarationsOfName = undefined;
65311                     break;
65312                 case 245:
65313                 case 244:
65314                     if (ts.hasModifier(node, 2)) {
65315                         break;
65316                     }
65317                     if (node.name) {
65318                         recordEmittedDeclarationInScope(node);
65319                     }
65320                     else {
65321                         ts.Debug.assert(node.kind === 245 || ts.hasModifier(node, 512));
65322                     }
65323                     if (ts.isClassDeclaration(node)) {
65324                         currentNameScope = node;
65325                     }
65326                     break;
65327             }
65328         }
65329         function visitor(node) {
65330             return saveStateAndInvoke(node, visitorWorker);
65331         }
65332         function visitorWorker(node) {
65333             if (node.transformFlags & 1) {
65334                 return visitTypeScript(node);
65335             }
65336             return node;
65337         }
65338         function sourceElementVisitor(node) {
65339             return saveStateAndInvoke(node, sourceElementVisitorWorker);
65340         }
65341         function sourceElementVisitorWorker(node) {
65342             switch (node.kind) {
65343                 case 254:
65344                 case 253:
65345                 case 259:
65346                 case 260:
65347                     return visitEllidableStatement(node);
65348                 default:
65349                     return visitorWorker(node);
65350             }
65351         }
65352         function visitEllidableStatement(node) {
65353             var parsed = ts.getParseTreeNode(node);
65354             if (parsed !== node) {
65355                 if (node.transformFlags & 1) {
65356                     return ts.visitEachChild(node, visitor, context);
65357                 }
65358                 return node;
65359             }
65360             switch (node.kind) {
65361                 case 254:
65362                     return visitImportDeclaration(node);
65363                 case 253:
65364                     return visitImportEqualsDeclaration(node);
65365                 case 259:
65366                     return visitExportAssignment(node);
65367                 case 260:
65368                     return visitExportDeclaration(node);
65369                 default:
65370                     ts.Debug.fail("Unhandled ellided statement");
65371             }
65372         }
65373         function namespaceElementVisitor(node) {
65374             return saveStateAndInvoke(node, namespaceElementVisitorWorker);
65375         }
65376         function namespaceElementVisitorWorker(node) {
65377             if (node.kind === 260 ||
65378                 node.kind === 254 ||
65379                 node.kind === 255 ||
65380                 (node.kind === 253 &&
65381                     node.moduleReference.kind === 265)) {
65382                 return undefined;
65383             }
65384             else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) {
65385                 return visitTypeScript(node);
65386             }
65387             return node;
65388         }
65389         function classElementVisitor(node) {
65390             return saveStateAndInvoke(node, classElementVisitorWorker);
65391         }
65392         function classElementVisitorWorker(node) {
65393             switch (node.kind) {
65394                 case 162:
65395                     return visitConstructor(node);
65396                 case 159:
65397                     return visitPropertyDeclaration(node);
65398                 case 167:
65399                 case 163:
65400                 case 164:
65401                 case 161:
65402                     return visitorWorker(node);
65403                 case 222:
65404                     return node;
65405                 default:
65406                     return ts.Debug.failBadSyntaxKind(node);
65407             }
65408         }
65409         function modifierVisitor(node) {
65410             if (ts.modifierToFlag(node.kind) & 2270) {
65411                 return undefined;
65412             }
65413             else if (currentNamespace && node.kind === 89) {
65414                 return undefined;
65415             }
65416             return node;
65417         }
65418         function visitTypeScript(node) {
65419             if (ts.isStatement(node) && ts.hasModifier(node, 2)) {
65420                 return ts.createNotEmittedStatement(node);
65421             }
65422             switch (node.kind) {
65423                 case 89:
65424                 case 84:
65425                     return currentNamespace ? undefined : node;
65426                 case 119:
65427                 case 117:
65428                 case 118:
65429                 case 122:
65430                 case 81:
65431                 case 130:
65432                 case 138:
65433                 case 174:
65434                 case 175:
65435                 case 176:
65436                 case 177:
65437                 case 173:
65438                 case 168:
65439                 case 155:
65440                 case 125:
65441                 case 148:
65442                 case 128:
65443                 case 143:
65444                 case 140:
65445                 case 137:
65446                 case 110:
65447                 case 144:
65448                 case 171:
65449                 case 170:
65450                 case 172:
65451                 case 169:
65452                 case 178:
65453                 case 179:
65454                 case 180:
65455                 case 182:
65456                 case 183:
65457                 case 184:
65458                 case 185:
65459                 case 186:
65460                 case 187:
65461                 case 167:
65462                 case 157:
65463                 case 247:
65464                     return undefined;
65465                 case 159:
65466                     return visitPropertyDeclaration(node);
65467                 case 252:
65468                     return undefined;
65469                 case 162:
65470                     return visitConstructor(node);
65471                 case 246:
65472                     return ts.createNotEmittedStatement(node);
65473                 case 245:
65474                     return visitClassDeclaration(node);
65475                 case 214:
65476                     return visitClassExpression(node);
65477                 case 279:
65478                     return visitHeritageClause(node);
65479                 case 216:
65480                     return visitExpressionWithTypeArguments(node);
65481                 case 161:
65482                     return visitMethodDeclaration(node);
65483                 case 163:
65484                     return visitGetAccessor(node);
65485                 case 164:
65486                     return visitSetAccessor(node);
65487                 case 244:
65488                     return visitFunctionDeclaration(node);
65489                 case 201:
65490                     return visitFunctionExpression(node);
65491                 case 202:
65492                     return visitArrowFunction(node);
65493                 case 156:
65494                     return visitParameter(node);
65495                 case 200:
65496                     return visitParenthesizedExpression(node);
65497                 case 199:
65498                 case 217:
65499                     return visitAssertionExpression(node);
65500                 case 196:
65501                     return visitCallExpression(node);
65502                 case 197:
65503                     return visitNewExpression(node);
65504                 case 198:
65505                     return visitTaggedTemplateExpression(node);
65506                 case 218:
65507                     return visitNonNullExpression(node);
65508                 case 248:
65509                     return visitEnumDeclaration(node);
65510                 case 225:
65511                     return visitVariableStatement(node);
65512                 case 242:
65513                     return visitVariableDeclaration(node);
65514                 case 249:
65515                     return visitModuleDeclaration(node);
65516                 case 253:
65517                     return visitImportEqualsDeclaration(node);
65518                 case 267:
65519                     return visitJsxSelfClosingElement(node);
65520                 case 268:
65521                     return visitJsxJsxOpeningElement(node);
65522                 default:
65523                     return ts.visitEachChild(node, visitor, context);
65524             }
65525         }
65526         function visitSourceFile(node) {
65527             var alwaysStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") &&
65528                 !(ts.isExternalModule(node) && moduleKind >= ts.ModuleKind.ES2015) &&
65529                 !ts.isJsonSourceFile(node);
65530             return ts.updateSourceFileNode(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, 0, alwaysStrict));
65531         }
65532         function shouldEmitDecorateCallForClass(node) {
65533             if (node.decorators && node.decorators.length > 0) {
65534                 return true;
65535             }
65536             var constructor = ts.getFirstConstructorWithBody(node);
65537             if (constructor) {
65538                 return ts.forEach(constructor.parameters, shouldEmitDecorateCallForParameter);
65539             }
65540             return false;
65541         }
65542         function shouldEmitDecorateCallForParameter(parameter) {
65543             return parameter.decorators !== undefined && parameter.decorators.length > 0;
65544         }
65545         function getClassFacts(node, staticProperties) {
65546             var facts = 0;
65547             if (ts.some(staticProperties))
65548                 facts |= 1;
65549             var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
65550             if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 100)
65551                 facts |= 64;
65552             if (shouldEmitDecorateCallForClass(node))
65553                 facts |= 2;
65554             if (ts.childIsDecorated(node))
65555                 facts |= 4;
65556             if (isExportOfNamespace(node))
65557                 facts |= 8;
65558             else if (isDefaultExternalModuleExport(node))
65559                 facts |= 32;
65560             else if (isNamedExternalModuleExport(node))
65561                 facts |= 16;
65562             if (languageVersion <= 1 && (facts & 7))
65563                 facts |= 128;
65564             return facts;
65565         }
65566         function hasTypeScriptClassSyntax(node) {
65567             return !!(node.transformFlags & 2048);
65568         }
65569         function isClassLikeDeclarationWithTypeScriptSyntax(node) {
65570             return ts.some(node.decorators)
65571                 || ts.some(node.typeParameters)
65572                 || ts.some(node.heritageClauses, hasTypeScriptClassSyntax)
65573                 || ts.some(node.members, hasTypeScriptClassSyntax);
65574         }
65575         function visitClassDeclaration(node) {
65576             if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasModifier(node, 1))) {
65577                 return ts.visitEachChild(node, visitor, context);
65578             }
65579             var staticProperties = ts.getProperties(node, true, true);
65580             var facts = getClassFacts(node, staticProperties);
65581             if (facts & 128) {
65582                 context.startLexicalEnvironment();
65583             }
65584             var name = node.name || (facts & 5 ? ts.getGeneratedNameForNode(node) : undefined);
65585             var classStatement = facts & 2
65586                 ? createClassDeclarationHeadWithDecorators(node, name)
65587                 : createClassDeclarationHeadWithoutDecorators(node, name, facts);
65588             var statements = [classStatement];
65589             addClassElementDecorationStatements(statements, node, false);
65590             addClassElementDecorationStatements(statements, node, true);
65591             addConstructorDecorationStatement(statements, node);
65592             if (facts & 128) {
65593                 var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19);
65594                 var localName = ts.getInternalName(node);
65595                 var outer = ts.createPartiallyEmittedExpression(localName);
65596                 outer.end = closingBraceLocation.end;
65597                 ts.setEmitFlags(outer, 1536);
65598                 var statement = ts.createReturn(outer);
65599                 statement.pos = closingBraceLocation.pos;
65600                 ts.setEmitFlags(statement, 1536 | 384);
65601                 statements.push(statement);
65602                 ts.insertStatementsAfterStandardPrologue(statements, context.endLexicalEnvironment());
65603                 var iife = ts.createImmediatelyInvokedArrowFunction(statements);
65604                 ts.setEmitFlags(iife, 33554432);
65605                 var varStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
65606                     ts.createVariableDeclaration(ts.getLocalName(node, false, false), undefined, iife)
65607                 ]));
65608                 ts.setOriginalNode(varStatement, node);
65609                 ts.setCommentRange(varStatement, node);
65610                 ts.setSourceMapRange(varStatement, ts.moveRangePastDecorators(node));
65611                 ts.startOnNewLine(varStatement);
65612                 statements = [varStatement];
65613             }
65614             if (facts & 8) {
65615                 addExportMemberAssignment(statements, node);
65616             }
65617             else if (facts & 128 || facts & 2) {
65618                 if (facts & 32) {
65619                     statements.push(ts.createExportDefault(ts.getLocalName(node, false, true)));
65620                 }
65621                 else if (facts & 16) {
65622                     statements.push(ts.createExternalModuleExport(ts.getLocalName(node, false, true)));
65623                 }
65624             }
65625             if (statements.length > 1) {
65626                 statements.push(ts.createEndOfDeclarationMarker(node));
65627                 ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304);
65628             }
65629             return ts.singleOrMany(statements);
65630         }
65631         function createClassDeclarationHeadWithoutDecorators(node, name, facts) {
65632             var modifiers = !(facts & 128)
65633                 ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier)
65634                 : undefined;
65635             var classDeclaration = ts.createClassDeclaration(undefined, modifiers, name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
65636             var emitFlags = ts.getEmitFlags(node);
65637             if (facts & 1) {
65638                 emitFlags |= 32;
65639             }
65640             ts.aggregateTransformFlags(classDeclaration);
65641             ts.setTextRange(classDeclaration, node);
65642             ts.setOriginalNode(classDeclaration, node);
65643             ts.setEmitFlags(classDeclaration, emitFlags);
65644             return classDeclaration;
65645         }
65646         function createClassDeclarationHeadWithDecorators(node, name) {
65647             var location = ts.moveRangePastDecorators(node);
65648             var classAlias = getClassAliasIfNeeded(node);
65649             var declName = ts.getLocalName(node, false, true);
65650             var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
65651             var members = transformClassMembers(node);
65652             var classExpression = ts.createClassExpression(undefined, name, undefined, heritageClauses, members);
65653             ts.aggregateTransformFlags(classExpression);
65654             ts.setOriginalNode(classExpression, node);
65655             ts.setTextRange(classExpression, location);
65656             var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
65657                 ts.createVariableDeclaration(declName, undefined, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression)
65658             ], 1));
65659             ts.setOriginalNode(statement, node);
65660             ts.setTextRange(statement, location);
65661             ts.setCommentRange(statement, node);
65662             return statement;
65663         }
65664         function visitClassExpression(node) {
65665             if (!isClassLikeDeclarationWithTypeScriptSyntax(node)) {
65666                 return ts.visitEachChild(node, visitor, context);
65667             }
65668             var classExpression = ts.createClassExpression(undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
65669             ts.aggregateTransformFlags(classExpression);
65670             ts.setOriginalNode(classExpression, node);
65671             ts.setTextRange(classExpression, node);
65672             return classExpression;
65673         }
65674         function transformClassMembers(node) {
65675             var members = [];
65676             var constructor = ts.getFirstConstructorWithBody(node);
65677             var parametersWithPropertyAssignments = constructor &&
65678                 ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); });
65679             if (parametersWithPropertyAssignments) {
65680                 for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) {
65681                     var parameter = parametersWithPropertyAssignments_1[_i];
65682                     if (ts.isIdentifier(parameter.name)) {
65683                         members.push(ts.setOriginalNode(ts.aggregateTransformFlags(ts.createProperty(undefined, undefined, parameter.name, undefined, undefined, undefined)), parameter));
65684                     }
65685                 }
65686             }
65687             ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
65688             return ts.setTextRange(ts.createNodeArray(members), node.members);
65689         }
65690         function getDecoratedClassElements(node, isStatic) {
65691             return ts.filter(node.members, isStatic ? function (m) { return isStaticDecoratedClassElement(m, node); } : function (m) { return isInstanceDecoratedClassElement(m, node); });
65692         }
65693         function isStaticDecoratedClassElement(member, parent) {
65694             return isDecoratedClassElement(member, true, parent);
65695         }
65696         function isInstanceDecoratedClassElement(member, parent) {
65697             return isDecoratedClassElement(member, false, parent);
65698         }
65699         function isDecoratedClassElement(member, isStatic, parent) {
65700             return ts.nodeOrChildIsDecorated(member, parent)
65701                 && isStatic === ts.hasModifier(member, 32);
65702         }
65703         function getDecoratorsOfParameters(node) {
65704             var decorators;
65705             if (node) {
65706                 var parameters = node.parameters;
65707                 var firstParameterIsThis = parameters.length > 0 && ts.parameterIsThisKeyword(parameters[0]);
65708                 var firstParameterOffset = firstParameterIsThis ? 1 : 0;
65709                 var numParameters = firstParameterIsThis ? parameters.length - 1 : parameters.length;
65710                 for (var i = 0; i < numParameters; i++) {
65711                     var parameter = parameters[i + firstParameterOffset];
65712                     if (decorators || parameter.decorators) {
65713                         if (!decorators) {
65714                             decorators = new Array(numParameters);
65715                         }
65716                         decorators[i] = parameter.decorators;
65717                     }
65718                 }
65719             }
65720             return decorators;
65721         }
65722         function getAllDecoratorsOfConstructor(node) {
65723             var decorators = node.decorators;
65724             var parameters = getDecoratorsOfParameters(ts.getFirstConstructorWithBody(node));
65725             if (!decorators && !parameters) {
65726                 return undefined;
65727             }
65728             return {
65729                 decorators: decorators,
65730                 parameters: parameters
65731             };
65732         }
65733         function getAllDecoratorsOfClassElement(node, member) {
65734             switch (member.kind) {
65735                 case 163:
65736                 case 164:
65737                     return getAllDecoratorsOfAccessors(node, member);
65738                 case 161:
65739                     return getAllDecoratorsOfMethod(member);
65740                 case 159:
65741                     return getAllDecoratorsOfProperty(member);
65742                 default:
65743                     return undefined;
65744             }
65745         }
65746         function getAllDecoratorsOfAccessors(node, accessor) {
65747             if (!accessor.body) {
65748                 return undefined;
65749             }
65750             var _a = ts.getAllAccessorDeclarations(node.members, accessor), firstAccessor = _a.firstAccessor, secondAccessor = _a.secondAccessor, setAccessor = _a.setAccessor;
65751             var firstAccessorWithDecorators = firstAccessor.decorators ? firstAccessor : secondAccessor && secondAccessor.decorators ? secondAccessor : undefined;
65752             if (!firstAccessorWithDecorators || accessor !== firstAccessorWithDecorators) {
65753                 return undefined;
65754             }
65755             var decorators = firstAccessorWithDecorators.decorators;
65756             var parameters = getDecoratorsOfParameters(setAccessor);
65757             if (!decorators && !parameters) {
65758                 return undefined;
65759             }
65760             return { decorators: decorators, parameters: parameters };
65761         }
65762         function getAllDecoratorsOfMethod(method) {
65763             if (!method.body) {
65764                 return undefined;
65765             }
65766             var decorators = method.decorators;
65767             var parameters = getDecoratorsOfParameters(method);
65768             if (!decorators && !parameters) {
65769                 return undefined;
65770             }
65771             return { decorators: decorators, parameters: parameters };
65772         }
65773         function getAllDecoratorsOfProperty(property) {
65774             var decorators = property.decorators;
65775             if (!decorators) {
65776                 return undefined;
65777             }
65778             return { decorators: decorators };
65779         }
65780         function transformAllDecoratorsOfDeclaration(node, container, allDecorators) {
65781             if (!allDecorators) {
65782                 return undefined;
65783             }
65784             var decoratorExpressions = [];
65785             ts.addRange(decoratorExpressions, ts.map(allDecorators.decorators, transformDecorator));
65786             ts.addRange(decoratorExpressions, ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter));
65787             addTypeMetadata(node, container, decoratorExpressions);
65788             return decoratorExpressions;
65789         }
65790         function addClassElementDecorationStatements(statements, node, isStatic) {
65791             ts.addRange(statements, ts.map(generateClassElementDecorationExpressions(node, isStatic), expressionToStatement));
65792         }
65793         function generateClassElementDecorationExpressions(node, isStatic) {
65794             var members = getDecoratedClassElements(node, isStatic);
65795             var expressions;
65796             for (var _i = 0, members_6 = members; _i < members_6.length; _i++) {
65797                 var member = members_6[_i];
65798                 var expression = generateClassElementDecorationExpression(node, member);
65799                 if (expression) {
65800                     if (!expressions) {
65801                         expressions = [expression];
65802                     }
65803                     else {
65804                         expressions.push(expression);
65805                     }
65806                 }
65807             }
65808             return expressions;
65809         }
65810         function generateClassElementDecorationExpression(node, member) {
65811             var allDecorators = getAllDecoratorsOfClassElement(node, member);
65812             var decoratorExpressions = transformAllDecoratorsOfDeclaration(member, node, allDecorators);
65813             if (!decoratorExpressions) {
65814                 return undefined;
65815             }
65816             var prefix = getClassMemberPrefix(node, member);
65817             var memberName = getExpressionForPropertyName(member, true);
65818             var descriptor = languageVersion > 0
65819                 ? member.kind === 159
65820                     ? ts.createVoidZero()
65821                     : ts.createNull()
65822                 : undefined;
65823             var helper = createDecorateHelper(context, decoratorExpressions, prefix, memberName, descriptor, ts.moveRangePastDecorators(member));
65824             ts.setEmitFlags(helper, 1536);
65825             return helper;
65826         }
65827         function addConstructorDecorationStatement(statements, node) {
65828             var expression = generateConstructorDecorationExpression(node);
65829             if (expression) {
65830                 statements.push(ts.setOriginalNode(ts.createExpressionStatement(expression), node));
65831             }
65832         }
65833         function generateConstructorDecorationExpression(node) {
65834             var allDecorators = getAllDecoratorsOfConstructor(node);
65835             var decoratorExpressions = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
65836             if (!decoratorExpressions) {
65837                 return undefined;
65838             }
65839             var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)];
65840             var localName = ts.getLocalName(node, false, true);
65841             var decorate = createDecorateHelper(context, decoratorExpressions, localName);
65842             var expression = ts.createAssignment(localName, classAlias ? ts.createAssignment(classAlias, decorate) : decorate);
65843             ts.setEmitFlags(expression, 1536);
65844             ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node));
65845             return expression;
65846         }
65847         function transformDecorator(decorator) {
65848             return ts.visitNode(decorator.expression, visitor, ts.isExpression);
65849         }
65850         function transformDecoratorsOfParameter(decorators, parameterOffset) {
65851             var expressions;
65852             if (decorators) {
65853                 expressions = [];
65854                 for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) {
65855                     var decorator = decorators_1[_i];
65856                     var helper = createParamHelper(context, transformDecorator(decorator), parameterOffset, decorator.expression);
65857                     ts.setEmitFlags(helper, 1536);
65858                     expressions.push(helper);
65859                 }
65860             }
65861             return expressions;
65862         }
65863         function addTypeMetadata(node, container, decoratorExpressions) {
65864             if (USE_NEW_TYPE_METADATA_FORMAT) {
65865                 addNewTypeMetadata(node, container, decoratorExpressions);
65866             }
65867             else {
65868                 addOldTypeMetadata(node, container, decoratorExpressions);
65869             }
65870         }
65871         function addOldTypeMetadata(node, container, decoratorExpressions) {
65872             if (compilerOptions.emitDecoratorMetadata) {
65873                 if (shouldAddTypeMetadata(node)) {
65874                     decoratorExpressions.push(createMetadataHelper(context, "design:type", serializeTypeOfNode(node)));
65875                 }
65876                 if (shouldAddParamTypesMetadata(node)) {
65877                     decoratorExpressions.push(createMetadataHelper(context, "design:paramtypes", serializeParameterTypesOfNode(node, container)));
65878                 }
65879                 if (shouldAddReturnTypeMetadata(node)) {
65880                     decoratorExpressions.push(createMetadataHelper(context, "design:returntype", serializeReturnTypeOfNode(node)));
65881                 }
65882             }
65883         }
65884         function addNewTypeMetadata(node, container, decoratorExpressions) {
65885             if (compilerOptions.emitDecoratorMetadata) {
65886                 var properties = void 0;
65887                 if (shouldAddTypeMetadata(node)) {
65888                     (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(38), serializeTypeOfNode(node))));
65889                 }
65890                 if (shouldAddParamTypesMetadata(node)) {
65891                     (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(38), serializeParameterTypesOfNode(node, container))));
65892                 }
65893                 if (shouldAddReturnTypeMetadata(node)) {
65894                     (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(38), serializeReturnTypeOfNode(node))));
65895                 }
65896                 if (properties) {
65897                     decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, true)));
65898                 }
65899             }
65900         }
65901         function shouldAddTypeMetadata(node) {
65902             var kind = node.kind;
65903             return kind === 161
65904                 || kind === 163
65905                 || kind === 164
65906                 || kind === 159;
65907         }
65908         function shouldAddReturnTypeMetadata(node) {
65909             return node.kind === 161;
65910         }
65911         function shouldAddParamTypesMetadata(node) {
65912             switch (node.kind) {
65913                 case 245:
65914                 case 214:
65915                     return ts.getFirstConstructorWithBody(node) !== undefined;
65916                 case 161:
65917                 case 163:
65918                 case 164:
65919                     return true;
65920             }
65921             return false;
65922         }
65923         function getAccessorTypeNode(node) {
65924             var accessors = resolver.getAllAccessorDeclarations(node);
65925             return accessors.setAccessor && ts.getSetAccessorTypeAnnotationNode(accessors.setAccessor)
65926                 || accessors.getAccessor && ts.getEffectiveReturnTypeNode(accessors.getAccessor);
65927         }
65928         function serializeTypeOfNode(node) {
65929             switch (node.kind) {
65930                 case 159:
65931                 case 156:
65932                     return serializeTypeNode(node.type);
65933                 case 164:
65934                 case 163:
65935                     return serializeTypeNode(getAccessorTypeNode(node));
65936                 case 245:
65937                 case 214:
65938                 case 161:
65939                     return ts.createIdentifier("Function");
65940                 default:
65941                     return ts.createVoidZero();
65942             }
65943         }
65944         function serializeParameterTypesOfNode(node, container) {
65945             var valueDeclaration = ts.isClassLike(node)
65946                 ? ts.getFirstConstructorWithBody(node)
65947                 : ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)
65948                     ? node
65949                     : undefined;
65950             var expressions = [];
65951             if (valueDeclaration) {
65952                 var parameters = getParametersOfDecoratedDeclaration(valueDeclaration, container);
65953                 var numParameters = parameters.length;
65954                 for (var i = 0; i < numParameters; i++) {
65955                     var parameter = parameters[i];
65956                     if (i === 0 && ts.isIdentifier(parameter.name) && parameter.name.escapedText === "this") {
65957                         continue;
65958                     }
65959                     if (parameter.dotDotDotToken) {
65960                         expressions.push(serializeTypeNode(ts.getRestParameterElementType(parameter.type)));
65961                     }
65962                     else {
65963                         expressions.push(serializeTypeOfNode(parameter));
65964                     }
65965                 }
65966             }
65967             return ts.createArrayLiteral(expressions);
65968         }
65969         function getParametersOfDecoratedDeclaration(node, container) {
65970             if (container && node.kind === 163) {
65971                 var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor;
65972                 if (setAccessor) {
65973                     return setAccessor.parameters;
65974                 }
65975             }
65976             return node.parameters;
65977         }
65978         function serializeReturnTypeOfNode(node) {
65979             if (ts.isFunctionLike(node) && node.type) {
65980                 return serializeTypeNode(node.type);
65981             }
65982             else if (ts.isAsyncFunction(node)) {
65983                 return ts.createIdentifier("Promise");
65984             }
65985             return ts.createVoidZero();
65986         }
65987         function serializeTypeNode(node) {
65988             if (node === undefined) {
65989                 return ts.createIdentifier("Object");
65990             }
65991             switch (node.kind) {
65992                 case 110:
65993                 case 146:
65994                 case 100:
65995                 case 137:
65996                     return ts.createVoidZero();
65997                 case 182:
65998                     return serializeTypeNode(node.type);
65999                 case 170:
66000                 case 171:
66001                     return ts.createIdentifier("Function");
66002                 case 174:
66003                 case 175:
66004                     return ts.createIdentifier("Array");
66005                 case 168:
66006                 case 128:
66007                     return ts.createIdentifier("Boolean");
66008                 case 143:
66009                     return ts.createIdentifier("String");
66010                 case 141:
66011                     return ts.createIdentifier("Object");
66012                 case 187:
66013                     switch (node.literal.kind) {
66014                         case 10:
66015                             return ts.createIdentifier("String");
66016                         case 207:
66017                         case 8:
66018                             return ts.createIdentifier("Number");
66019                         case 9:
66020                             return getGlobalBigIntNameWithFallback();
66021                         case 106:
66022                         case 91:
66023                             return ts.createIdentifier("Boolean");
66024                         default:
66025                             return ts.Debug.failBadSyntaxKind(node.literal);
66026                     }
66027                 case 140:
66028                     return ts.createIdentifier("Number");
66029                 case 151:
66030                     return getGlobalBigIntNameWithFallback();
66031                 case 144:
66032                     return languageVersion < 2
66033                         ? getGlobalSymbolNameWithFallback()
66034                         : ts.createIdentifier("Symbol");
66035                 case 169:
66036                     return serializeTypeReferenceNode(node);
66037                 case 179:
66038                 case 178:
66039                     return serializeTypeList(node.types);
66040                 case 180:
66041                     return serializeTypeList([node.trueType, node.falseType]);
66042                 case 184:
66043                     if (node.operator === 138) {
66044                         return serializeTypeNode(node.type);
66045                     }
66046                     break;
66047                 case 172:
66048                 case 185:
66049                 case 186:
66050                 case 173:
66051                 case 125:
66052                 case 148:
66053                 case 183:
66054                 case 188:
66055                     break;
66056                 case 295:
66057                 case 296:
66058                 case 300:
66059                 case 301:
66060                 case 302:
66061                     break;
66062                 case 297:
66063                 case 298:
66064                 case 299:
66065                     return serializeTypeNode(node.type);
66066                 default:
66067                     return ts.Debug.failBadSyntaxKind(node);
66068             }
66069             return ts.createIdentifier("Object");
66070         }
66071         function serializeTypeList(types) {
66072             var serializedUnion;
66073             for (var _i = 0, types_21 = types; _i < types_21.length; _i++) {
66074                 var typeNode = types_21[_i];
66075                 while (typeNode.kind === 182) {
66076                     typeNode = typeNode.type;
66077                 }
66078                 if (typeNode.kind === 137) {
66079                     continue;
66080                 }
66081                 if (!strictNullChecks && (typeNode.kind === 100 || typeNode.kind === 146)) {
66082                     continue;
66083                 }
66084                 var serializedIndividual = serializeTypeNode(typeNode);
66085                 if (ts.isIdentifier(serializedIndividual) && serializedIndividual.escapedText === "Object") {
66086                     return serializedIndividual;
66087                 }
66088                 else if (serializedUnion) {
66089                     if (!ts.isIdentifier(serializedUnion) ||
66090                         !ts.isIdentifier(serializedIndividual) ||
66091                         serializedUnion.escapedText !== serializedIndividual.escapedText) {
66092                         return ts.createIdentifier("Object");
66093                     }
66094                 }
66095                 else {
66096                     serializedUnion = serializedIndividual;
66097                 }
66098             }
66099             return serializedUnion || ts.createVoidZero();
66100         }
66101         function serializeTypeReferenceNode(node) {
66102             var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope);
66103             switch (kind) {
66104                 case ts.TypeReferenceSerializationKind.Unknown:
66105                     if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) {
66106                         return ts.createIdentifier("Object");
66107                     }
66108                     var serialized = serializeEntityNameAsExpressionFallback(node.typeName);
66109                     var temp = ts.createTempVariable(hoistVariableDeclaration);
66110                     return ts.createConditional(ts.createTypeCheck(ts.createAssignment(temp, serialized), "function"), temp, ts.createIdentifier("Object"));
66111                 case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
66112                     return serializeEntityNameAsExpression(node.typeName);
66113                 case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType:
66114                     return ts.createVoidZero();
66115                 case ts.TypeReferenceSerializationKind.BigIntLikeType:
66116                     return getGlobalBigIntNameWithFallback();
66117                 case ts.TypeReferenceSerializationKind.BooleanType:
66118                     return ts.createIdentifier("Boolean");
66119                 case ts.TypeReferenceSerializationKind.NumberLikeType:
66120                     return ts.createIdentifier("Number");
66121                 case ts.TypeReferenceSerializationKind.StringLikeType:
66122                     return ts.createIdentifier("String");
66123                 case ts.TypeReferenceSerializationKind.ArrayLikeType:
66124                     return ts.createIdentifier("Array");
66125                 case ts.TypeReferenceSerializationKind.ESSymbolType:
66126                     return languageVersion < 2
66127                         ? getGlobalSymbolNameWithFallback()
66128                         : ts.createIdentifier("Symbol");
66129                 case ts.TypeReferenceSerializationKind.TypeWithCallSignature:
66130                     return ts.createIdentifier("Function");
66131                 case ts.TypeReferenceSerializationKind.Promise:
66132                     return ts.createIdentifier("Promise");
66133                 case ts.TypeReferenceSerializationKind.ObjectType:
66134                     return ts.createIdentifier("Object");
66135                 default:
66136                     return ts.Debug.assertNever(kind);
66137             }
66138         }
66139         function createCheckedValue(left, right) {
66140             return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(left), ts.createLiteral("undefined")), right);
66141         }
66142         function serializeEntityNameAsExpressionFallback(node) {
66143             if (node.kind === 75) {
66144                 var copied = serializeEntityNameAsExpression(node);
66145                 return createCheckedValue(copied, copied);
66146             }
66147             if (node.left.kind === 75) {
66148                 return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node));
66149             }
66150             var left = serializeEntityNameAsExpressionFallback(node.left);
66151             var temp = ts.createTempVariable(hoistVariableDeclaration);
66152             return ts.createLogicalAnd(ts.createLogicalAnd(left.left, ts.createStrictInequality(ts.createAssignment(temp, left.right), ts.createVoidZero())), ts.createPropertyAccess(temp, node.right));
66153         }
66154         function serializeEntityNameAsExpression(node) {
66155             switch (node.kind) {
66156                 case 75:
66157                     var name = ts.getMutableClone(node);
66158                     name.flags &= ~8;
66159                     name.original = undefined;
66160                     name.parent = ts.getParseTreeNode(currentLexicalScope);
66161                     return name;
66162                 case 153:
66163                     return serializeQualifiedNameAsExpression(node);
66164             }
66165         }
66166         function serializeQualifiedNameAsExpression(node) {
66167             return ts.createPropertyAccess(serializeEntityNameAsExpression(node.left), node.right);
66168         }
66169         function getGlobalSymbolNameWithFallback() {
66170             return ts.createConditional(ts.createTypeCheck(ts.createIdentifier("Symbol"), "function"), ts.createIdentifier("Symbol"), ts.createIdentifier("Object"));
66171         }
66172         function getGlobalBigIntNameWithFallback() {
66173             return languageVersion < 99
66174                 ? ts.createConditional(ts.createTypeCheck(ts.createIdentifier("BigInt"), "function"), ts.createIdentifier("BigInt"), ts.createIdentifier("Object"))
66175                 : ts.createIdentifier("BigInt");
66176         }
66177         function getExpressionForPropertyName(member, generateNameForComputedPropertyName) {
66178             var name = member.name;
66179             if (ts.isPrivateIdentifier(name)) {
66180                 return ts.createIdentifier("");
66181             }
66182             else if (ts.isComputedPropertyName(name)) {
66183                 return generateNameForComputedPropertyName && !ts.isSimpleInlineableExpression(name.expression)
66184                     ? ts.getGeneratedNameForNode(name)
66185                     : name.expression;
66186             }
66187             else if (ts.isIdentifier(name)) {
66188                 return ts.createLiteral(ts.idText(name));
66189             }
66190             else {
66191                 return ts.getSynthesizedClone(name);
66192             }
66193         }
66194         function visitPropertyNameOfClassElement(member) {
66195             var name = member.name;
66196             if (ts.isComputedPropertyName(name) && ((!ts.hasStaticModifier(member) && currentClassHasParameterProperties) || ts.some(member.decorators))) {
66197                 var expression = ts.visitNode(name.expression, visitor, ts.isExpression);
66198                 var innerExpression = ts.skipPartiallyEmittedExpressions(expression);
66199                 if (!ts.isSimpleInlineableExpression(innerExpression)) {
66200                     var generatedName = ts.getGeneratedNameForNode(name);
66201                     hoistVariableDeclaration(generatedName);
66202                     return ts.updateComputedPropertyName(name, ts.createAssignment(generatedName, expression));
66203                 }
66204             }
66205             return ts.visitNode(name, visitor, ts.isPropertyName);
66206         }
66207         function visitHeritageClause(node) {
66208             if (node.token === 113) {
66209                 return undefined;
66210             }
66211             return ts.visitEachChild(node, visitor, context);
66212         }
66213         function visitExpressionWithTypeArguments(node) {
66214             return ts.updateExpressionWithTypeArguments(node, undefined, ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression));
66215         }
66216         function shouldEmitFunctionLikeDeclaration(node) {
66217             return !ts.nodeIsMissing(node.body);
66218         }
66219         function visitPropertyDeclaration(node) {
66220             if (node.flags & 8388608) {
66221                 return undefined;
66222             }
66223             var updated = ts.updateProperty(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), undefined, undefined, ts.visitNode(node.initializer, visitor));
66224             if (updated !== node) {
66225                 ts.setCommentRange(updated, node);
66226                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
66227             }
66228             return updated;
66229         }
66230         function visitConstructor(node) {
66231             if (!shouldEmitFunctionLikeDeclaration(node)) {
66232                 return undefined;
66233             }
66234             return ts.updateConstructor(node, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), transformConstructorBody(node.body, node));
66235         }
66236         function transformConstructorBody(body, constructor) {
66237             var parametersWithPropertyAssignments = constructor &&
66238                 ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); });
66239             if (!ts.some(parametersWithPropertyAssignments)) {
66240                 return ts.visitFunctionBody(body, visitor, context);
66241             }
66242             var statements = [];
66243             var indexOfFirstStatement = 0;
66244             resumeLexicalEnvironment();
66245             indexOfFirstStatement = ts.addPrologueDirectivesAndInitialSuperCall(constructor, statements, visitor);
66246             ts.addRange(statements, ts.map(parametersWithPropertyAssignments, transformParameterWithPropertyAssignment));
66247             ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexOfFirstStatement));
66248             statements = ts.mergeLexicalEnvironment(statements, endLexicalEnvironment());
66249             var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), body.statements), true);
66250             ts.setTextRange(block, body);
66251             ts.setOriginalNode(block, body);
66252             return block;
66253         }
66254         function transformParameterWithPropertyAssignment(node) {
66255             var name = node.name;
66256             if (!ts.isIdentifier(name)) {
66257                 return undefined;
66258             }
66259             var propertyName = ts.getMutableClone(name);
66260             ts.setEmitFlags(propertyName, 1536 | 48);
66261             var localName = ts.getMutableClone(name);
66262             ts.setEmitFlags(localName, 1536);
66263             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))));
66264         }
66265         function visitMethodDeclaration(node) {
66266             if (!shouldEmitFunctionLikeDeclaration(node)) {
66267                 return undefined;
66268             }
66269             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));
66270             if (updated !== node) {
66271                 ts.setCommentRange(updated, node);
66272                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
66273             }
66274             return updated;
66275         }
66276         function shouldEmitAccessorDeclaration(node) {
66277             return !(ts.nodeIsMissing(node.body) && ts.hasModifier(node, 128));
66278         }
66279         function visitGetAccessor(node) {
66280             if (!shouldEmitAccessorDeclaration(node)) {
66281                 return undefined;
66282             }
66283             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([]));
66284             if (updated !== node) {
66285                 ts.setCommentRange(updated, node);
66286                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
66287             }
66288             return updated;
66289         }
66290         function visitSetAccessor(node) {
66291             if (!shouldEmitAccessorDeclaration(node)) {
66292                 return undefined;
66293             }
66294             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([]));
66295             if (updated !== node) {
66296                 ts.setCommentRange(updated, node);
66297                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
66298             }
66299             return updated;
66300         }
66301         function visitFunctionDeclaration(node) {
66302             if (!shouldEmitFunctionLikeDeclaration(node)) {
66303                 return ts.createNotEmittedStatement(node);
66304             }
66305             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([]));
66306             if (isExportOfNamespace(node)) {
66307                 var statements = [updated];
66308                 addExportMemberAssignment(statements, node);
66309                 return statements;
66310             }
66311             return updated;
66312         }
66313         function visitFunctionExpression(node) {
66314             if (!shouldEmitFunctionLikeDeclaration(node)) {
66315                 return ts.createOmittedExpression();
66316             }
66317             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([]));
66318             return updated;
66319         }
66320         function visitArrowFunction(node) {
66321             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));
66322             return updated;
66323         }
66324         function visitParameter(node) {
66325             if (ts.parameterIsThisKeyword(node)) {
66326                 return undefined;
66327             }
66328             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));
66329             if (updated !== node) {
66330                 ts.setCommentRange(updated, node);
66331                 ts.setTextRange(updated, ts.moveRangePastModifiers(node));
66332                 ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node));
66333                 ts.setEmitFlags(updated.name, 32);
66334             }
66335             return updated;
66336         }
66337         function visitVariableStatement(node) {
66338             if (isExportOfNamespace(node)) {
66339                 var variables = ts.getInitializedVariables(node.declarationList);
66340                 if (variables.length === 0) {
66341                     return undefined;
66342                 }
66343                 return ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node);
66344             }
66345             else {
66346                 return ts.visitEachChild(node, visitor, context);
66347             }
66348         }
66349         function transformInitializedVariable(node) {
66350             var name = node.name;
66351             if (ts.isBindingPattern(name)) {
66352                 return ts.flattenDestructuringAssignment(node, visitor, context, 0, false, createNamespaceExportExpression);
66353             }
66354             else {
66355                 return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression)), node);
66356             }
66357         }
66358         function visitVariableDeclaration(node) {
66359             return ts.updateTypeScriptVariableDeclaration(node, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
66360         }
66361         function visitParenthesizedExpression(node) {
66362             var innerExpression = ts.skipOuterExpressions(node.expression, ~6);
66363             if (ts.isAssertionExpression(innerExpression)) {
66364                 var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
66365                 if (ts.length(ts.getLeadingCommentRangesOfNode(expression, currentSourceFile))) {
66366                     return ts.updateParen(node, expression);
66367                 }
66368                 return ts.createPartiallyEmittedExpression(expression, node);
66369             }
66370             return ts.visitEachChild(node, visitor, context);
66371         }
66372         function visitAssertionExpression(node) {
66373             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
66374             return ts.createPartiallyEmittedExpression(expression, node);
66375         }
66376         function visitNonNullExpression(node) {
66377             var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression);
66378             return ts.createPartiallyEmittedExpression(expression, node);
66379         }
66380         function visitCallExpression(node) {
66381             return ts.updateCall(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression));
66382         }
66383         function visitNewExpression(node) {
66384             return ts.updateNew(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression));
66385         }
66386         function visitTaggedTemplateExpression(node) {
66387             return ts.updateTaggedTemplate(node, ts.visitNode(node.tag, visitor, ts.isExpression), undefined, ts.visitNode(node.template, visitor, ts.isExpression));
66388         }
66389         function visitJsxSelfClosingElement(node) {
66390             return ts.updateJsxSelfClosingElement(node, ts.visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), undefined, ts.visitNode(node.attributes, visitor, ts.isJsxAttributes));
66391         }
66392         function visitJsxJsxOpeningElement(node) {
66393             return ts.updateJsxOpeningElement(node, ts.visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), undefined, ts.visitNode(node.attributes, visitor, ts.isJsxAttributes));
66394         }
66395         function shouldEmitEnumDeclaration(node) {
66396             return !ts.isEnumConst(node)
66397                 || compilerOptions.preserveConstEnums
66398                 || compilerOptions.isolatedModules;
66399         }
66400         function visitEnumDeclaration(node) {
66401             if (!shouldEmitEnumDeclaration(node)) {
66402                 return ts.createNotEmittedStatement(node);
66403             }
66404             var statements = [];
66405             var emitFlags = 2;
66406             var varAdded = addVarForEnumOrModuleDeclaration(statements, node);
66407             if (varAdded) {
66408                 if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) {
66409                     emitFlags |= 512;
66410                 }
66411             }
66412             var parameterName = getNamespaceParameterName(node);
66413             var containerName = getNamespaceContainerName(node);
66414             var exportName = ts.hasModifier(node, 1)
66415                 ? ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true)
66416                 : ts.getLocalName(node, false, true);
66417             var moduleArg = ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()));
66418             if (hasNamespaceQualifiedExportName(node)) {
66419                 var localName = ts.getLocalName(node, false, true);
66420                 moduleArg = ts.createAssignment(localName, moduleArg);
66421             }
66422             var enumStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg]));
66423             ts.setOriginalNode(enumStatement, node);
66424             if (varAdded) {
66425                 ts.setSyntheticLeadingComments(enumStatement, undefined);
66426                 ts.setSyntheticTrailingComments(enumStatement, undefined);
66427             }
66428             ts.setTextRange(enumStatement, node);
66429             ts.addEmitFlags(enumStatement, emitFlags);
66430             statements.push(enumStatement);
66431             statements.push(ts.createEndOfDeclarationMarker(node));
66432             return statements;
66433         }
66434         function transformEnumBody(node, localName) {
66435             var savedCurrentNamespaceLocalName = currentNamespaceContainerName;
66436             currentNamespaceContainerName = localName;
66437             var statements = [];
66438             startLexicalEnvironment();
66439             var members = ts.map(node.members, transformEnumMember);
66440             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
66441             ts.addRange(statements, members);
66442             currentNamespaceContainerName = savedCurrentNamespaceLocalName;
66443             return ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), node.members), true);
66444         }
66445         function transformEnumMember(member) {
66446             var name = getExpressionForPropertyName(member, false);
66447             var valueExpression = transformEnumMemberDeclarationValue(member);
66448             var innerAssignment = ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, name), valueExpression);
66449             var outerAssignment = valueExpression.kind === 10 ?
66450                 innerAssignment :
66451                 ts.createAssignment(ts.createElementAccess(currentNamespaceContainerName, innerAssignment), name);
66452             return ts.setTextRange(ts.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member);
66453         }
66454         function transformEnumMemberDeclarationValue(member) {
66455             var value = resolver.getConstantValue(member);
66456             if (value !== undefined) {
66457                 return ts.createLiteral(value);
66458             }
66459             else {
66460                 enableSubstitutionForNonQualifiedEnumMembers();
66461                 if (member.initializer) {
66462                     return ts.visitNode(member.initializer, visitor, ts.isExpression);
66463                 }
66464                 else {
66465                     return ts.createVoidZero();
66466                 }
66467             }
66468         }
66469         function shouldEmitModuleDeclaration(nodeIn) {
66470             var node = ts.getParseTreeNode(nodeIn, ts.isModuleDeclaration);
66471             if (!node) {
66472                 return true;
66473             }
66474             return ts.isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules);
66475         }
66476         function hasNamespaceQualifiedExportName(node) {
66477             return isExportOfNamespace(node)
66478                 || (isExternalModuleExport(node)
66479                     && moduleKind !== ts.ModuleKind.ES2015
66480                     && moduleKind !== ts.ModuleKind.ES2020
66481                     && moduleKind !== ts.ModuleKind.ESNext
66482                     && moduleKind !== ts.ModuleKind.System);
66483         }
66484         function recordEmittedDeclarationInScope(node) {
66485             if (!currentScopeFirstDeclarationsOfName) {
66486                 currentScopeFirstDeclarationsOfName = ts.createUnderscoreEscapedMap();
66487             }
66488             var name = declaredNameInScope(node);
66489             if (!currentScopeFirstDeclarationsOfName.has(name)) {
66490                 currentScopeFirstDeclarationsOfName.set(name, node);
66491             }
66492         }
66493         function isFirstEmittedDeclarationInScope(node) {
66494             if (currentScopeFirstDeclarationsOfName) {
66495                 var name = declaredNameInScope(node);
66496                 return currentScopeFirstDeclarationsOfName.get(name) === node;
66497             }
66498             return true;
66499         }
66500         function declaredNameInScope(node) {
66501             ts.Debug.assertNode(node.name, ts.isIdentifier);
66502             return node.name.escapedText;
66503         }
66504         function addVarForEnumOrModuleDeclaration(statements, node) {
66505             var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([
66506                 ts.createVariableDeclaration(ts.getLocalName(node, false, true))
66507             ], currentLexicalScope.kind === 290 ? 0 : 1));
66508             ts.setOriginalNode(statement, node);
66509             recordEmittedDeclarationInScope(node);
66510             if (isFirstEmittedDeclarationInScope(node)) {
66511                 if (node.kind === 248) {
66512                     ts.setSourceMapRange(statement.declarationList, node);
66513                 }
66514                 else {
66515                     ts.setSourceMapRange(statement, node);
66516                 }
66517                 ts.setCommentRange(statement, node);
66518                 ts.addEmitFlags(statement, 1024 | 4194304);
66519                 statements.push(statement);
66520                 return true;
66521             }
66522             else {
66523                 var mergeMarker = ts.createMergeDeclarationMarker(statement);
66524                 ts.setEmitFlags(mergeMarker, 1536 | 4194304);
66525                 statements.push(mergeMarker);
66526                 return false;
66527             }
66528         }
66529         function visitModuleDeclaration(node) {
66530             if (!shouldEmitModuleDeclaration(node)) {
66531                 return ts.createNotEmittedStatement(node);
66532             }
66533             ts.Debug.assertNode(node.name, ts.isIdentifier, "A TypeScript namespace should have an Identifier name.");
66534             enableSubstitutionForNamespaceExports();
66535             var statements = [];
66536             var emitFlags = 2;
66537             var varAdded = addVarForEnumOrModuleDeclaration(statements, node);
66538             if (varAdded) {
66539                 if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) {
66540                     emitFlags |= 512;
66541                 }
66542             }
66543             var parameterName = getNamespaceParameterName(node);
66544             var containerName = getNamespaceContainerName(node);
66545             var exportName = ts.hasModifier(node, 1)
66546                 ? ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true)
66547                 : ts.getLocalName(node, false, true);
66548             var moduleArg = ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()));
66549             if (hasNamespaceQualifiedExportName(node)) {
66550                 var localName = ts.getLocalName(node, false, true);
66551                 moduleArg = ts.createAssignment(localName, moduleArg);
66552             }
66553             var moduleStatement = ts.createExpressionStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]));
66554             ts.setOriginalNode(moduleStatement, node);
66555             if (varAdded) {
66556                 ts.setSyntheticLeadingComments(moduleStatement, undefined);
66557                 ts.setSyntheticTrailingComments(moduleStatement, undefined);
66558             }
66559             ts.setTextRange(moduleStatement, node);
66560             ts.addEmitFlags(moduleStatement, emitFlags);
66561             statements.push(moduleStatement);
66562             statements.push(ts.createEndOfDeclarationMarker(node));
66563             return statements;
66564         }
66565         function transformModuleBody(node, namespaceLocalName) {
66566             var savedCurrentNamespaceContainerName = currentNamespaceContainerName;
66567             var savedCurrentNamespace = currentNamespace;
66568             var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName;
66569             currentNamespaceContainerName = namespaceLocalName;
66570             currentNamespace = node;
66571             currentScopeFirstDeclarationsOfName = undefined;
66572             var statements = [];
66573             startLexicalEnvironment();
66574             var statementsLocation;
66575             var blockLocation;
66576             if (node.body) {
66577                 if (node.body.kind === 250) {
66578                     saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); });
66579                     statementsLocation = node.body.statements;
66580                     blockLocation = node.body;
66581                 }
66582                 else {
66583                     var result = visitModuleDeclaration(node.body);
66584                     if (result) {
66585                         if (ts.isArray(result)) {
66586                             ts.addRange(statements, result);
66587                         }
66588                         else {
66589                             statements.push(result);
66590                         }
66591                     }
66592                     var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body;
66593                     statementsLocation = ts.moveRangePos(moduleBlock.statements, -1);
66594                 }
66595             }
66596             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
66597             currentNamespaceContainerName = savedCurrentNamespaceContainerName;
66598             currentNamespace = savedCurrentNamespace;
66599             currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName;
66600             var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true);
66601             ts.setTextRange(block, blockLocation);
66602             if (!node.body || node.body.kind !== 250) {
66603                 ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536);
66604             }
66605             return block;
66606         }
66607         function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) {
66608             if (moduleDeclaration.body.kind === 249) {
66609                 var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body);
66610                 return recursiveInnerModule || moduleDeclaration.body;
66611             }
66612         }
66613         function visitImportDeclaration(node) {
66614             if (!node.importClause) {
66615                 return node;
66616             }
66617             if (node.importClause.isTypeOnly) {
66618                 return undefined;
66619             }
66620             var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause);
66621             return importClause ||
66622                 compilerOptions.importsNotUsedAsValues === 1 ||
66623                 compilerOptions.importsNotUsedAsValues === 2
66624                 ? ts.updateImportDeclaration(node, undefined, undefined, importClause, node.moduleSpecifier)
66625                 : undefined;
66626         }
66627         function visitImportClause(node) {
66628             if (node.isTypeOnly) {
66629                 return undefined;
66630             }
66631             var name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined;
66632             var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings);
66633             return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings, false) : undefined;
66634         }
66635         function visitNamedImportBindings(node) {
66636             if (node.kind === 256) {
66637                 return resolver.isReferencedAliasDeclaration(node) ? node : undefined;
66638             }
66639             else {
66640                 var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier);
66641                 return ts.some(elements) ? ts.updateNamedImports(node, elements) : undefined;
66642             }
66643         }
66644         function visitImportSpecifier(node) {
66645             return resolver.isReferencedAliasDeclaration(node) ? node : undefined;
66646         }
66647         function visitExportAssignment(node) {
66648             return resolver.isValueAliasDeclaration(node)
66649                 ? ts.visitEachChild(node, visitor, context)
66650                 : undefined;
66651         }
66652         function visitExportDeclaration(node) {
66653             if (node.isTypeOnly) {
66654                 return undefined;
66655             }
66656             if (!node.exportClause || ts.isNamespaceExport(node.exportClause)) {
66657                 return node;
66658             }
66659             if (!resolver.isValueAliasDeclaration(node)) {
66660                 return undefined;
66661             }
66662             var exportClause = ts.visitNode(node.exportClause, visitNamedExportBindings, ts.isNamedExportBindings);
66663             return exportClause
66664                 ? ts.updateExportDeclaration(node, undefined, undefined, exportClause, node.moduleSpecifier, node.isTypeOnly)
66665                 : undefined;
66666         }
66667         function visitNamedExports(node) {
66668             var elements = ts.visitNodes(node.elements, visitExportSpecifier, ts.isExportSpecifier);
66669             return ts.some(elements) ? ts.updateNamedExports(node, elements) : undefined;
66670         }
66671         function visitNamespaceExports(node) {
66672             return ts.updateNamespaceExport(node, ts.visitNode(node.name, visitor, ts.isIdentifier));
66673         }
66674         function visitNamedExportBindings(node) {
66675             return ts.isNamespaceExport(node) ? visitNamespaceExports(node) : visitNamedExports(node);
66676         }
66677         function visitExportSpecifier(node) {
66678             return resolver.isValueAliasDeclaration(node) ? node : undefined;
66679         }
66680         function shouldEmitImportEqualsDeclaration(node) {
66681             return resolver.isReferencedAliasDeclaration(node)
66682                 || (!ts.isExternalModule(currentSourceFile)
66683                     && resolver.isTopLevelValueImportEqualsWithEntityName(node));
66684         }
66685         function visitImportEqualsDeclaration(node) {
66686             if (ts.isExternalModuleImportEqualsDeclaration(node)) {
66687                 var isReferenced = resolver.isReferencedAliasDeclaration(node);
66688                 if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1) {
66689                     return ts.setOriginalNode(ts.setTextRange(ts.createImportDeclaration(undefined, undefined, undefined, node.moduleReference.expression), node), node);
66690                 }
66691                 return isReferenced ? ts.visitEachChild(node, visitor, context) : undefined;
66692             }
66693             if (!shouldEmitImportEqualsDeclaration(node)) {
66694                 return undefined;
66695             }
66696             var moduleReference = ts.createExpressionFromEntityName(node.moduleReference);
66697             ts.setEmitFlags(moduleReference, 1536 | 2048);
66698             if (isNamedExternalModuleExport(node) || !isExportOfNamespace(node)) {
66699                 return ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([
66700                     ts.setOriginalNode(ts.createVariableDeclaration(node.name, undefined, moduleReference), node)
66701                 ])), node), node);
66702             }
66703             else {
66704                 return ts.setOriginalNode(createNamespaceExport(node.name, moduleReference, node), node);
66705             }
66706         }
66707         function isExportOfNamespace(node) {
66708             return currentNamespace !== undefined && ts.hasModifier(node, 1);
66709         }
66710         function isExternalModuleExport(node) {
66711             return currentNamespace === undefined && ts.hasModifier(node, 1);
66712         }
66713         function isNamedExternalModuleExport(node) {
66714             return isExternalModuleExport(node)
66715                 && !ts.hasModifier(node, 512);
66716         }
66717         function isDefaultExternalModuleExport(node) {
66718             return isExternalModuleExport(node)
66719                 && ts.hasModifier(node, 512);
66720         }
66721         function expressionToStatement(expression) {
66722             return ts.createExpressionStatement(expression);
66723         }
66724         function addExportMemberAssignment(statements, node) {
66725             var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true), ts.getLocalName(node));
66726             ts.setSourceMapRange(expression, ts.createRange(node.name ? node.name.pos : node.pos, node.end));
66727             var statement = ts.createExpressionStatement(expression);
66728             ts.setSourceMapRange(statement, ts.createRange(-1, node.end));
66729             statements.push(statement);
66730         }
66731         function createNamespaceExport(exportName, exportValue, location) {
66732             return ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue)), location);
66733         }
66734         function createNamespaceExportExpression(exportName, exportValue, location) {
66735             return ts.setTextRange(ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location);
66736         }
66737         function getNamespaceMemberNameWithSourceMapsAndWithoutComments(name) {
66738             return ts.getNamespaceMemberName(currentNamespaceContainerName, name, false, true);
66739         }
66740         function getNamespaceParameterName(node) {
66741             var name = ts.getGeneratedNameForNode(node);
66742             ts.setSourceMapRange(name, node.name);
66743             return name;
66744         }
66745         function getNamespaceContainerName(node) {
66746             return ts.getGeneratedNameForNode(node);
66747         }
66748         function getClassAliasIfNeeded(node) {
66749             if (resolver.getNodeCheckFlags(node) & 16777216) {
66750                 enableSubstitutionForClassAliases();
66751                 var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default");
66752                 classAliases[ts.getOriginalNodeId(node)] = classAlias;
66753                 hoistVariableDeclaration(classAlias);
66754                 return classAlias;
66755             }
66756         }
66757         function getClassPrototype(node) {
66758             return ts.createPropertyAccess(ts.getDeclarationName(node), "prototype");
66759         }
66760         function getClassMemberPrefix(node, member) {
66761             return ts.hasModifier(member, 32)
66762                 ? ts.getDeclarationName(node)
66763                 : getClassPrototype(node);
66764         }
66765         function enableSubstitutionForNonQualifiedEnumMembers() {
66766             if ((enabledSubstitutions & 8) === 0) {
66767                 enabledSubstitutions |= 8;
66768                 context.enableSubstitution(75);
66769             }
66770         }
66771         function enableSubstitutionForClassAliases() {
66772             if ((enabledSubstitutions & 1) === 0) {
66773                 enabledSubstitutions |= 1;
66774                 context.enableSubstitution(75);
66775                 classAliases = [];
66776             }
66777         }
66778         function enableSubstitutionForNamespaceExports() {
66779             if ((enabledSubstitutions & 2) === 0) {
66780                 enabledSubstitutions |= 2;
66781                 context.enableSubstitution(75);
66782                 context.enableSubstitution(282);
66783                 context.enableEmitNotification(249);
66784             }
66785         }
66786         function isTransformedModuleDeclaration(node) {
66787             return ts.getOriginalNode(node).kind === 249;
66788         }
66789         function isTransformedEnumDeclaration(node) {
66790             return ts.getOriginalNode(node).kind === 248;
66791         }
66792         function onEmitNode(hint, node, emitCallback) {
66793             var savedApplicableSubstitutions = applicableSubstitutions;
66794             var savedCurrentSourceFile = currentSourceFile;
66795             if (ts.isSourceFile(node)) {
66796                 currentSourceFile = node;
66797             }
66798             if (enabledSubstitutions & 2 && isTransformedModuleDeclaration(node)) {
66799                 applicableSubstitutions |= 2;
66800             }
66801             if (enabledSubstitutions & 8 && isTransformedEnumDeclaration(node)) {
66802                 applicableSubstitutions |= 8;
66803             }
66804             previousOnEmitNode(hint, node, emitCallback);
66805             applicableSubstitutions = savedApplicableSubstitutions;
66806             currentSourceFile = savedCurrentSourceFile;
66807         }
66808         function onSubstituteNode(hint, node) {
66809             node = previousOnSubstituteNode(hint, node);
66810             if (hint === 1) {
66811                 return substituteExpression(node);
66812             }
66813             else if (ts.isShorthandPropertyAssignment(node)) {
66814                 return substituteShorthandPropertyAssignment(node);
66815             }
66816             return node;
66817         }
66818         function substituteShorthandPropertyAssignment(node) {
66819             if (enabledSubstitutions & 2) {
66820                 var name = node.name;
66821                 var exportedName = trySubstituteNamespaceExportedName(name);
66822                 if (exportedName) {
66823                     if (node.objectAssignmentInitializer) {
66824                         var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer);
66825                         return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node);
66826                     }
66827                     return ts.setTextRange(ts.createPropertyAssignment(name, exportedName), node);
66828                 }
66829             }
66830             return node;
66831         }
66832         function substituteExpression(node) {
66833             switch (node.kind) {
66834                 case 75:
66835                     return substituteExpressionIdentifier(node);
66836                 case 194:
66837                     return substitutePropertyAccessExpression(node);
66838                 case 195:
66839                     return substituteElementAccessExpression(node);
66840             }
66841             return node;
66842         }
66843         function substituteExpressionIdentifier(node) {
66844             return trySubstituteClassAlias(node)
66845                 || trySubstituteNamespaceExportedName(node)
66846                 || node;
66847         }
66848         function trySubstituteClassAlias(node) {
66849             if (enabledSubstitutions & 1) {
66850                 if (resolver.getNodeCheckFlags(node) & 33554432) {
66851                     var declaration = resolver.getReferencedValueDeclaration(node);
66852                     if (declaration) {
66853                         var classAlias = classAliases[declaration.id];
66854                         if (classAlias) {
66855                             var clone_1 = ts.getSynthesizedClone(classAlias);
66856                             ts.setSourceMapRange(clone_1, node);
66857                             ts.setCommentRange(clone_1, node);
66858                             return clone_1;
66859                         }
66860                     }
66861                 }
66862             }
66863             return undefined;
66864         }
66865         function trySubstituteNamespaceExportedName(node) {
66866             if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) {
66867                 var container = resolver.getReferencedExportContainer(node, false);
66868                 if (container && container.kind !== 290) {
66869                     var substitute = (applicableSubstitutions & 2 && container.kind === 249) ||
66870                         (applicableSubstitutions & 8 && container.kind === 248);
66871                     if (substitute) {
66872                         return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), node);
66873                     }
66874                 }
66875             }
66876             return undefined;
66877         }
66878         function substitutePropertyAccessExpression(node) {
66879             return substituteConstantValue(node);
66880         }
66881         function substituteElementAccessExpression(node) {
66882             return substituteConstantValue(node);
66883         }
66884         function substituteConstantValue(node) {
66885             var constantValue = tryGetConstEnumValue(node);
66886             if (constantValue !== undefined) {
66887                 ts.setConstantValue(node, constantValue);
66888                 var substitute = ts.createLiteral(constantValue);
66889                 if (!compilerOptions.removeComments) {
66890                     var originalNode = ts.getOriginalNode(node, ts.isAccessExpression);
66891                     var propertyName = ts.isPropertyAccessExpression(originalNode)
66892                         ? ts.declarationNameToString(originalNode.name)
66893                         : ts.getTextOfNode(originalNode.argumentExpression);
66894                     ts.addSyntheticTrailingComment(substitute, 3, " " + propertyName + " ");
66895                 }
66896                 return substitute;
66897             }
66898             return node;
66899         }
66900         function tryGetConstEnumValue(node) {
66901             if (compilerOptions.isolatedModules) {
66902                 return undefined;
66903             }
66904             return ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) ? resolver.getConstantValue(node) : undefined;
66905         }
66906     }
66907     ts.transformTypeScript = transformTypeScript;
66908     function createDecorateHelper(context, decoratorExpressions, target, memberName, descriptor, location) {
66909         var argumentsArray = [];
66910         argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, true));
66911         argumentsArray.push(target);
66912         if (memberName) {
66913             argumentsArray.push(memberName);
66914             if (descriptor) {
66915                 argumentsArray.push(descriptor);
66916             }
66917         }
66918         context.requestEmitHelper(ts.decorateHelper);
66919         return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__decorate"), undefined, argumentsArray), location);
66920     }
66921     ts.decorateHelper = {
66922         name: "typescript:decorate",
66923         importName: "__decorate",
66924         scoped: false,
66925         priority: 2,
66926         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            };"
66927     };
66928     function createMetadataHelper(context, metadataKey, metadataValue) {
66929         context.requestEmitHelper(ts.metadataHelper);
66930         return ts.createCall(ts.getUnscopedHelperName("__metadata"), undefined, [
66931             ts.createLiteral(metadataKey),
66932             metadataValue
66933         ]);
66934     }
66935     ts.metadataHelper = {
66936         name: "typescript:metadata",
66937         importName: "__metadata",
66938         scoped: false,
66939         priority: 3,
66940         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            };"
66941     };
66942     function createParamHelper(context, expression, parameterOffset, location) {
66943         context.requestEmitHelper(ts.paramHelper);
66944         return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__param"), undefined, [
66945             ts.createLiteral(parameterOffset),
66946             expression
66947         ]), location);
66948     }
66949     ts.paramHelper = {
66950         name: "typescript:param",
66951         importName: "__param",
66952         scoped: false,
66953         priority: 4,
66954         text: "\n            var __param = (this && this.__param) || function (paramIndex, decorator) {\n                return function (target, key) { decorator(target, key, paramIndex); }\n            };"
66955     };
66956 })(ts || (ts = {}));
66957 var ts;
66958 (function (ts) {
66959     function transformClassFields(context) {
66960         var hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment;
66961         var resolver = context.getEmitResolver();
66962         var compilerOptions = context.getCompilerOptions();
66963         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
66964         var shouldTransformPrivateFields = languageVersion < 99;
66965         var previousOnSubstituteNode = context.onSubstituteNode;
66966         context.onSubstituteNode = onSubstituteNode;
66967         var enabledSubstitutions;
66968         var classAliases;
66969         var pendingExpressions;
66970         var pendingStatements;
66971         var privateIdentifierEnvironmentStack = [];
66972         var currentPrivateIdentifierEnvironment;
66973         return ts.chainBundle(transformSourceFile);
66974         function transformSourceFile(node) {
66975             var options = context.getCompilerOptions();
66976             if (node.isDeclarationFile
66977                 || options.useDefineForClassFields && options.target === 99) {
66978                 return node;
66979             }
66980             var visited = ts.visitEachChild(node, visitor, context);
66981             ts.addEmitHelpers(visited, context.readEmitHelpers());
66982             return visited;
66983         }
66984         function visitor(node) {
66985             if (!(node.transformFlags & 4194304))
66986                 return node;
66987             switch (node.kind) {
66988                 case 214:
66989                 case 245:
66990                     return visitClassLike(node);
66991                 case 159:
66992                     return visitPropertyDeclaration(node);
66993                 case 225:
66994                     return visitVariableStatement(node);
66995                 case 154:
66996                     return visitComputedPropertyName(node);
66997                 case 194:
66998                     return visitPropertyAccessExpression(node);
66999                 case 207:
67000                     return visitPrefixUnaryExpression(node);
67001                 case 208:
67002                     return visitPostfixUnaryExpression(node, false);
67003                 case 196:
67004                     return visitCallExpression(node);
67005                 case 209:
67006                     return visitBinaryExpression(node);
67007                 case 76:
67008                     return visitPrivateIdentifier(node);
67009                 case 226:
67010                     return visitExpressionStatement(node);
67011                 case 230:
67012                     return visitForStatement(node);
67013                 case 198:
67014                     return visitTaggedTemplateExpression(node);
67015             }
67016             return ts.visitEachChild(node, visitor, context);
67017         }
67018         function visitorDestructuringTarget(node) {
67019             switch (node.kind) {
67020                 case 193:
67021                 case 192:
67022                     return visitAssignmentPattern(node);
67023                 default:
67024                     return visitor(node);
67025             }
67026         }
67027         function visitPrivateIdentifier(node) {
67028             if (!shouldTransformPrivateFields) {
67029                 return node;
67030             }
67031             return ts.setOriginalNode(ts.createIdentifier(""), node);
67032         }
67033         function classElementVisitor(node) {
67034             switch (node.kind) {
67035                 case 162:
67036                     return undefined;
67037                 case 163:
67038                 case 164:
67039                 case 161:
67040                     return ts.visitEachChild(node, classElementVisitor, context);
67041                 case 159:
67042                     return visitPropertyDeclaration(node);
67043                 case 154:
67044                     return visitComputedPropertyName(node);
67045                 case 222:
67046                     return node;
67047                 default:
67048                     return visitor(node);
67049             }
67050         }
67051         function visitVariableStatement(node) {
67052             var savedPendingStatements = pendingStatements;
67053             pendingStatements = [];
67054             var visitedNode = ts.visitEachChild(node, visitor, context);
67055             var statement = ts.some(pendingStatements) ? __spreadArrays([visitedNode], pendingStatements) :
67056                 visitedNode;
67057             pendingStatements = savedPendingStatements;
67058             return statement;
67059         }
67060         function visitComputedPropertyName(name) {
67061             var node = ts.visitEachChild(name, visitor, context);
67062             if (ts.some(pendingExpressions)) {
67063                 var expressions = pendingExpressions;
67064                 expressions.push(name.expression);
67065                 pendingExpressions = [];
67066                 node = ts.updateComputedPropertyName(node, ts.inlineExpressions(expressions));
67067             }
67068             return node;
67069         }
67070         function visitPropertyDeclaration(node) {
67071             ts.Debug.assert(!ts.some(node.decorators));
67072             if (!shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) {
67073                 return ts.updateProperty(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, undefined, undefined, undefined);
67074             }
67075             var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || !!context.getCompilerOptions().useDefineForClassFields);
67076             if (expr && !ts.isSimpleInlineableExpression(expr)) {
67077                 (pendingExpressions || (pendingExpressions = [])).push(expr);
67078             }
67079             return undefined;
67080         }
67081         function createPrivateIdentifierAccess(info, receiver) {
67082             receiver = ts.visitNode(receiver, visitor, ts.isExpression);
67083             switch (info.placement) {
67084                 case 0:
67085                     return createClassPrivateFieldGetHelper(context, ts.nodeIsSynthesized(receiver) ? receiver : ts.getSynthesizedClone(receiver), info.weakMapName);
67086                 default: return ts.Debug.fail("Unexpected private identifier placement");
67087             }
67088         }
67089         function visitPropertyAccessExpression(node) {
67090             if (shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) {
67091                 var privateIdentifierInfo = accessPrivateIdentifier(node.name);
67092                 if (privateIdentifierInfo) {
67093                     return ts.setOriginalNode(createPrivateIdentifierAccess(privateIdentifierInfo, node.expression), node);
67094                 }
67095             }
67096             return ts.visitEachChild(node, visitor, context);
67097         }
67098         function visitPrefixUnaryExpression(node) {
67099             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) {
67100                 var operator = node.operator === 45 ?
67101                     39 : node.operator === 46 ?
67102                     40 : undefined;
67103                 var info = void 0;
67104                 if (operator && (info = accessPrivateIdentifier(node.operand.name))) {
67105                     var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression);
67106                     var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
67107                     var existingValue = ts.createPrefix(39, createPrivateIdentifierAccess(info, readExpression));
67108                     return ts.setOriginalNode(createPrivateIdentifierAssignment(info, initializeExpression || readExpression, ts.createBinary(existingValue, operator, ts.createLiteral(1)), 62), node);
67109                 }
67110             }
67111             return ts.visitEachChild(node, visitor, context);
67112         }
67113         function visitPostfixUnaryExpression(node, valueIsDiscarded) {
67114             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) {
67115                 var operator = node.operator === 45 ?
67116                     39 : node.operator === 46 ?
67117                     40 : undefined;
67118                 var info = void 0;
67119                 if (operator && (info = accessPrivateIdentifier(node.operand.name))) {
67120                     var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression);
67121                     var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
67122                     var existingValue = ts.createPrefix(39, createPrivateIdentifierAccess(info, readExpression));
67123                     var returnValue = valueIsDiscarded ? undefined : ts.createTempVariable(hoistVariableDeclaration);
67124                     return ts.setOriginalNode(ts.inlineExpressions(ts.compact([
67125                         createPrivateIdentifierAssignment(info, initializeExpression || readExpression, ts.createBinary(returnValue ? ts.createAssignment(returnValue, existingValue) : existingValue, operator, ts.createLiteral(1)), 62),
67126                         returnValue
67127                     ])), node);
67128                 }
67129             }
67130             return ts.visitEachChild(node, visitor, context);
67131         }
67132         function visitForStatement(node) {
67133             if (node.incrementor && ts.isPostfixUnaryExpression(node.incrementor)) {
67134                 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));
67135             }
67136             return ts.visitEachChild(node, visitor, context);
67137         }
67138         function visitExpressionStatement(node) {
67139             if (ts.isPostfixUnaryExpression(node.expression)) {
67140                 return ts.updateExpressionStatement(node, visitPostfixUnaryExpression(node.expression, true));
67141             }
67142             return ts.visitEachChild(node, visitor, context);
67143         }
67144         function createCopiableReceiverExpr(receiver) {
67145             var clone = ts.nodeIsSynthesized(receiver) ? receiver : ts.getSynthesizedClone(receiver);
67146             if (ts.isSimpleInlineableExpression(receiver)) {
67147                 return { readExpression: clone, initializeExpression: undefined };
67148             }
67149             var readExpression = ts.createTempVariable(hoistVariableDeclaration);
67150             var initializeExpression = ts.createAssignment(readExpression, clone);
67151             return { readExpression: readExpression, initializeExpression: initializeExpression };
67152         }
67153         function visitCallExpression(node) {
67154             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.expression)) {
67155                 var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target;
67156                 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)));
67157             }
67158             return ts.visitEachChild(node, visitor, context);
67159         }
67160         function visitTaggedTemplateExpression(node) {
67161             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.tag)) {
67162                 var _a = ts.createCallBinding(node.tag, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target;
67163                 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));
67164             }
67165             return ts.visitEachChild(node, visitor, context);
67166         }
67167         function visitBinaryExpression(node) {
67168             if (shouldTransformPrivateFields) {
67169                 if (ts.isDestructuringAssignment(node)) {
67170                     var savedPendingExpressions = pendingExpressions;
67171                     pendingExpressions = undefined;
67172                     node = ts.updateBinary(node, ts.visitNode(node.left, visitorDestructuringTarget), ts.visitNode(node.right, visitor), node.operatorToken);
67173                     var expr = ts.some(pendingExpressions) ?
67174                         ts.inlineExpressions(ts.compact(__spreadArrays(pendingExpressions, [node]))) :
67175                         node;
67176                     pendingExpressions = savedPendingExpressions;
67177                     return expr;
67178                 }
67179                 if (ts.isAssignmentExpression(node) && ts.isPrivateIdentifierPropertyAccessExpression(node.left)) {
67180                     var info = accessPrivateIdentifier(node.left.name);
67181                     if (info) {
67182                         return ts.setOriginalNode(createPrivateIdentifierAssignment(info, node.left.expression, node.right, node.operatorToken.kind), node);
67183                     }
67184                 }
67185             }
67186             return ts.visitEachChild(node, visitor, context);
67187         }
67188         function createPrivateIdentifierAssignment(info, receiver, right, operator) {
67189             switch (info.placement) {
67190                 case 0: {
67191                     return createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator);
67192                 }
67193                 default: return ts.Debug.fail("Unexpected private identifier placement");
67194             }
67195         }
67196         function createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator) {
67197             receiver = ts.visitNode(receiver, visitor, ts.isExpression);
67198             right = ts.visitNode(right, visitor, ts.isExpression);
67199             if (ts.isCompoundAssignment(operator)) {
67200                 var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
67201                 return createClassPrivateFieldSetHelper(context, initializeExpression || readExpression, info.weakMapName, ts.createBinary(createClassPrivateFieldGetHelper(context, readExpression, info.weakMapName), ts.getNonAssignmentOperatorForCompoundAssignment(operator), right));
67202             }
67203             else {
67204                 return createClassPrivateFieldSetHelper(context, receiver, info.weakMapName, right);
67205             }
67206         }
67207         function visitClassLike(node) {
67208             var savedPendingExpressions = pendingExpressions;
67209             pendingExpressions = undefined;
67210             if (shouldTransformPrivateFields) {
67211                 startPrivateIdentifierEnvironment();
67212             }
67213             var result = ts.isClassDeclaration(node) ?
67214                 visitClassDeclaration(node) :
67215                 visitClassExpression(node);
67216             if (shouldTransformPrivateFields) {
67217                 endPrivateIdentifierEnvironment();
67218             }
67219             pendingExpressions = savedPendingExpressions;
67220             return result;
67221         }
67222         function doesClassElementNeedTransform(node) {
67223             return ts.isPropertyDeclaration(node) || (shouldTransformPrivateFields && node.name && ts.isPrivateIdentifier(node.name));
67224         }
67225         function visitClassDeclaration(node) {
67226             if (!ts.forEach(node.members, doesClassElementNeedTransform)) {
67227                 return ts.visitEachChild(node, visitor, context);
67228             }
67229             var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
67230             var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 100);
67231             var statements = [
67232                 ts.updateClassDeclaration(node, undefined, node.modifiers, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass))
67233             ];
67234             if (ts.some(pendingExpressions)) {
67235                 statements.push(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions)));
67236             }
67237             var staticProperties = ts.getProperties(node, true, true);
67238             if (ts.some(staticProperties)) {
67239                 addPropertyStatements(statements, staticProperties, ts.getInternalName(node));
67240             }
67241             return statements;
67242         }
67243         function visitClassExpression(node) {
67244             if (!ts.forEach(node.members, doesClassElementNeedTransform)) {
67245                 return ts.visitEachChild(node, visitor, context);
67246             }
67247             var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node));
67248             var staticProperties = ts.getProperties(node, true, true);
67249             var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
67250             var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 100);
67251             var classExpression = ts.updateClassExpression(node, node.modifiers, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass));
67252             if (ts.some(staticProperties) || ts.some(pendingExpressions)) {
67253                 if (isDecoratedClassDeclaration) {
67254                     ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration.");
67255                     if (pendingStatements && pendingExpressions && ts.some(pendingExpressions)) {
67256                         pendingStatements.push(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions)));
67257                     }
67258                     if (pendingStatements && ts.some(staticProperties)) {
67259                         addPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node));
67260                     }
67261                     return classExpression;
67262                 }
67263                 else {
67264                     var expressions = [];
67265                     var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216;
67266                     var temp = ts.createTempVariable(hoistVariableDeclaration, !!isClassWithConstructorReference);
67267                     if (isClassWithConstructorReference) {
67268                         enableSubstitutionForClassAliases();
67269                         var alias = ts.getSynthesizedClone(temp);
67270                         alias.autoGenerateFlags &= ~8;
67271                         classAliases[ts.getOriginalNodeId(node)] = alias;
67272                     }
67273                     ts.setEmitFlags(classExpression, 65536 | ts.getEmitFlags(classExpression));
67274                     expressions.push(ts.startOnNewLine(ts.createAssignment(temp, classExpression)));
67275                     ts.addRange(expressions, ts.map(pendingExpressions, ts.startOnNewLine));
67276                     ts.addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp));
67277                     expressions.push(ts.startOnNewLine(temp));
67278                     return ts.inlineExpressions(expressions);
67279                 }
67280             }
67281             return classExpression;
67282         }
67283         function transformClassMembers(node, isDerivedClass) {
67284             if (shouldTransformPrivateFields) {
67285                 for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
67286                     var member = _a[_i];
67287                     if (ts.isPrivateIdentifierPropertyDeclaration(member)) {
67288                         addPrivateIdentifierToEnvironment(member.name);
67289                     }
67290                 }
67291             }
67292             var members = [];
67293             var constructor = transformConstructor(node, isDerivedClass);
67294             if (constructor) {
67295                 members.push(constructor);
67296             }
67297             ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
67298             return ts.setTextRange(ts.createNodeArray(members), node.members);
67299         }
67300         function isPropertyDeclarationThatRequiresConstructorStatement(member) {
67301             if (!ts.isPropertyDeclaration(member) || ts.hasStaticModifier(member)) {
67302                 return false;
67303             }
67304             if (context.getCompilerOptions().useDefineForClassFields) {
67305                 return languageVersion < 99;
67306             }
67307             return ts.isInitializedProperty(member) || shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyDeclaration(member);
67308         }
67309         function transformConstructor(node, isDerivedClass) {
67310             var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration);
67311             var properties = node.members.filter(isPropertyDeclarationThatRequiresConstructorStatement);
67312             if (!ts.some(properties)) {
67313                 return constructor;
67314             }
67315             var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context);
67316             var body = transformConstructorBody(node, constructor, isDerivedClass);
67317             if (!body) {
67318                 return undefined;
67319             }
67320             return ts.startOnNewLine(ts.setOriginalNode(ts.setTextRange(ts.createConstructor(undefined, undefined, parameters !== null && parameters !== void 0 ? parameters : [], body), constructor || node), constructor));
67321         }
67322         function transformConstructorBody(node, constructor, isDerivedClass) {
67323             var useDefineForClassFields = context.getCompilerOptions().useDefineForClassFields;
67324             var properties = ts.getProperties(node, false, false);
67325             if (!useDefineForClassFields) {
67326                 properties = ts.filter(properties, function (property) { return !!property.initializer || ts.isPrivateIdentifier(property.name); });
67327             }
67328             if (!constructor && !ts.some(properties)) {
67329                 return ts.visitFunctionBody(undefined, visitor, context);
67330             }
67331             resumeLexicalEnvironment();
67332             var indexOfFirstStatement = 0;
67333             var statements = [];
67334             if (!constructor && isDerivedClass) {
67335                 statements.push(ts.createExpressionStatement(ts.createCall(ts.createSuper(), undefined, [ts.createSpread(ts.createIdentifier("arguments"))])));
67336             }
67337             if (constructor) {
67338                 indexOfFirstStatement = ts.addPrologueDirectivesAndInitialSuperCall(constructor, statements, visitor);
67339             }
67340             if (constructor === null || constructor === void 0 ? void 0 : constructor.body) {
67341                 var afterParameterProperties = ts.findIndex(constructor.body.statements, function (s) { return !ts.isParameterPropertyDeclaration(ts.getOriginalNode(s), constructor); }, indexOfFirstStatement);
67342                 if (afterParameterProperties === -1) {
67343                     afterParameterProperties = constructor.body.statements.length;
67344                 }
67345                 if (afterParameterProperties > indexOfFirstStatement) {
67346                     if (!useDefineForClassFields) {
67347                         ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, afterParameterProperties - indexOfFirstStatement));
67348                     }
67349                     indexOfFirstStatement = afterParameterProperties;
67350                 }
67351             }
67352             addPropertyStatements(statements, properties, ts.createThis());
67353             if (constructor) {
67354                 ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement));
67355             }
67356             statements = ts.mergeLexicalEnvironment(statements, endLexicalEnvironment());
67357             return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true), constructor ? constructor.body : undefined);
67358         }
67359         function addPropertyStatements(statements, properties, receiver) {
67360             for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) {
67361                 var property = properties_8[_i];
67362                 var expression = transformProperty(property, receiver);
67363                 if (!expression) {
67364                     continue;
67365                 }
67366                 var statement = ts.createExpressionStatement(expression);
67367                 ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
67368                 ts.setCommentRange(statement, property);
67369                 ts.setOriginalNode(statement, property);
67370                 statements.push(statement);
67371             }
67372         }
67373         function generateInitializedPropertyExpressions(properties, receiver) {
67374             var expressions = [];
67375             for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) {
67376                 var property = properties_9[_i];
67377                 var expression = transformProperty(property, receiver);
67378                 if (!expression) {
67379                     continue;
67380                 }
67381                 ts.startOnNewLine(expression);
67382                 ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property));
67383                 ts.setCommentRange(expression, property);
67384                 ts.setOriginalNode(expression, property);
67385                 expressions.push(expression);
67386             }
67387             return expressions;
67388         }
67389         function transformProperty(property, receiver) {
67390             var emitAssignment = !context.getCompilerOptions().useDefineForClassFields;
67391             var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression)
67392                 ? ts.updateComputedPropertyName(property.name, ts.getGeneratedNameForNode(property.name))
67393                 : property.name;
67394             if (shouldTransformPrivateFields && ts.isPrivateIdentifier(propertyName)) {
67395                 var privateIdentifierInfo = accessPrivateIdentifier(propertyName);
67396                 if (privateIdentifierInfo) {
67397                     switch (privateIdentifierInfo.placement) {
67398                         case 0: {
67399                             return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.weakMapName);
67400                         }
67401                     }
67402                 }
67403                 else {
67404                     ts.Debug.fail("Undeclared private name for property declaration.");
67405                 }
67406             }
67407             if (ts.isPrivateIdentifier(propertyName) && !property.initializer) {
67408                 return undefined;
67409             }
67410             if (ts.isPrivateIdentifier(propertyName) && !property.initializer) {
67411                 return undefined;
67412             }
67413             var propertyOriginalNode = ts.getOriginalNode(property);
67414             var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression)
67415                 : ts.isParameterPropertyDeclaration(propertyOriginalNode, propertyOriginalNode.parent) && ts.isIdentifier(propertyName) ? propertyName
67416                     : ts.createVoidZero();
67417             if (emitAssignment || ts.isPrivateIdentifier(propertyName)) {
67418                 var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, propertyName);
67419                 return ts.createAssignment(memberAccess, initializer);
67420             }
67421             else {
67422                 var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression
67423                     : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText))
67424                         : propertyName;
67425                 var descriptor = ts.createPropertyDescriptor({ value: initializer, configurable: true, writable: true, enumerable: true });
67426                 return ts.createObjectDefinePropertyCall(receiver, name, descriptor);
67427             }
67428         }
67429         function enableSubstitutionForClassAliases() {
67430             if ((enabledSubstitutions & 1) === 0) {
67431                 enabledSubstitutions |= 1;
67432                 context.enableSubstitution(75);
67433                 classAliases = [];
67434             }
67435         }
67436         function onSubstituteNode(hint, node) {
67437             node = previousOnSubstituteNode(hint, node);
67438             if (hint === 1) {
67439                 return substituteExpression(node);
67440             }
67441             return node;
67442         }
67443         function substituteExpression(node) {
67444             switch (node.kind) {
67445                 case 75:
67446                     return substituteExpressionIdentifier(node);
67447             }
67448             return node;
67449         }
67450         function substituteExpressionIdentifier(node) {
67451             return trySubstituteClassAlias(node) || node;
67452         }
67453         function trySubstituteClassAlias(node) {
67454             if (enabledSubstitutions & 1) {
67455                 if (resolver.getNodeCheckFlags(node) & 33554432) {
67456                     var declaration = resolver.getReferencedValueDeclaration(node);
67457                     if (declaration) {
67458                         var classAlias = classAliases[declaration.id];
67459                         if (classAlias) {
67460                             var clone_2 = ts.getSynthesizedClone(classAlias);
67461                             ts.setSourceMapRange(clone_2, node);
67462                             ts.setCommentRange(clone_2, node);
67463                             return clone_2;
67464                         }
67465                     }
67466                 }
67467             }
67468             return undefined;
67469         }
67470         function getPropertyNameExpressionIfNeeded(name, shouldHoist) {
67471             if (ts.isComputedPropertyName(name)) {
67472                 var expression = ts.visitNode(name.expression, visitor, ts.isExpression);
67473                 var innerExpression = ts.skipPartiallyEmittedExpressions(expression);
67474                 var inlinable = ts.isSimpleInlineableExpression(innerExpression);
67475                 var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left);
67476                 if (!alreadyTransformed && !inlinable && shouldHoist) {
67477                     var generatedName = ts.getGeneratedNameForNode(name);
67478                     hoistVariableDeclaration(generatedName);
67479                     return ts.createAssignment(generatedName, expression);
67480                 }
67481                 return (inlinable || ts.isIdentifier(innerExpression)) ? undefined : expression;
67482             }
67483         }
67484         function startPrivateIdentifierEnvironment() {
67485             privateIdentifierEnvironmentStack.push(currentPrivateIdentifierEnvironment);
67486             currentPrivateIdentifierEnvironment = undefined;
67487         }
67488         function endPrivateIdentifierEnvironment() {
67489             currentPrivateIdentifierEnvironment = privateIdentifierEnvironmentStack.pop();
67490         }
67491         function addPrivateIdentifierToEnvironment(name) {
67492             var text = ts.getTextOfPropertyName(name);
67493             var weakMapName = ts.createOptimisticUniqueName("_" + text.substring(1));
67494             weakMapName.autoGenerateFlags |= 8;
67495             hoistVariableDeclaration(weakMapName);
67496             (currentPrivateIdentifierEnvironment || (currentPrivateIdentifierEnvironment = ts.createUnderscoreEscapedMap()))
67497                 .set(name.escapedText, { placement: 0, weakMapName: weakMapName });
67498             (pendingExpressions || (pendingExpressions = [])).push(ts.createAssignment(weakMapName, ts.createNew(ts.createIdentifier("WeakMap"), undefined, [])));
67499         }
67500         function accessPrivateIdentifier(name) {
67501             if (currentPrivateIdentifierEnvironment) {
67502                 var info = currentPrivateIdentifierEnvironment.get(name.escapedText);
67503                 if (info) {
67504                     return info;
67505                 }
67506             }
67507             for (var i = privateIdentifierEnvironmentStack.length - 1; i >= 0; --i) {
67508                 var env = privateIdentifierEnvironmentStack[i];
67509                 if (!env) {
67510                     continue;
67511                 }
67512                 var info = env.get(name.escapedText);
67513                 if (info) {
67514                     return info;
67515                 }
67516             }
67517             return undefined;
67518         }
67519         function wrapPrivateIdentifierForDestructuringTarget(node) {
67520             var parameter = ts.getGeneratedNameForNode(node);
67521             var info = accessPrivateIdentifier(node.name);
67522             if (!info) {
67523                 return ts.visitEachChild(node, visitor, context);
67524             }
67525             var receiver = node.expression;
67526             if (ts.isThisProperty(node) || ts.isSuperProperty(node) || !ts.isSimpleCopiableExpression(node.expression)) {
67527                 receiver = ts.createTempVariable(hoistVariableDeclaration);
67528                 receiver.autoGenerateFlags |= 8;
67529                 (pendingExpressions || (pendingExpressions = [])).push(ts.createBinary(receiver, 62, node.expression));
67530             }
67531             return ts.createPropertyAccess(ts.createParen(ts.createObjectLiteral([
67532                 ts.createSetAccessor(undefined, undefined, "value", [ts.createParameter(undefined, undefined, undefined, parameter, undefined, undefined, undefined)], ts.createBlock([ts.createExpressionStatement(createPrivateIdentifierAssignment(info, receiver, parameter, 62))]))
67533             ])), "value");
67534         }
67535         function visitArrayAssignmentTarget(node) {
67536             var target = ts.getTargetOfBindingOrAssignmentElement(node);
67537             if (target && ts.isPrivateIdentifierPropertyAccessExpression(target)) {
67538                 var wrapped = wrapPrivateIdentifierForDestructuringTarget(target);
67539                 if (ts.isAssignmentExpression(node)) {
67540                     return ts.updateBinary(node, wrapped, ts.visitNode(node.right, visitor, ts.isExpression), node.operatorToken);
67541                 }
67542                 else if (ts.isSpreadElement(node)) {
67543                     return ts.updateSpread(node, wrapped);
67544                 }
67545                 else {
67546                     return wrapped;
67547                 }
67548             }
67549             return ts.visitNode(node, visitorDestructuringTarget);
67550         }
67551         function visitObjectAssignmentTarget(node) {
67552             if (ts.isPropertyAssignment(node)) {
67553                 var target = ts.getTargetOfBindingOrAssignmentElement(node);
67554                 if (target && ts.isPrivateIdentifierPropertyAccessExpression(target)) {
67555                     var initializer = ts.getInitializerOfBindingOrAssignmentElement(node);
67556                     var wrapped = wrapPrivateIdentifierForDestructuringTarget(target);
67557                     return ts.updatePropertyAssignment(node, ts.visitNode(node.name, visitor), initializer ? ts.createAssignment(wrapped, ts.visitNode(initializer, visitor)) : wrapped);
67558                 }
67559                 return ts.updatePropertyAssignment(node, ts.visitNode(node.name, visitor), ts.visitNode(node.initializer, visitorDestructuringTarget));
67560             }
67561             return ts.visitNode(node, visitor);
67562         }
67563         function visitAssignmentPattern(node) {
67564             if (ts.isArrayLiteralExpression(node)) {
67565                 return ts.updateArrayLiteral(node, ts.visitNodes(node.elements, visitArrayAssignmentTarget, ts.isExpression));
67566             }
67567             else {
67568                 return ts.updateObjectLiteral(node, ts.visitNodes(node.properties, visitObjectAssignmentTarget, ts.isObjectLiteralElementLike));
67569             }
67570         }
67571     }
67572     ts.transformClassFields = transformClassFields;
67573     function createPrivateInstanceFieldInitializer(receiver, initializer, weakMapName) {
67574         return ts.createCall(ts.createPropertyAccess(weakMapName, "set"), undefined, [receiver, initializer || ts.createVoidZero()]);
67575     }
67576     ts.classPrivateFieldGetHelper = {
67577         name: "typescript:classPrivateFieldGet",
67578         scoped: false,
67579         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            };"
67580     };
67581     function createClassPrivateFieldGetHelper(context, receiver, privateField) {
67582         context.requestEmitHelper(ts.classPrivateFieldGetHelper);
67583         return ts.createCall(ts.getUnscopedHelperName("__classPrivateFieldGet"), undefined, [receiver, privateField]);
67584     }
67585     ts.classPrivateFieldSetHelper = {
67586         name: "typescript:classPrivateFieldSet",
67587         scoped: false,
67588         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            };"
67589     };
67590     function createClassPrivateFieldSetHelper(context, receiver, privateField, value) {
67591         context.requestEmitHelper(ts.classPrivateFieldSetHelper);
67592         return ts.createCall(ts.getUnscopedHelperName("__classPrivateFieldSet"), undefined, [receiver, privateField, value]);
67593     }
67594 })(ts || (ts = {}));
67595 var ts;
67596 (function (ts) {
67597     function transformES2017(context) {
67598         var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
67599         var resolver = context.getEmitResolver();
67600         var compilerOptions = context.getCompilerOptions();
67601         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
67602         var enabledSubstitutions;
67603         var enclosingSuperContainerFlags = 0;
67604         var enclosingFunctionParameterNames;
67605         var capturedSuperProperties;
67606         var hasSuperElementAccess;
67607         var substitutedSuperAccessors = [];
67608         var contextFlags = 0;
67609         var previousOnEmitNode = context.onEmitNode;
67610         var previousOnSubstituteNode = context.onSubstituteNode;
67611         context.onEmitNode = onEmitNode;
67612         context.onSubstituteNode = onSubstituteNode;
67613         return ts.chainBundle(transformSourceFile);
67614         function transformSourceFile(node) {
67615             if (node.isDeclarationFile) {
67616                 return node;
67617             }
67618             setContextFlag(1, false);
67619             setContextFlag(2, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions));
67620             var visited = ts.visitEachChild(node, visitor, context);
67621             ts.addEmitHelpers(visited, context.readEmitHelpers());
67622             return visited;
67623         }
67624         function setContextFlag(flag, val) {
67625             contextFlags = val ? contextFlags | flag : contextFlags & ~flag;
67626         }
67627         function inContext(flags) {
67628             return (contextFlags & flags) !== 0;
67629         }
67630         function inTopLevelContext() {
67631             return !inContext(1);
67632         }
67633         function inHasLexicalThisContext() {
67634             return inContext(2);
67635         }
67636         function doWithContext(flags, cb, value) {
67637             var contextFlagsToSet = flags & ~contextFlags;
67638             if (contextFlagsToSet) {
67639                 setContextFlag(contextFlagsToSet, true);
67640                 var result = cb(value);
67641                 setContextFlag(contextFlagsToSet, false);
67642                 return result;
67643             }
67644             return cb(value);
67645         }
67646         function visitDefault(node) {
67647             return ts.visitEachChild(node, visitor, context);
67648         }
67649         function visitor(node) {
67650             if ((node.transformFlags & 64) === 0) {
67651                 return node;
67652             }
67653             switch (node.kind) {
67654                 case 126:
67655                     return undefined;
67656                 case 206:
67657                     return visitAwaitExpression(node);
67658                 case 161:
67659                     return doWithContext(1 | 2, visitMethodDeclaration, node);
67660                 case 244:
67661                     return doWithContext(1 | 2, visitFunctionDeclaration, node);
67662                 case 201:
67663                     return doWithContext(1 | 2, visitFunctionExpression, node);
67664                 case 202:
67665                     return doWithContext(1, visitArrowFunction, node);
67666                 case 194:
67667                     if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 102) {
67668                         capturedSuperProperties.set(node.name.escapedText, true);
67669                     }
67670                     return ts.visitEachChild(node, visitor, context);
67671                 case 195:
67672                     if (capturedSuperProperties && node.expression.kind === 102) {
67673                         hasSuperElementAccess = true;
67674                     }
67675                     return ts.visitEachChild(node, visitor, context);
67676                 case 163:
67677                 case 164:
67678                 case 162:
67679                 case 245:
67680                 case 214:
67681                     return doWithContext(1 | 2, visitDefault, node);
67682                 default:
67683                     return ts.visitEachChild(node, visitor, context);
67684             }
67685         }
67686         function asyncBodyVisitor(node) {
67687             if (ts.isNodeWithPossibleHoistedDeclaration(node)) {
67688                 switch (node.kind) {
67689                     case 225:
67690                         return visitVariableStatementInAsyncBody(node);
67691                     case 230:
67692                         return visitForStatementInAsyncBody(node);
67693                     case 231:
67694                         return visitForInStatementInAsyncBody(node);
67695                     case 232:
67696                         return visitForOfStatementInAsyncBody(node);
67697                     case 280:
67698                         return visitCatchClauseInAsyncBody(node);
67699                     case 223:
67700                     case 237:
67701                     case 251:
67702                     case 277:
67703                     case 278:
67704                     case 240:
67705                     case 228:
67706                     case 229:
67707                     case 227:
67708                     case 236:
67709                     case 238:
67710                         return ts.visitEachChild(node, asyncBodyVisitor, context);
67711                     default:
67712                         return ts.Debug.assertNever(node, "Unhandled node.");
67713                 }
67714             }
67715             return visitor(node);
67716         }
67717         function visitCatchClauseInAsyncBody(node) {
67718             var catchClauseNames = ts.createUnderscoreEscapedMap();
67719             recordDeclarationName(node.variableDeclaration, catchClauseNames);
67720             var catchClauseUnshadowedNames;
67721             catchClauseNames.forEach(function (_, escapedName) {
67722                 if (enclosingFunctionParameterNames.has(escapedName)) {
67723                     if (!catchClauseUnshadowedNames) {
67724                         catchClauseUnshadowedNames = ts.cloneMap(enclosingFunctionParameterNames);
67725                     }
67726                     catchClauseUnshadowedNames.delete(escapedName);
67727                 }
67728             });
67729             if (catchClauseUnshadowedNames) {
67730                 var savedEnclosingFunctionParameterNames = enclosingFunctionParameterNames;
67731                 enclosingFunctionParameterNames = catchClauseUnshadowedNames;
67732                 var result = ts.visitEachChild(node, asyncBodyVisitor, context);
67733                 enclosingFunctionParameterNames = savedEnclosingFunctionParameterNames;
67734                 return result;
67735             }
67736             else {
67737                 return ts.visitEachChild(node, asyncBodyVisitor, context);
67738             }
67739         }
67740         function visitVariableStatementInAsyncBody(node) {
67741             if (isVariableDeclarationListWithCollidingName(node.declarationList)) {
67742                 var expression = visitVariableDeclarationListWithCollidingNames(node.declarationList, false);
67743                 return expression ? ts.createExpressionStatement(expression) : undefined;
67744             }
67745             return ts.visitEachChild(node, visitor, context);
67746         }
67747         function visitForInStatementInAsyncBody(node) {
67748             return ts.updateForIn(node, isVariableDeclarationListWithCollidingName(node.initializer)
67749                 ? visitVariableDeclarationListWithCollidingNames(node.initializer, true)
67750                 : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, ts.liftToBlock));
67751         }
67752         function visitForOfStatementInAsyncBody(node) {
67753             return ts.updateForOf(node, ts.visitNode(node.awaitModifier, visitor, ts.isToken), isVariableDeclarationListWithCollidingName(node.initializer)
67754                 ? visitVariableDeclarationListWithCollidingNames(node.initializer, true)
67755                 : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, ts.liftToBlock));
67756         }
67757         function visitForStatementInAsyncBody(node) {
67758             var initializer = node.initializer;
67759             return ts.updateFor(node, isVariableDeclarationListWithCollidingName(initializer)
67760                 ? visitVariableDeclarationListWithCollidingNames(initializer, false)
67761                 : 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));
67762         }
67763         function visitAwaitExpression(node) {
67764             if (inTopLevelContext()) {
67765                 return ts.visitEachChild(node, visitor, context);
67766             }
67767             return ts.setOriginalNode(ts.setTextRange(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node);
67768         }
67769         function visitMethodDeclaration(node) {
67770             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
67771                 ? transformAsyncFunctionBody(node)
67772                 : ts.visitFunctionBody(node.body, visitor, context));
67773         }
67774         function visitFunctionDeclaration(node) {
67775             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
67776                 ? transformAsyncFunctionBody(node)
67777                 : ts.visitFunctionBody(node.body, visitor, context));
67778         }
67779         function visitFunctionExpression(node) {
67780             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
67781                 ? transformAsyncFunctionBody(node)
67782                 : ts.visitFunctionBody(node.body, visitor, context));
67783         }
67784         function visitArrowFunction(node) {
67785             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
67786                 ? transformAsyncFunctionBody(node)
67787                 : ts.visitFunctionBody(node.body, visitor, context));
67788         }
67789         function recordDeclarationName(_a, names) {
67790             var name = _a.name;
67791             if (ts.isIdentifier(name)) {
67792                 names.set(name.escapedText, true);
67793             }
67794             else {
67795                 for (var _i = 0, _b = name.elements; _i < _b.length; _i++) {
67796                     var element = _b[_i];
67797                     if (!ts.isOmittedExpression(element)) {
67798                         recordDeclarationName(element, names);
67799                     }
67800                 }
67801             }
67802         }
67803         function isVariableDeclarationListWithCollidingName(node) {
67804             return !!node
67805                 && ts.isVariableDeclarationList(node)
67806                 && !(node.flags & 3)
67807                 && node.declarations.some(collidesWithParameterName);
67808         }
67809         function visitVariableDeclarationListWithCollidingNames(node, hasReceiver) {
67810             hoistVariableDeclarationList(node);
67811             var variables = ts.getInitializedVariables(node);
67812             if (variables.length === 0) {
67813                 if (hasReceiver) {
67814                     return ts.visitNode(ts.convertToAssignmentElementTarget(node.declarations[0].name), visitor, ts.isExpression);
67815                 }
67816                 return undefined;
67817             }
67818             return ts.inlineExpressions(ts.map(variables, transformInitializedVariable));
67819         }
67820         function hoistVariableDeclarationList(node) {
67821             ts.forEach(node.declarations, hoistVariable);
67822         }
67823         function hoistVariable(_a) {
67824             var name = _a.name;
67825             if (ts.isIdentifier(name)) {
67826                 hoistVariableDeclaration(name);
67827             }
67828             else {
67829                 for (var _i = 0, _b = name.elements; _i < _b.length; _i++) {
67830                     var element = _b[_i];
67831                     if (!ts.isOmittedExpression(element)) {
67832                         hoistVariable(element);
67833                     }
67834                 }
67835             }
67836         }
67837         function transformInitializedVariable(node) {
67838             var converted = ts.setSourceMapRange(ts.createAssignment(ts.convertToAssignmentElementTarget(node.name), node.initializer), node);
67839             return ts.visitNode(converted, visitor, ts.isExpression);
67840         }
67841         function collidesWithParameterName(_a) {
67842             var name = _a.name;
67843             if (ts.isIdentifier(name)) {
67844                 return enclosingFunctionParameterNames.has(name.escapedText);
67845             }
67846             else {
67847                 for (var _i = 0, _b = name.elements; _i < _b.length; _i++) {
67848                     var element = _b[_i];
67849                     if (!ts.isOmittedExpression(element) && collidesWithParameterName(element)) {
67850                         return true;
67851                     }
67852                 }
67853             }
67854             return false;
67855         }
67856         function transformAsyncFunctionBody(node) {
67857             resumeLexicalEnvironment();
67858             var original = ts.getOriginalNode(node, ts.isFunctionLike);
67859             var nodeType = original.type;
67860             var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined;
67861             var isArrowFunction = node.kind === 202;
67862             var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0;
67863             var savedEnclosingFunctionParameterNames = enclosingFunctionParameterNames;
67864             enclosingFunctionParameterNames = ts.createUnderscoreEscapedMap();
67865             for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
67866                 var parameter = _a[_i];
67867                 recordDeclarationName(parameter, enclosingFunctionParameterNames);
67868             }
67869             var savedCapturedSuperProperties = capturedSuperProperties;
67870             var savedHasSuperElementAccess = hasSuperElementAccess;
67871             if (!isArrowFunction) {
67872                 capturedSuperProperties = ts.createUnderscoreEscapedMap();
67873                 hasSuperElementAccess = false;
67874             }
67875             var result;
67876             if (!isArrowFunction) {
67877                 var statements = [];
67878                 var statementOffset = ts.addPrologue(statements, node.body.statements, false, visitor);
67879                 statements.push(ts.createReturn(createAwaiterHelper(context, inHasLexicalThisContext(), hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset))));
67880                 ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
67881                 var emitSuperHelpers = languageVersion >= 2 && resolver.getNodeCheckFlags(node) & (4096 | 2048);
67882                 if (emitSuperHelpers) {
67883                     enableSubstitutionForAsyncMethodsWithSuper();
67884                     if (ts.hasEntries(capturedSuperProperties)) {
67885                         var variableStatement = createSuperAccessVariableStatement(resolver, node, capturedSuperProperties);
67886                         substitutedSuperAccessors[ts.getNodeId(variableStatement)] = true;
67887                         ts.insertStatementsAfterStandardPrologue(statements, [variableStatement]);
67888                     }
67889                 }
67890                 var block = ts.createBlock(statements, true);
67891                 ts.setTextRange(block, node.body);
67892                 if (emitSuperHelpers && hasSuperElementAccess) {
67893                     if (resolver.getNodeCheckFlags(node) & 4096) {
67894                         ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
67895                     }
67896                     else if (resolver.getNodeCheckFlags(node) & 2048) {
67897                         ts.addEmitHelper(block, ts.asyncSuperHelper);
67898                     }
67899                 }
67900                 result = block;
67901             }
67902             else {
67903                 var expression = createAwaiterHelper(context, inHasLexicalThisContext(), hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body));
67904                 var declarations = endLexicalEnvironment();
67905                 if (ts.some(declarations)) {
67906                     var block = ts.convertToFunctionBody(expression);
67907                     result = ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, block.statements)), block.statements));
67908                 }
67909                 else {
67910                     result = expression;
67911                 }
67912             }
67913             enclosingFunctionParameterNames = savedEnclosingFunctionParameterNames;
67914             if (!isArrowFunction) {
67915                 capturedSuperProperties = savedCapturedSuperProperties;
67916                 hasSuperElementAccess = savedHasSuperElementAccess;
67917             }
67918             return result;
67919         }
67920         function transformAsyncFunctionBodyWorker(body, start) {
67921             if (ts.isBlock(body)) {
67922                 return ts.updateBlock(body, ts.visitNodes(body.statements, asyncBodyVisitor, ts.isStatement, start));
67923             }
67924             else {
67925                 return ts.convertToFunctionBody(ts.visitNode(body, asyncBodyVisitor, ts.isConciseBody));
67926             }
67927         }
67928         function getPromiseConstructor(type) {
67929             var typeName = type && ts.getEntityNameFromTypeNode(type);
67930             if (typeName && ts.isEntityName(typeName)) {
67931                 var serializationKind = resolver.getTypeReferenceSerializationKind(typeName);
67932                 if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue
67933                     || serializationKind === ts.TypeReferenceSerializationKind.Unknown) {
67934                     return typeName;
67935                 }
67936             }
67937             return undefined;
67938         }
67939         function enableSubstitutionForAsyncMethodsWithSuper() {
67940             if ((enabledSubstitutions & 1) === 0) {
67941                 enabledSubstitutions |= 1;
67942                 context.enableSubstitution(196);
67943                 context.enableSubstitution(194);
67944                 context.enableSubstitution(195);
67945                 context.enableEmitNotification(245);
67946                 context.enableEmitNotification(161);
67947                 context.enableEmitNotification(163);
67948                 context.enableEmitNotification(164);
67949                 context.enableEmitNotification(162);
67950                 context.enableEmitNotification(225);
67951             }
67952         }
67953         function onEmitNode(hint, node, emitCallback) {
67954             if (enabledSubstitutions & 1 && isSuperContainer(node)) {
67955                 var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 | 4096);
67956                 if (superContainerFlags !== enclosingSuperContainerFlags) {
67957                     var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
67958                     enclosingSuperContainerFlags = superContainerFlags;
67959                     previousOnEmitNode(hint, node, emitCallback);
67960                     enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
67961                     return;
67962                 }
67963             }
67964             else if (enabledSubstitutions && substitutedSuperAccessors[ts.getNodeId(node)]) {
67965                 var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
67966                 enclosingSuperContainerFlags = 0;
67967                 previousOnEmitNode(hint, node, emitCallback);
67968                 enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
67969                 return;
67970             }
67971             previousOnEmitNode(hint, node, emitCallback);
67972         }
67973         function onSubstituteNode(hint, node) {
67974             node = previousOnSubstituteNode(hint, node);
67975             if (hint === 1 && enclosingSuperContainerFlags) {
67976                 return substituteExpression(node);
67977             }
67978             return node;
67979         }
67980         function substituteExpression(node) {
67981             switch (node.kind) {
67982                 case 194:
67983                     return substitutePropertyAccessExpression(node);
67984                 case 195:
67985                     return substituteElementAccessExpression(node);
67986                 case 196:
67987                     return substituteCallExpression(node);
67988             }
67989             return node;
67990         }
67991         function substitutePropertyAccessExpression(node) {
67992             if (node.expression.kind === 102) {
67993                 return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node);
67994             }
67995             return node;
67996         }
67997         function substituteElementAccessExpression(node) {
67998             if (node.expression.kind === 102) {
67999                 return createSuperElementAccessInAsyncMethod(node.argumentExpression, node);
68000             }
68001             return node;
68002         }
68003         function substituteCallExpression(node) {
68004             var expression = node.expression;
68005             if (ts.isSuperProperty(expression)) {
68006                 var argumentExpression = ts.isPropertyAccessExpression(expression)
68007                     ? substitutePropertyAccessExpression(expression)
68008                     : substituteElementAccessExpression(expression);
68009                 return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, __spreadArrays([
68010                     ts.createThis()
68011                 ], node.arguments));
68012             }
68013             return node;
68014         }
68015         function isSuperContainer(node) {
68016             var kind = node.kind;
68017             return kind === 245
68018                 || kind === 162
68019                 || kind === 161
68020                 || kind === 163
68021                 || kind === 164;
68022         }
68023         function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
68024             if (enclosingSuperContainerFlags & 4096) {
68025                 return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createFileLevelUniqueName("_superIndex"), undefined, [argumentExpression]), "value"), location);
68026             }
68027             else {
68028                 return ts.setTextRange(ts.createCall(ts.createFileLevelUniqueName("_superIndex"), undefined, [argumentExpression]), location);
68029             }
68030         }
68031     }
68032     ts.transformES2017 = transformES2017;
68033     function createSuperAccessVariableStatement(resolver, node, names) {
68034         var hasBinding = (resolver.getNodeCheckFlags(node) & 4096) !== 0;
68035         var accessors = [];
68036         names.forEach(function (_, key) {
68037             var name = ts.unescapeLeadingUnderscores(key);
68038             var getterAndSetter = [];
68039             getterAndSetter.push(ts.createPropertyAssignment("get", ts.createArrowFunction(undefined, undefined, [], undefined, undefined, ts.setEmitFlags(ts.createPropertyAccess(ts.setEmitFlags(ts.createSuper(), 4), name), 4))));
68040             if (hasBinding) {
68041                 getterAndSetter.push(ts.createPropertyAssignment("set", ts.createArrowFunction(undefined, undefined, [
68042                     ts.createParameter(undefined, undefined, undefined, "v", undefined, undefined, undefined)
68043                 ], undefined, undefined, ts.createAssignment(ts.setEmitFlags(ts.createPropertyAccess(ts.setEmitFlags(ts.createSuper(), 4), name), 4), ts.createIdentifier("v")))));
68044             }
68045             accessors.push(ts.createPropertyAssignment(name, ts.createObjectLiteral(getterAndSetter)));
68046         });
68047         return ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
68048             ts.createVariableDeclaration(ts.createFileLevelUniqueName("_super"), undefined, ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "create"), undefined, [
68049                 ts.createNull(),
68050                 ts.createObjectLiteral(accessors, true)
68051             ]))
68052         ], 2));
68053     }
68054     ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement;
68055     ts.awaiterHelper = {
68056         name: "typescript:awaiter",
68057         importName: "__awaiter",
68058         scoped: false,
68059         priority: 5,
68060         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            };"
68061     };
68062     function createAwaiterHelper(context, hasLexicalThis, hasLexicalArguments, promiseConstructor, body) {
68063         context.requestEmitHelper(ts.awaiterHelper);
68064         var generatorFunc = ts.createFunctionExpression(undefined, ts.createToken(41), undefined, undefined, [], undefined, body);
68065         (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 | 524288;
68066         return ts.createCall(ts.getUnscopedHelperName("__awaiter"), undefined, [
68067             hasLexicalThis ? ts.createThis() : ts.createVoidZero(),
68068             hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(),
68069             promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(),
68070             generatorFunc
68071         ]);
68072     }
68073     ts.asyncSuperHelper = {
68074         name: "typescript:async-super",
68075         scoped: true,
68076         text: ts.helperString(__makeTemplateObject(["\n            const ", " = name => super[name];"], ["\n            const ", " = name => super[name];"]), "_superIndex")
68077     };
68078     ts.advancedAsyncSuperHelper = {
68079         name: "typescript:advanced-async-super",
68080         scoped: true,
68081         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")
68082     };
68083 })(ts || (ts = {}));
68084 var ts;
68085 (function (ts) {
68086     function transformES2018(context) {
68087         var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
68088         var resolver = context.getEmitResolver();
68089         var compilerOptions = context.getCompilerOptions();
68090         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
68091         var previousOnEmitNode = context.onEmitNode;
68092         context.onEmitNode = onEmitNode;
68093         var previousOnSubstituteNode = context.onSubstituteNode;
68094         context.onSubstituteNode = onSubstituteNode;
68095         var exportedVariableStatement = false;
68096         var enabledSubstitutions;
68097         var enclosingFunctionFlags;
68098         var enclosingSuperContainerFlags = 0;
68099         var hierarchyFacts = 0;
68100         var currentSourceFile;
68101         var taggedTemplateStringDeclarations;
68102         var capturedSuperProperties;
68103         var hasSuperElementAccess;
68104         var substitutedSuperAccessors = [];
68105         return ts.chainBundle(transformSourceFile);
68106         function affectsSubtree(excludeFacts, includeFacts) {
68107             return hierarchyFacts !== (hierarchyFacts & ~excludeFacts | includeFacts);
68108         }
68109         function enterSubtree(excludeFacts, includeFacts) {
68110             var ancestorFacts = hierarchyFacts;
68111             hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3;
68112             return ancestorFacts;
68113         }
68114         function exitSubtree(ancestorFacts) {
68115             hierarchyFacts = ancestorFacts;
68116         }
68117         function recordTaggedTemplateString(temp) {
68118             taggedTemplateStringDeclarations = ts.append(taggedTemplateStringDeclarations, ts.createVariableDeclaration(temp));
68119         }
68120         function transformSourceFile(node) {
68121             if (node.isDeclarationFile) {
68122                 return node;
68123             }
68124             currentSourceFile = node;
68125             var visited = visitSourceFile(node);
68126             ts.addEmitHelpers(visited, context.readEmitHelpers());
68127             currentSourceFile = undefined;
68128             taggedTemplateStringDeclarations = undefined;
68129             return visited;
68130         }
68131         function visitor(node) {
68132             return visitorWorker(node, false);
68133         }
68134         function visitorNoDestructuringValue(node) {
68135             return visitorWorker(node, true);
68136         }
68137         function visitorNoAsyncModifier(node) {
68138             if (node.kind === 126) {
68139                 return undefined;
68140             }
68141             return node;
68142         }
68143         function doWithHierarchyFacts(cb, value, excludeFacts, includeFacts) {
68144             if (affectsSubtree(excludeFacts, includeFacts)) {
68145                 var ancestorFacts = enterSubtree(excludeFacts, includeFacts);
68146                 var result = cb(value);
68147                 exitSubtree(ancestorFacts);
68148                 return result;
68149             }
68150             return cb(value);
68151         }
68152         function visitDefault(node) {
68153             return ts.visitEachChild(node, visitor, context);
68154         }
68155         function visitorWorker(node, noDestructuringValue) {
68156             if ((node.transformFlags & 32) === 0) {
68157                 return node;
68158             }
68159             switch (node.kind) {
68160                 case 206:
68161                     return visitAwaitExpression(node);
68162                 case 212:
68163                     return visitYieldExpression(node);
68164                 case 235:
68165                     return visitReturnStatement(node);
68166                 case 238:
68167                     return visitLabeledStatement(node);
68168                 case 193:
68169                     return visitObjectLiteralExpression(node);
68170                 case 209:
68171                     return visitBinaryExpression(node, noDestructuringValue);
68172                 case 280:
68173                     return visitCatchClause(node);
68174                 case 225:
68175                     return visitVariableStatement(node);
68176                 case 242:
68177                     return visitVariableDeclaration(node);
68178                 case 228:
68179                 case 229:
68180                 case 231:
68181                     return doWithHierarchyFacts(visitDefault, node, 0, 2);
68182                 case 232:
68183                     return visitForOfStatement(node, undefined);
68184                 case 230:
68185                     return doWithHierarchyFacts(visitForStatement, node, 0, 2);
68186                 case 205:
68187                     return visitVoidExpression(node);
68188                 case 162:
68189                     return doWithHierarchyFacts(visitConstructorDeclaration, node, 2, 1);
68190                 case 161:
68191                     return doWithHierarchyFacts(visitMethodDeclaration, node, 2, 1);
68192                 case 163:
68193                     return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2, 1);
68194                 case 164:
68195                     return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2, 1);
68196                 case 244:
68197                     return doWithHierarchyFacts(visitFunctionDeclaration, node, 2, 1);
68198                 case 201:
68199                     return doWithHierarchyFacts(visitFunctionExpression, node, 2, 1);
68200                 case 202:
68201                     return doWithHierarchyFacts(visitArrowFunction, node, 2, 0);
68202                 case 156:
68203                     return visitParameter(node);
68204                 case 226:
68205                     return visitExpressionStatement(node);
68206                 case 200:
68207                     return visitParenthesizedExpression(node, noDestructuringValue);
68208                 case 198:
68209                     return visitTaggedTemplateExpression(node);
68210                 case 194:
68211                     if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 102) {
68212                         capturedSuperProperties.set(node.name.escapedText, true);
68213                     }
68214                     return ts.visitEachChild(node, visitor, context);
68215                 case 195:
68216                     if (capturedSuperProperties && node.expression.kind === 102) {
68217                         hasSuperElementAccess = true;
68218                     }
68219                     return ts.visitEachChild(node, visitor, context);
68220                 case 245:
68221                 case 214:
68222                     return doWithHierarchyFacts(visitDefault, node, 2, 1);
68223                 default:
68224                     return ts.visitEachChild(node, visitor, context);
68225             }
68226         }
68227         function visitAwaitExpression(node) {
68228             if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) {
68229                 return ts.setOriginalNode(ts.setTextRange(ts.createYield(createAwaitHelper(context, ts.visitNode(node.expression, visitor, ts.isExpression))), node), node);
68230             }
68231             return ts.visitEachChild(node, visitor, context);
68232         }
68233         function visitYieldExpression(node) {
68234             if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) {
68235                 if (node.asteriskToken) {
68236                     var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
68237                     return ts.setOriginalNode(ts.setTextRange(ts.createYield(createAwaitHelper(context, ts.updateYield(node, node.asteriskToken, createAsyncDelegatorHelper(context, createAsyncValuesHelper(context, expression, expression), expression)))), node), node);
68238                 }
68239                 return ts.setOriginalNode(ts.setTextRange(ts.createYield(createDownlevelAwait(node.expression
68240                     ? ts.visitNode(node.expression, visitor, ts.isExpression)
68241                     : ts.createVoidZero())), node), node);
68242             }
68243             return ts.visitEachChild(node, visitor, context);
68244         }
68245         function visitReturnStatement(node) {
68246             if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) {
68247                 return ts.updateReturn(node, createDownlevelAwait(node.expression ? ts.visitNode(node.expression, visitor, ts.isExpression) : ts.createVoidZero()));
68248             }
68249             return ts.visitEachChild(node, visitor, context);
68250         }
68251         function visitLabeledStatement(node) {
68252             if (enclosingFunctionFlags & 2) {
68253                 var statement = ts.unwrapInnermostStatementOfLabel(node);
68254                 if (statement.kind === 232 && statement.awaitModifier) {
68255                     return visitForOfStatement(statement, node);
68256                 }
68257                 return ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, ts.liftToBlock), node);
68258             }
68259             return ts.visitEachChild(node, visitor, context);
68260         }
68261         function chunkObjectLiteralElements(elements) {
68262             var chunkObject;
68263             var objects = [];
68264             for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) {
68265                 var e = elements_4[_i];
68266                 if (e.kind === 283) {
68267                     if (chunkObject) {
68268                         objects.push(ts.createObjectLiteral(chunkObject));
68269                         chunkObject = undefined;
68270                     }
68271                     var target = e.expression;
68272                     objects.push(ts.visitNode(target, visitor, ts.isExpression));
68273                 }
68274                 else {
68275                     chunkObject = ts.append(chunkObject, e.kind === 281
68276                         ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression))
68277                         : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike));
68278                 }
68279             }
68280             if (chunkObject) {
68281                 objects.push(ts.createObjectLiteral(chunkObject));
68282             }
68283             return objects;
68284         }
68285         function visitObjectLiteralExpression(node) {
68286             if (node.transformFlags & 16384) {
68287                 var objects = chunkObjectLiteralElements(node.properties);
68288                 if (objects.length && objects[0].kind !== 193) {
68289                     objects.unshift(ts.createObjectLiteral());
68290                 }
68291                 var expression = objects[0];
68292                 if (objects.length > 1) {
68293                     for (var i = 1; i < objects.length; i++) {
68294                         expression = createAssignHelper(context, [expression, objects[i]]);
68295                     }
68296                     return expression;
68297                 }
68298                 else {
68299                     return createAssignHelper(context, objects);
68300                 }
68301             }
68302             return ts.visitEachChild(node, visitor, context);
68303         }
68304         function visitExpressionStatement(node) {
68305             return ts.visitEachChild(node, visitorNoDestructuringValue, context);
68306         }
68307         function visitParenthesizedExpression(node, noDestructuringValue) {
68308             return ts.visitEachChild(node, noDestructuringValue ? visitorNoDestructuringValue : visitor, context);
68309         }
68310         function visitSourceFile(node) {
68311             var ancestorFacts = enterSubtree(2, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ?
68312                 0 :
68313                 1);
68314             exportedVariableStatement = false;
68315             var visited = ts.visitEachChild(node, visitor, context);
68316             var statement = ts.concatenate(visited.statements, taggedTemplateStringDeclarations && [
68317                 ts.createVariableStatement(undefined, ts.createVariableDeclarationList(taggedTemplateStringDeclarations))
68318             ]);
68319             var result = ts.updateSourceFileNode(visited, ts.setTextRange(ts.createNodeArray(statement), node.statements));
68320             exitSubtree(ancestorFacts);
68321             return result;
68322         }
68323         function visitTaggedTemplateExpression(node) {
68324             return ts.processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, ts.ProcessLevel.LiftRestriction);
68325         }
68326         function visitBinaryExpression(node, noDestructuringValue) {
68327             if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 16384) {
68328                 return ts.flattenDestructuringAssignment(node, visitor, context, 1, !noDestructuringValue);
68329             }
68330             else if (node.operatorToken.kind === 27) {
68331                 return ts.updateBinary(node, ts.visitNode(node.left, visitorNoDestructuringValue, ts.isExpression), ts.visitNode(node.right, noDestructuringValue ? visitorNoDestructuringValue : visitor, ts.isExpression));
68332             }
68333             return ts.visitEachChild(node, visitor, context);
68334         }
68335         function visitCatchClause(node) {
68336             if (node.variableDeclaration &&
68337                 ts.isBindingPattern(node.variableDeclaration.name) &&
68338                 node.variableDeclaration.name.transformFlags & 16384) {
68339                 var name = ts.getGeneratedNameForNode(node.variableDeclaration.name);
68340                 var updatedDecl = ts.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, undefined, name);
68341                 var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1);
68342                 var block = ts.visitNode(node.block, visitor, ts.isBlock);
68343                 if (ts.some(visitedBindings)) {
68344                     block = ts.updateBlock(block, __spreadArrays([
68345                         ts.createVariableStatement(undefined, visitedBindings)
68346                     ], block.statements));
68347                 }
68348                 return ts.updateCatchClause(node, ts.updateVariableDeclaration(node.variableDeclaration, name, undefined, undefined), block);
68349             }
68350             return ts.visitEachChild(node, visitor, context);
68351         }
68352         function visitVariableStatement(node) {
68353             if (ts.hasModifier(node, 1)) {
68354                 var savedExportedVariableStatement = exportedVariableStatement;
68355                 exportedVariableStatement = true;
68356                 var visited = ts.visitEachChild(node, visitor, context);
68357                 exportedVariableStatement = savedExportedVariableStatement;
68358                 return visited;
68359             }
68360             return ts.visitEachChild(node, visitor, context);
68361         }
68362         function visitVariableDeclaration(node) {
68363             if (exportedVariableStatement) {
68364                 var savedExportedVariableStatement = exportedVariableStatement;
68365                 exportedVariableStatement = false;
68366                 var visited = visitVariableDeclarationWorker(node, true);
68367                 exportedVariableStatement = savedExportedVariableStatement;
68368                 return visited;
68369             }
68370             return visitVariableDeclarationWorker(node, false);
68371         }
68372         function visitVariableDeclarationWorker(node, exportedVariableStatement) {
68373             if (ts.isBindingPattern(node.name) && node.name.transformFlags & 16384) {
68374                 return ts.flattenDestructuringBinding(node, visitor, context, 1, undefined, exportedVariableStatement);
68375             }
68376             return ts.visitEachChild(node, visitor, context);
68377         }
68378         function visitForStatement(node) {
68379             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));
68380         }
68381         function visitVoidExpression(node) {
68382             return ts.visitEachChild(node, visitorNoDestructuringValue, context);
68383         }
68384         function visitForOfStatement(node, outermostLabeledStatement) {
68385             var ancestorFacts = enterSubtree(0, 2);
68386             if (node.initializer.transformFlags & 16384) {
68387                 node = transformForOfStatementWithObjectRest(node);
68388             }
68389             var result = node.awaitModifier ?
68390                 transformForAwaitOfStatement(node, outermostLabeledStatement, ancestorFacts) :
68391                 ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement);
68392             exitSubtree(ancestorFacts);
68393             return result;
68394         }
68395         function transformForOfStatementWithObjectRest(node) {
68396             var initializerWithoutParens = ts.skipParentheses(node.initializer);
68397             if (ts.isVariableDeclarationList(initializerWithoutParens) || ts.isAssignmentPattern(initializerWithoutParens)) {
68398                 var bodyLocation = void 0;
68399                 var statementsLocation = void 0;
68400                 var temp = ts.createTempVariable(undefined);
68401                 var statements = [ts.createForOfBindingStatement(initializerWithoutParens, temp)];
68402                 if (ts.isBlock(node.statement)) {
68403                     ts.addRange(statements, node.statement.statements);
68404                     bodyLocation = node.statement;
68405                     statementsLocation = node.statement.statements;
68406                 }
68407                 else if (node.statement) {
68408                     ts.append(statements, node.statement);
68409                     bodyLocation = node.statement;
68410                     statementsLocation = node.statement;
68411                 }
68412                 return ts.updateForOf(node, node.awaitModifier, ts.setTextRange(ts.createVariableDeclarationList([
68413                     ts.setTextRange(ts.createVariableDeclaration(temp), node.initializer)
68414                 ], 1), node.initializer), node.expression, ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true), bodyLocation));
68415             }
68416             return node;
68417         }
68418         function convertForOfStatementHead(node, boundValue) {
68419             var binding = ts.createForOfBindingStatement(node.initializer, boundValue);
68420             var bodyLocation;
68421             var statementsLocation;
68422             var statements = [ts.visitNode(binding, visitor, ts.isStatement)];
68423             var statement = ts.visitNode(node.statement, visitor, ts.isStatement);
68424             if (ts.isBlock(statement)) {
68425                 ts.addRange(statements, statement.statements);
68426                 bodyLocation = statement;
68427                 statementsLocation = statement.statements;
68428             }
68429             else {
68430                 statements.push(statement);
68431             }
68432             return ts.setEmitFlags(ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true), bodyLocation), 48 | 384);
68433         }
68434         function createDownlevelAwait(expression) {
68435             return enclosingFunctionFlags & 1
68436                 ? ts.createYield(undefined, createAwaitHelper(context, expression))
68437                 : ts.createAwait(expression);
68438         }
68439         function transformForAwaitOfStatement(node, outermostLabeledStatement, ancestorFacts) {
68440             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
68441             var iterator = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(undefined);
68442             var result = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(iterator) : ts.createTempVariable(undefined);
68443             var errorRecord = ts.createUniqueName("e");
68444             var catchVariable = ts.getGeneratedNameForNode(errorRecord);
68445             var returnMethod = ts.createTempVariable(undefined);
68446             var callValues = createAsyncValuesHelper(context, expression, node.expression);
68447             var callNext = ts.createCall(ts.createPropertyAccess(iterator, "next"), undefined, []);
68448             var getDone = ts.createPropertyAccess(result, "done");
68449             var getValue = ts.createPropertyAccess(result, "value");
68450             var callReturn = ts.createFunctionCall(returnMethod, iterator, []);
68451             hoistVariableDeclaration(errorRecord);
68452             hoistVariableDeclaration(returnMethod);
68453             var initializer = ancestorFacts & 2 ?
68454                 ts.inlineExpressions([ts.createAssignment(errorRecord, ts.createVoidZero()), callValues]) :
68455                 callValues;
68456             var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([
68457                 ts.setTextRange(ts.createVariableDeclaration(iterator, undefined, initializer), node.expression),
68458                 ts.createVariableDeclaration(result)
68459             ]), node.expression), 2097152), ts.createComma(ts.createAssignment(result, createDownlevelAwait(callNext)), ts.createLogicalNot(getDone)), undefined, convertForOfStatementHead(node, getValue)), node), 256);
68460             return ts.createTry(ts.createBlock([
68461                 ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement)
68462             ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([
68463                 ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([
68464                     ts.createPropertyAssignment("error", catchVariable)
68465                 ])))
68466             ]), 1)), ts.createBlock([
68467                 ts.createTry(ts.createBlock([
68468                     ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(getDone)), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createExpressionStatement(createDownlevelAwait(callReturn))), 1)
68469                 ]), undefined, ts.setEmitFlags(ts.createBlock([
68470                     ts.setEmitFlags(ts.createIf(errorRecord, ts.createThrow(ts.createPropertyAccess(errorRecord, "error"))), 1)
68471                 ]), 1))
68472             ]));
68473         }
68474         function visitParameter(node) {
68475             if (node.transformFlags & 16384) {
68476                 return ts.updateParameter(node, undefined, undefined, node.dotDotDotToken, ts.getGeneratedNameForNode(node), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
68477             }
68478             return ts.visitEachChild(node, visitor, context);
68479         }
68480         function visitConstructorDeclaration(node) {
68481             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68482             enclosingFunctionFlags = 0;
68483             var updated = ts.updateConstructor(node, undefined, node.modifiers, ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
68484             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68485             return updated;
68486         }
68487         function visitGetAccessorDeclaration(node) {
68488             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68489             enclosingFunctionFlags = 0;
68490             var updated = ts.updateGetAccessor(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node));
68491             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68492             return updated;
68493         }
68494         function visitSetAccessorDeclaration(node) {
68495             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68496             enclosingFunctionFlags = 0;
68497             var updated = ts.updateSetAccessor(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
68498             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68499             return updated;
68500         }
68501         function visitMethodDeclaration(node) {
68502             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68503             enclosingFunctionFlags = ts.getFunctionFlags(node);
68504             var updated = ts.updateMethod(node, undefined, enclosingFunctionFlags & 1
68505                 ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
68506                 : node.modifiers, enclosingFunctionFlags & 2
68507                 ? undefined
68508                 : 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
68509                 ? transformAsyncGeneratorFunctionBody(node)
68510                 : transformFunctionBody(node));
68511             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68512             return updated;
68513         }
68514         function visitFunctionDeclaration(node) {
68515             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68516             enclosingFunctionFlags = ts.getFunctionFlags(node);
68517             var updated = ts.updateFunctionDeclaration(node, undefined, enclosingFunctionFlags & 1
68518                 ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
68519                 : node.modifiers, enclosingFunctionFlags & 2
68520                 ? undefined
68521                 : node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1
68522                 ? transformAsyncGeneratorFunctionBody(node)
68523                 : transformFunctionBody(node));
68524             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68525             return updated;
68526         }
68527         function visitArrowFunction(node) {
68528             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68529             enclosingFunctionFlags = ts.getFunctionFlags(node);
68530             var updated = ts.updateArrowFunction(node, node.modifiers, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.equalsGreaterThanToken, transformFunctionBody(node));
68531             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68532             return updated;
68533         }
68534         function visitFunctionExpression(node) {
68535             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
68536             enclosingFunctionFlags = ts.getFunctionFlags(node);
68537             var updated = ts.updateFunctionExpression(node, enclosingFunctionFlags & 1
68538                 ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
68539                 : node.modifiers, enclosingFunctionFlags & 2
68540                 ? undefined
68541                 : node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1
68542                 ? transformAsyncGeneratorFunctionBody(node)
68543                 : transformFunctionBody(node));
68544             enclosingFunctionFlags = savedEnclosingFunctionFlags;
68545             return updated;
68546         }
68547         function transformAsyncGeneratorFunctionBody(node) {
68548             resumeLexicalEnvironment();
68549             var statements = [];
68550             var statementOffset = ts.addPrologue(statements, node.body.statements, false, visitor);
68551             appendObjectRestAssignmentsIfNeeded(statements, node);
68552             var savedCapturedSuperProperties = capturedSuperProperties;
68553             var savedHasSuperElementAccess = hasSuperElementAccess;
68554             capturedSuperProperties = ts.createUnderscoreEscapedMap();
68555             hasSuperElementAccess = false;
68556             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)));
68557             var emitSuperHelpers = languageVersion >= 2 && resolver.getNodeCheckFlags(node) & (4096 | 2048);
68558             if (emitSuperHelpers) {
68559                 enableSubstitutionForAsyncMethodsWithSuper();
68560                 var variableStatement = ts.createSuperAccessVariableStatement(resolver, node, capturedSuperProperties);
68561                 substitutedSuperAccessors[ts.getNodeId(variableStatement)] = true;
68562                 ts.insertStatementsAfterStandardPrologue(statements, [variableStatement]);
68563             }
68564             statements.push(returnStatement);
68565             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
68566             var block = ts.updateBlock(node.body, statements);
68567             if (emitSuperHelpers && hasSuperElementAccess) {
68568                 if (resolver.getNodeCheckFlags(node) & 4096) {
68569                     ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
68570                 }
68571                 else if (resolver.getNodeCheckFlags(node) & 2048) {
68572                     ts.addEmitHelper(block, ts.asyncSuperHelper);
68573                 }
68574             }
68575             capturedSuperProperties = savedCapturedSuperProperties;
68576             hasSuperElementAccess = savedHasSuperElementAccess;
68577             return block;
68578         }
68579         function transformFunctionBody(node) {
68580             resumeLexicalEnvironment();
68581             var statementOffset = 0;
68582             var statements = [];
68583             var body = ts.visitNode(node.body, visitor, ts.isConciseBody);
68584             if (ts.isBlock(body)) {
68585                 statementOffset = ts.addPrologue(statements, body.statements, false, visitor);
68586             }
68587             ts.addRange(statements, appendObjectRestAssignmentsIfNeeded(undefined, node));
68588             var leadingStatements = endLexicalEnvironment();
68589             if (statementOffset > 0 || ts.some(statements) || ts.some(leadingStatements)) {
68590                 var block = ts.convertToFunctionBody(body, true);
68591                 ts.insertStatementsAfterStandardPrologue(statements, leadingStatements);
68592                 ts.addRange(statements, block.statements.slice(statementOffset));
68593                 return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(statements), block.statements));
68594             }
68595             return body;
68596         }
68597         function appendObjectRestAssignmentsIfNeeded(statements, node) {
68598             for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
68599                 var parameter = _a[_i];
68600                 if (parameter.transformFlags & 16384) {
68601                     var temp = ts.getGeneratedNameForNode(parameter);
68602                     var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1, temp, false, true);
68603                     if (ts.some(declarations)) {
68604                         var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList(declarations));
68605                         ts.setEmitFlags(statement, 1048576);
68606                         statements = ts.append(statements, statement);
68607                     }
68608                 }
68609             }
68610             return statements;
68611         }
68612         function enableSubstitutionForAsyncMethodsWithSuper() {
68613             if ((enabledSubstitutions & 1) === 0) {
68614                 enabledSubstitutions |= 1;
68615                 context.enableSubstitution(196);
68616                 context.enableSubstitution(194);
68617                 context.enableSubstitution(195);
68618                 context.enableEmitNotification(245);
68619                 context.enableEmitNotification(161);
68620                 context.enableEmitNotification(163);
68621                 context.enableEmitNotification(164);
68622                 context.enableEmitNotification(162);
68623                 context.enableEmitNotification(225);
68624             }
68625         }
68626         function onEmitNode(hint, node, emitCallback) {
68627             if (enabledSubstitutions & 1 && isSuperContainer(node)) {
68628                 var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 | 4096);
68629                 if (superContainerFlags !== enclosingSuperContainerFlags) {
68630                     var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
68631                     enclosingSuperContainerFlags = superContainerFlags;
68632                     previousOnEmitNode(hint, node, emitCallback);
68633                     enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
68634                     return;
68635                 }
68636             }
68637             else if (enabledSubstitutions && substitutedSuperAccessors[ts.getNodeId(node)]) {
68638                 var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
68639                 enclosingSuperContainerFlags = 0;
68640                 previousOnEmitNode(hint, node, emitCallback);
68641                 enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
68642                 return;
68643             }
68644             previousOnEmitNode(hint, node, emitCallback);
68645         }
68646         function onSubstituteNode(hint, node) {
68647             node = previousOnSubstituteNode(hint, node);
68648             if (hint === 1 && enclosingSuperContainerFlags) {
68649                 return substituteExpression(node);
68650             }
68651             return node;
68652         }
68653         function substituteExpression(node) {
68654             switch (node.kind) {
68655                 case 194:
68656                     return substitutePropertyAccessExpression(node);
68657                 case 195:
68658                     return substituteElementAccessExpression(node);
68659                 case 196:
68660                     return substituteCallExpression(node);
68661             }
68662             return node;
68663         }
68664         function substitutePropertyAccessExpression(node) {
68665             if (node.expression.kind === 102) {
68666                 return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node);
68667             }
68668             return node;
68669         }
68670         function substituteElementAccessExpression(node) {
68671             if (node.expression.kind === 102) {
68672                 return createSuperElementAccessInAsyncMethod(node.argumentExpression, node);
68673             }
68674             return node;
68675         }
68676         function substituteCallExpression(node) {
68677             var expression = node.expression;
68678             if (ts.isSuperProperty(expression)) {
68679                 var argumentExpression = ts.isPropertyAccessExpression(expression)
68680                     ? substitutePropertyAccessExpression(expression)
68681                     : substituteElementAccessExpression(expression);
68682                 return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, __spreadArrays([
68683                     ts.createThis()
68684                 ], node.arguments));
68685             }
68686             return node;
68687         }
68688         function isSuperContainer(node) {
68689             var kind = node.kind;
68690             return kind === 245
68691                 || kind === 162
68692                 || kind === 161
68693                 || kind === 163
68694                 || kind === 164;
68695         }
68696         function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
68697             if (enclosingSuperContainerFlags & 4096) {
68698                 return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_superIndex"), undefined, [argumentExpression]), "value"), location);
68699             }
68700             else {
68701                 return ts.setTextRange(ts.createCall(ts.createIdentifier("_superIndex"), undefined, [argumentExpression]), location);
68702             }
68703         }
68704     }
68705     ts.transformES2018 = transformES2018;
68706     ts.assignHelper = {
68707         name: "typescript:assign",
68708         importName: "__assign",
68709         scoped: false,
68710         priority: 1,
68711         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            };"
68712     };
68713     function createAssignHelper(context, attributesSegments) {
68714         if (context.getCompilerOptions().target >= 2) {
68715             return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), undefined, attributesSegments);
68716         }
68717         context.requestEmitHelper(ts.assignHelper);
68718         return ts.createCall(ts.getUnscopedHelperName("__assign"), undefined, attributesSegments);
68719     }
68720     ts.createAssignHelper = createAssignHelper;
68721     ts.awaitHelper = {
68722         name: "typescript:await",
68723         importName: "__await",
68724         scoped: false,
68725         text: "\n            var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }"
68726     };
68727     function createAwaitHelper(context, expression) {
68728         context.requestEmitHelper(ts.awaitHelper);
68729         return ts.createCall(ts.getUnscopedHelperName("__await"), undefined, [expression]);
68730     }
68731     ts.asyncGeneratorHelper = {
68732         name: "typescript:asyncGenerator",
68733         importName: "__asyncGenerator",
68734         scoped: false,
68735         dependencies: [ts.awaitHelper],
68736         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            };"
68737     };
68738     function createAsyncGeneratorHelper(context, generatorFunc, hasLexicalThis) {
68739         context.requestEmitHelper(ts.asyncGeneratorHelper);
68740         (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 | 524288;
68741         return ts.createCall(ts.getUnscopedHelperName("__asyncGenerator"), undefined, [
68742             hasLexicalThis ? ts.createThis() : ts.createVoidZero(),
68743             ts.createIdentifier("arguments"),
68744             generatorFunc
68745         ]);
68746     }
68747     ts.asyncDelegator = {
68748         name: "typescript:asyncDelegator",
68749         importName: "__asyncDelegator",
68750         scoped: false,
68751         dependencies: [ts.awaitHelper],
68752         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            };"
68753     };
68754     function createAsyncDelegatorHelper(context, expression, location) {
68755         context.requestEmitHelper(ts.asyncDelegator);
68756         return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncDelegator"), undefined, [expression]), location);
68757     }
68758     ts.asyncValues = {
68759         name: "typescript:asyncValues",
68760         importName: "__asyncValues",
68761         scoped: false,
68762         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            };"
68763     };
68764     function createAsyncValuesHelper(context, expression, location) {
68765         context.requestEmitHelper(ts.asyncValues);
68766         return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncValues"), undefined, [expression]), location);
68767     }
68768 })(ts || (ts = {}));
68769 var ts;
68770 (function (ts) {
68771     function transformES2019(context) {
68772         return ts.chainBundle(transformSourceFile);
68773         function transformSourceFile(node) {
68774             if (node.isDeclarationFile) {
68775                 return node;
68776             }
68777             return ts.visitEachChild(node, visitor, context);
68778         }
68779         function visitor(node) {
68780             if ((node.transformFlags & 16) === 0) {
68781                 return node;
68782             }
68783             switch (node.kind) {
68784                 case 280:
68785                     return visitCatchClause(node);
68786                 default:
68787                     return ts.visitEachChild(node, visitor, context);
68788             }
68789         }
68790         function visitCatchClause(node) {
68791             if (!node.variableDeclaration) {
68792                 return ts.updateCatchClause(node, ts.createVariableDeclaration(ts.createTempVariable(undefined)), ts.visitNode(node.block, visitor, ts.isBlock));
68793             }
68794             return ts.visitEachChild(node, visitor, context);
68795         }
68796     }
68797     ts.transformES2019 = transformES2019;
68798 })(ts || (ts = {}));
68799 var ts;
68800 (function (ts) {
68801     function transformES2020(context) {
68802         var hoistVariableDeclaration = context.hoistVariableDeclaration;
68803         return ts.chainBundle(transformSourceFile);
68804         function transformSourceFile(node) {
68805             if (node.isDeclarationFile) {
68806                 return node;
68807             }
68808             return ts.visitEachChild(node, visitor, context);
68809         }
68810         function visitor(node) {
68811             if ((node.transformFlags & 8) === 0) {
68812                 return node;
68813             }
68814             switch (node.kind) {
68815                 case 194:
68816                 case 195:
68817                 case 196:
68818                     if (node.flags & 32) {
68819                         var updated = visitOptionalExpression(node, false, false);
68820                         ts.Debug.assertNotNode(updated, ts.isSyntheticReference);
68821                         return updated;
68822                     }
68823                     return ts.visitEachChild(node, visitor, context);
68824                 case 209:
68825                     if (node.operatorToken.kind === 60) {
68826                         return transformNullishCoalescingExpression(node);
68827                     }
68828                     return ts.visitEachChild(node, visitor, context);
68829                 case 203:
68830                     return visitDeleteExpression(node);
68831                 default:
68832                     return ts.visitEachChild(node, visitor, context);
68833             }
68834         }
68835         function flattenChain(chain) {
68836             ts.Debug.assertNotNode(chain, ts.isNonNullChain);
68837             var links = [chain];
68838             while (!chain.questionDotToken && !ts.isTaggedTemplateExpression(chain)) {
68839                 chain = ts.cast(ts.skipPartiallyEmittedExpressions(chain.expression), ts.isOptionalChain);
68840                 ts.Debug.assertNotNode(chain, ts.isNonNullChain);
68841                 links.unshift(chain);
68842             }
68843             return { expression: chain.expression, chain: links };
68844         }
68845         function visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete) {
68846             var expression = visitNonOptionalExpression(node.expression, captureThisArg, isDelete);
68847             if (ts.isSyntheticReference(expression)) {
68848                 return ts.createSyntheticReferenceExpression(ts.updateParen(node, expression.expression), expression.thisArg);
68849             }
68850             return ts.updateParen(node, expression);
68851         }
68852         function visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete) {
68853             if (ts.isOptionalChain(node)) {
68854                 return visitOptionalExpression(node, captureThisArg, isDelete);
68855             }
68856             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
68857             ts.Debug.assertNotNode(expression, ts.isSyntheticReference);
68858             var thisArg;
68859             if (captureThisArg) {
68860                 if (shouldCaptureInTempVariable(expression)) {
68861                     thisArg = ts.createTempVariable(hoistVariableDeclaration);
68862                     expression = ts.createAssignment(thisArg, expression);
68863                 }
68864                 else {
68865                     thisArg = expression;
68866                 }
68867             }
68868             expression = node.kind === 194
68869                 ? ts.updatePropertyAccess(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier))
68870                 : ts.updateElementAccess(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression));
68871             return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression;
68872         }
68873         function visitNonOptionalCallExpression(node, captureThisArg) {
68874             if (ts.isOptionalChain(node)) {
68875                 return visitOptionalExpression(node, captureThisArg, false);
68876             }
68877             return ts.visitEachChild(node, visitor, context);
68878         }
68879         function visitNonOptionalExpression(node, captureThisArg, isDelete) {
68880             switch (node.kind) {
68881                 case 200: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete);
68882                 case 194:
68883                 case 195: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete);
68884                 case 196: return visitNonOptionalCallExpression(node, captureThisArg);
68885                 default: return ts.visitNode(node, visitor, ts.isExpression);
68886             }
68887         }
68888         function visitOptionalExpression(node, captureThisArg, isDelete) {
68889             var _a = flattenChain(node), expression = _a.expression, chain = _a.chain;
68890             var left = visitNonOptionalExpression(expression, ts.isCallChain(chain[0]), false);
68891             var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined;
68892             var leftExpression = ts.isSyntheticReference(left) ? left.expression : left;
68893             var capturedLeft = leftExpression;
68894             if (shouldCaptureInTempVariable(leftExpression)) {
68895                 capturedLeft = ts.createTempVariable(hoistVariableDeclaration);
68896                 leftExpression = ts.createAssignment(capturedLeft, leftExpression);
68897             }
68898             var rightExpression = capturedLeft;
68899             var thisArg;
68900             for (var i = 0; i < chain.length; i++) {
68901                 var segment = chain[i];
68902                 switch (segment.kind) {
68903                     case 194:
68904                     case 195:
68905                         if (i === chain.length - 1 && captureThisArg) {
68906                             if (shouldCaptureInTempVariable(rightExpression)) {
68907                                 thisArg = ts.createTempVariable(hoistVariableDeclaration);
68908                                 rightExpression = ts.createAssignment(thisArg, rightExpression);
68909                             }
68910                             else {
68911                                 thisArg = rightExpression;
68912                             }
68913                         }
68914                         rightExpression = segment.kind === 194
68915                             ? ts.createPropertyAccess(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier))
68916                             : ts.createElementAccess(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression));
68917                         break;
68918                     case 196:
68919                         if (i === 0 && leftThisArg) {
68920                             rightExpression = ts.createFunctionCall(rightExpression, leftThisArg.kind === 102 ? ts.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression));
68921                         }
68922                         else {
68923                             rightExpression = ts.createCall(rightExpression, undefined, ts.visitNodes(segment.arguments, visitor, ts.isExpression));
68924                         }
68925                         break;
68926                 }
68927                 ts.setOriginalNode(rightExpression, segment);
68928             }
68929             var target = isDelete
68930                 ? ts.createConditional(createNotNullCondition(leftExpression, capturedLeft, true), ts.createTrue(), ts.createDelete(rightExpression))
68931                 : ts.createConditional(createNotNullCondition(leftExpression, capturedLeft, true), ts.createVoidZero(), rightExpression);
68932             return thisArg ? ts.createSyntheticReferenceExpression(target, thisArg) : target;
68933         }
68934         function createNotNullCondition(left, right, invert) {
68935             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()));
68936         }
68937         function transformNullishCoalescingExpression(node) {
68938             var left = ts.visitNode(node.left, visitor, ts.isExpression);
68939             var right = left;
68940             if (shouldCaptureInTempVariable(left)) {
68941                 right = ts.createTempVariable(hoistVariableDeclaration);
68942                 left = ts.createAssignment(right, left);
68943             }
68944             return ts.createConditional(createNotNullCondition(left, right), right, ts.visitNode(node.right, visitor, ts.isExpression));
68945         }
68946         function shouldCaptureInTempVariable(expression) {
68947             return !ts.isIdentifier(expression) &&
68948                 expression.kind !== 104 &&
68949                 expression.kind !== 102;
68950         }
68951         function visitDeleteExpression(node) {
68952             return ts.isOptionalChain(ts.skipParentheses(node.expression))
68953                 ? ts.setOriginalNode(visitNonOptionalExpression(node.expression, false, true), node)
68954                 : ts.updateDelete(node, ts.visitNode(node.expression, visitor, ts.isExpression));
68955         }
68956     }
68957     ts.transformES2020 = transformES2020;
68958 })(ts || (ts = {}));
68959 var ts;
68960 (function (ts) {
68961     function transformESNext(context) {
68962         return ts.chainBundle(transformSourceFile);
68963         function transformSourceFile(node) {
68964             if (node.isDeclarationFile) {
68965                 return node;
68966             }
68967             return ts.visitEachChild(node, visitor, context);
68968         }
68969         function visitor(node) {
68970             if ((node.transformFlags & 4) === 0) {
68971                 return node;
68972             }
68973             switch (node.kind) {
68974                 default:
68975                     return ts.visitEachChild(node, visitor, context);
68976             }
68977         }
68978     }
68979     ts.transformESNext = transformESNext;
68980 })(ts || (ts = {}));
68981 var ts;
68982 (function (ts) {
68983     function transformJsx(context) {
68984         var compilerOptions = context.getCompilerOptions();
68985         var currentSourceFile;
68986         return ts.chainBundle(transformSourceFile);
68987         function transformSourceFile(node) {
68988             if (node.isDeclarationFile) {
68989                 return node;
68990             }
68991             currentSourceFile = node;
68992             var visited = ts.visitEachChild(node, visitor, context);
68993             ts.addEmitHelpers(visited, context.readEmitHelpers());
68994             return visited;
68995         }
68996         function visitor(node) {
68997             if (node.transformFlags & 2) {
68998                 return visitorWorker(node);
68999             }
69000             else {
69001                 return node;
69002             }
69003         }
69004         function visitorWorker(node) {
69005             switch (node.kind) {
69006                 case 266:
69007                     return visitJsxElement(node, false);
69008                 case 267:
69009                     return visitJsxSelfClosingElement(node, false);
69010                 case 270:
69011                     return visitJsxFragment(node, false);
69012                 case 276:
69013                     return visitJsxExpression(node);
69014                 default:
69015                     return ts.visitEachChild(node, visitor, context);
69016             }
69017         }
69018         function transformJsxChildToExpression(node) {
69019             switch (node.kind) {
69020                 case 11:
69021                     return visitJsxText(node);
69022                 case 276:
69023                     return visitJsxExpression(node);
69024                 case 266:
69025                     return visitJsxElement(node, true);
69026                 case 267:
69027                     return visitJsxSelfClosingElement(node, true);
69028                 case 270:
69029                     return visitJsxFragment(node, true);
69030                 default:
69031                     return ts.Debug.failBadSyntaxKind(node);
69032             }
69033         }
69034         function visitJsxElement(node, isChild) {
69035             return visitJsxOpeningLikeElement(node.openingElement, node.children, isChild, node);
69036         }
69037         function visitJsxSelfClosingElement(node, isChild) {
69038             return visitJsxOpeningLikeElement(node, undefined, isChild, node);
69039         }
69040         function visitJsxFragment(node, isChild) {
69041             return visitJsxOpeningFragment(node.openingFragment, node.children, isChild, node);
69042         }
69043         function visitJsxOpeningLikeElement(node, children, isChild, location) {
69044             var tagName = getTagName(node);
69045             var objectProperties;
69046             var attrs = node.attributes.properties;
69047             if (attrs.length === 0) {
69048                 objectProperties = ts.createNull();
69049             }
69050             else {
69051                 var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread
69052                     ? ts.map(attrs, transformJsxSpreadAttributeToExpression)
69053                     : ts.createObjectLiteral(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); }));
69054                 if (ts.isJsxSpreadAttribute(attrs[0])) {
69055                     segments.unshift(ts.createObjectLiteral());
69056                 }
69057                 objectProperties = ts.singleOrUndefined(segments);
69058                 if (!objectProperties) {
69059                     objectProperties = ts.createAssignHelper(context, segments);
69060                 }
69061             }
69062             var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, tagName, objectProperties, ts.mapDefined(children, transformJsxChildToExpression), node, location);
69063             if (isChild) {
69064                 ts.startOnNewLine(element);
69065             }
69066             return element;
69067         }
69068         function visitJsxOpeningFragment(node, children, isChild, location) {
69069             var element = ts.createExpressionForJsxFragment(context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, ts.mapDefined(children, transformJsxChildToExpression), node, location);
69070             if (isChild) {
69071                 ts.startOnNewLine(element);
69072             }
69073             return element;
69074         }
69075         function transformJsxSpreadAttributeToExpression(node) {
69076             return ts.visitNode(node.expression, visitor, ts.isExpression);
69077         }
69078         function transformJsxAttributeToObjectLiteralElement(node) {
69079             var name = getAttributeName(node);
69080             var expression = transformJsxAttributeInitializer(node.initializer);
69081             return ts.createPropertyAssignment(name, expression);
69082         }
69083         function transformJsxAttributeInitializer(node) {
69084             if (node === undefined) {
69085                 return ts.createTrue();
69086             }
69087             else if (node.kind === 10) {
69088                 var literal = ts.createLiteral(tryDecodeEntities(node.text) || node.text);
69089                 literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile);
69090                 return ts.setTextRange(literal, node);
69091             }
69092             else if (node.kind === 276) {
69093                 if (node.expression === undefined) {
69094                     return ts.createTrue();
69095                 }
69096                 return visitJsxExpression(node);
69097             }
69098             else {
69099                 return ts.Debug.failBadSyntaxKind(node);
69100             }
69101         }
69102         function visitJsxText(node) {
69103             var fixed = fixupWhitespaceAndDecodeEntities(node.text);
69104             return fixed === undefined ? undefined : ts.createLiteral(fixed);
69105         }
69106         function fixupWhitespaceAndDecodeEntities(text) {
69107             var acc;
69108             var firstNonWhitespace = 0;
69109             var lastNonWhitespace = -1;
69110             for (var i = 0; i < text.length; i++) {
69111                 var c = text.charCodeAt(i);
69112                 if (ts.isLineBreak(c)) {
69113                     if (firstNonWhitespace !== -1 && lastNonWhitespace !== -1) {
69114                         acc = addLineOfJsxText(acc, text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1));
69115                     }
69116                     firstNonWhitespace = -1;
69117                 }
69118                 else if (!ts.isWhiteSpaceSingleLine(c)) {
69119                     lastNonWhitespace = i;
69120                     if (firstNonWhitespace === -1) {
69121                         firstNonWhitespace = i;
69122                     }
69123                 }
69124             }
69125             return firstNonWhitespace !== -1
69126                 ? addLineOfJsxText(acc, text.substr(firstNonWhitespace))
69127                 : acc;
69128         }
69129         function addLineOfJsxText(acc, trimmedLine) {
69130             var decoded = decodeEntities(trimmedLine);
69131             return acc === undefined ? decoded : acc + " " + decoded;
69132         }
69133         function decodeEntities(text) {
69134             return text.replace(/&((#((\d+)|x([\da-fA-F]+)))|(\w+));/g, function (match, _all, _number, _digits, decimal, hex, word) {
69135                 if (decimal) {
69136                     return ts.utf16EncodeAsString(parseInt(decimal, 10));
69137                 }
69138                 else if (hex) {
69139                     return ts.utf16EncodeAsString(parseInt(hex, 16));
69140                 }
69141                 else {
69142                     var ch = entities.get(word);
69143                     return ch ? ts.utf16EncodeAsString(ch) : match;
69144                 }
69145             });
69146         }
69147         function tryDecodeEntities(text) {
69148             var decoded = decodeEntities(text);
69149             return decoded === text ? undefined : decoded;
69150         }
69151         function getTagName(node) {
69152             if (node.kind === 266) {
69153                 return getTagName(node.openingElement);
69154             }
69155             else {
69156                 var name = node.tagName;
69157                 if (ts.isIdentifier(name) && ts.isIntrinsicJsxName(name.escapedText)) {
69158                     return ts.createLiteral(ts.idText(name));
69159                 }
69160                 else {
69161                     return ts.createExpressionFromEntityName(name);
69162                 }
69163             }
69164         }
69165         function getAttributeName(node) {
69166             var name = node.name;
69167             var text = ts.idText(name);
69168             if (/^[A-Za-z_]\w*$/.test(text)) {
69169                 return name;
69170             }
69171             else {
69172                 return ts.createLiteral(text);
69173             }
69174         }
69175         function visitJsxExpression(node) {
69176             return ts.visitNode(node.expression, visitor, ts.isExpression);
69177         }
69178     }
69179     ts.transformJsx = transformJsx;
69180     var entities = ts.createMapFromTemplate({
69181         quot: 0x0022,
69182         amp: 0x0026,
69183         apos: 0x0027,
69184         lt: 0x003C,
69185         gt: 0x003E,
69186         nbsp: 0x00A0,
69187         iexcl: 0x00A1,
69188         cent: 0x00A2,
69189         pound: 0x00A3,
69190         curren: 0x00A4,
69191         yen: 0x00A5,
69192         brvbar: 0x00A6,
69193         sect: 0x00A7,
69194         uml: 0x00A8,
69195         copy: 0x00A9,
69196         ordf: 0x00AA,
69197         laquo: 0x00AB,
69198         not: 0x00AC,
69199         shy: 0x00AD,
69200         reg: 0x00AE,
69201         macr: 0x00AF,
69202         deg: 0x00B0,
69203         plusmn: 0x00B1,
69204         sup2: 0x00B2,
69205         sup3: 0x00B3,
69206         acute: 0x00B4,
69207         micro: 0x00B5,
69208         para: 0x00B6,
69209         middot: 0x00B7,
69210         cedil: 0x00B8,
69211         sup1: 0x00B9,
69212         ordm: 0x00BA,
69213         raquo: 0x00BB,
69214         frac14: 0x00BC,
69215         frac12: 0x00BD,
69216         frac34: 0x00BE,
69217         iquest: 0x00BF,
69218         Agrave: 0x00C0,
69219         Aacute: 0x00C1,
69220         Acirc: 0x00C2,
69221         Atilde: 0x00C3,
69222         Auml: 0x00C4,
69223         Aring: 0x00C5,
69224         AElig: 0x00C6,
69225         Ccedil: 0x00C7,
69226         Egrave: 0x00C8,
69227         Eacute: 0x00C9,
69228         Ecirc: 0x00CA,
69229         Euml: 0x00CB,
69230         Igrave: 0x00CC,
69231         Iacute: 0x00CD,
69232         Icirc: 0x00CE,
69233         Iuml: 0x00CF,
69234         ETH: 0x00D0,
69235         Ntilde: 0x00D1,
69236         Ograve: 0x00D2,
69237         Oacute: 0x00D3,
69238         Ocirc: 0x00D4,
69239         Otilde: 0x00D5,
69240         Ouml: 0x00D6,
69241         times: 0x00D7,
69242         Oslash: 0x00D8,
69243         Ugrave: 0x00D9,
69244         Uacute: 0x00DA,
69245         Ucirc: 0x00DB,
69246         Uuml: 0x00DC,
69247         Yacute: 0x00DD,
69248         THORN: 0x00DE,
69249         szlig: 0x00DF,
69250         agrave: 0x00E0,
69251         aacute: 0x00E1,
69252         acirc: 0x00E2,
69253         atilde: 0x00E3,
69254         auml: 0x00E4,
69255         aring: 0x00E5,
69256         aelig: 0x00E6,
69257         ccedil: 0x00E7,
69258         egrave: 0x00E8,
69259         eacute: 0x00E9,
69260         ecirc: 0x00EA,
69261         euml: 0x00EB,
69262         igrave: 0x00EC,
69263         iacute: 0x00ED,
69264         icirc: 0x00EE,
69265         iuml: 0x00EF,
69266         eth: 0x00F0,
69267         ntilde: 0x00F1,
69268         ograve: 0x00F2,
69269         oacute: 0x00F3,
69270         ocirc: 0x00F4,
69271         otilde: 0x00F5,
69272         ouml: 0x00F6,
69273         divide: 0x00F7,
69274         oslash: 0x00F8,
69275         ugrave: 0x00F9,
69276         uacute: 0x00FA,
69277         ucirc: 0x00FB,
69278         uuml: 0x00FC,
69279         yacute: 0x00FD,
69280         thorn: 0x00FE,
69281         yuml: 0x00FF,
69282         OElig: 0x0152,
69283         oelig: 0x0153,
69284         Scaron: 0x0160,
69285         scaron: 0x0161,
69286         Yuml: 0x0178,
69287         fnof: 0x0192,
69288         circ: 0x02C6,
69289         tilde: 0x02DC,
69290         Alpha: 0x0391,
69291         Beta: 0x0392,
69292         Gamma: 0x0393,
69293         Delta: 0x0394,
69294         Epsilon: 0x0395,
69295         Zeta: 0x0396,
69296         Eta: 0x0397,
69297         Theta: 0x0398,
69298         Iota: 0x0399,
69299         Kappa: 0x039A,
69300         Lambda: 0x039B,
69301         Mu: 0x039C,
69302         Nu: 0x039D,
69303         Xi: 0x039E,
69304         Omicron: 0x039F,
69305         Pi: 0x03A0,
69306         Rho: 0x03A1,
69307         Sigma: 0x03A3,
69308         Tau: 0x03A4,
69309         Upsilon: 0x03A5,
69310         Phi: 0x03A6,
69311         Chi: 0x03A7,
69312         Psi: 0x03A8,
69313         Omega: 0x03A9,
69314         alpha: 0x03B1,
69315         beta: 0x03B2,
69316         gamma: 0x03B3,
69317         delta: 0x03B4,
69318         epsilon: 0x03B5,
69319         zeta: 0x03B6,
69320         eta: 0x03B7,
69321         theta: 0x03B8,
69322         iota: 0x03B9,
69323         kappa: 0x03BA,
69324         lambda: 0x03BB,
69325         mu: 0x03BC,
69326         nu: 0x03BD,
69327         xi: 0x03BE,
69328         omicron: 0x03BF,
69329         pi: 0x03C0,
69330         rho: 0x03C1,
69331         sigmaf: 0x03C2,
69332         sigma: 0x03C3,
69333         tau: 0x03C4,
69334         upsilon: 0x03C5,
69335         phi: 0x03C6,
69336         chi: 0x03C7,
69337         psi: 0x03C8,
69338         omega: 0x03C9,
69339         thetasym: 0x03D1,
69340         upsih: 0x03D2,
69341         piv: 0x03D6,
69342         ensp: 0x2002,
69343         emsp: 0x2003,
69344         thinsp: 0x2009,
69345         zwnj: 0x200C,
69346         zwj: 0x200D,
69347         lrm: 0x200E,
69348         rlm: 0x200F,
69349         ndash: 0x2013,
69350         mdash: 0x2014,
69351         lsquo: 0x2018,
69352         rsquo: 0x2019,
69353         sbquo: 0x201A,
69354         ldquo: 0x201C,
69355         rdquo: 0x201D,
69356         bdquo: 0x201E,
69357         dagger: 0x2020,
69358         Dagger: 0x2021,
69359         bull: 0x2022,
69360         hellip: 0x2026,
69361         permil: 0x2030,
69362         prime: 0x2032,
69363         Prime: 0x2033,
69364         lsaquo: 0x2039,
69365         rsaquo: 0x203A,
69366         oline: 0x203E,
69367         frasl: 0x2044,
69368         euro: 0x20AC,
69369         image: 0x2111,
69370         weierp: 0x2118,
69371         real: 0x211C,
69372         trade: 0x2122,
69373         alefsym: 0x2135,
69374         larr: 0x2190,
69375         uarr: 0x2191,
69376         rarr: 0x2192,
69377         darr: 0x2193,
69378         harr: 0x2194,
69379         crarr: 0x21B5,
69380         lArr: 0x21D0,
69381         uArr: 0x21D1,
69382         rArr: 0x21D2,
69383         dArr: 0x21D3,
69384         hArr: 0x21D4,
69385         forall: 0x2200,
69386         part: 0x2202,
69387         exist: 0x2203,
69388         empty: 0x2205,
69389         nabla: 0x2207,
69390         isin: 0x2208,
69391         notin: 0x2209,
69392         ni: 0x220B,
69393         prod: 0x220F,
69394         sum: 0x2211,
69395         minus: 0x2212,
69396         lowast: 0x2217,
69397         radic: 0x221A,
69398         prop: 0x221D,
69399         infin: 0x221E,
69400         ang: 0x2220,
69401         and: 0x2227,
69402         or: 0x2228,
69403         cap: 0x2229,
69404         cup: 0x222A,
69405         int: 0x222B,
69406         there4: 0x2234,
69407         sim: 0x223C,
69408         cong: 0x2245,
69409         asymp: 0x2248,
69410         ne: 0x2260,
69411         equiv: 0x2261,
69412         le: 0x2264,
69413         ge: 0x2265,
69414         sub: 0x2282,
69415         sup: 0x2283,
69416         nsub: 0x2284,
69417         sube: 0x2286,
69418         supe: 0x2287,
69419         oplus: 0x2295,
69420         otimes: 0x2297,
69421         perp: 0x22A5,
69422         sdot: 0x22C5,
69423         lceil: 0x2308,
69424         rceil: 0x2309,
69425         lfloor: 0x230A,
69426         rfloor: 0x230B,
69427         lang: 0x2329,
69428         rang: 0x232A,
69429         loz: 0x25CA,
69430         spades: 0x2660,
69431         clubs: 0x2663,
69432         hearts: 0x2665,
69433         diams: 0x2666
69434     });
69435 })(ts || (ts = {}));
69436 var ts;
69437 (function (ts) {
69438     function transformES2016(context) {
69439         var hoistVariableDeclaration = context.hoistVariableDeclaration;
69440         return ts.chainBundle(transformSourceFile);
69441         function transformSourceFile(node) {
69442             if (node.isDeclarationFile) {
69443                 return node;
69444             }
69445             return ts.visitEachChild(node, visitor, context);
69446         }
69447         function visitor(node) {
69448             if ((node.transformFlags & 128) === 0) {
69449                 return node;
69450             }
69451             switch (node.kind) {
69452                 case 209:
69453                     return visitBinaryExpression(node);
69454                 default:
69455                     return ts.visitEachChild(node, visitor, context);
69456             }
69457         }
69458         function visitBinaryExpression(node) {
69459             switch (node.operatorToken.kind) {
69460                 case 66:
69461                     return visitExponentiationAssignmentExpression(node);
69462                 case 42:
69463                     return visitExponentiationExpression(node);
69464                 default:
69465                     return ts.visitEachChild(node, visitor, context);
69466             }
69467         }
69468         function visitExponentiationAssignmentExpression(node) {
69469             var target;
69470             var value;
69471             var left = ts.visitNode(node.left, visitor, ts.isExpression);
69472             var right = ts.visitNode(node.right, visitor, ts.isExpression);
69473             if (ts.isElementAccessExpression(left)) {
69474                 var expressionTemp = ts.createTempVariable(hoistVariableDeclaration);
69475                 var argumentExpressionTemp = ts.createTempVariable(hoistVariableDeclaration);
69476                 target = ts.setTextRange(ts.createElementAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), ts.setTextRange(ts.createAssignment(argumentExpressionTemp, left.argumentExpression), left.argumentExpression)), left);
69477                 value = ts.setTextRange(ts.createElementAccess(expressionTemp, argumentExpressionTemp), left);
69478             }
69479             else if (ts.isPropertyAccessExpression(left)) {
69480                 var expressionTemp = ts.createTempVariable(hoistVariableDeclaration);
69481                 target = ts.setTextRange(ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(expressionTemp, left.expression), left.expression), left.name), left);
69482                 value = ts.setTextRange(ts.createPropertyAccess(expressionTemp, left.name), left);
69483             }
69484             else {
69485                 target = left;
69486                 value = left;
69487             }
69488             return ts.setTextRange(ts.createAssignment(target, ts.createMathPow(value, right, node)), node);
69489         }
69490         function visitExponentiationExpression(node) {
69491             var left = ts.visitNode(node.left, visitor, ts.isExpression);
69492             var right = ts.visitNode(node.right, visitor, ts.isExpression);
69493             return ts.createMathPow(left, right, node);
69494         }
69495     }
69496     ts.transformES2016 = transformES2016;
69497 })(ts || (ts = {}));
69498 var ts;
69499 (function (ts) {
69500     function transformES2015(context) {
69501         var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
69502         var compilerOptions = context.getCompilerOptions();
69503         var resolver = context.getEmitResolver();
69504         var previousOnSubstituteNode = context.onSubstituteNode;
69505         var previousOnEmitNode = context.onEmitNode;
69506         context.onEmitNode = onEmitNode;
69507         context.onSubstituteNode = onSubstituteNode;
69508         var currentSourceFile;
69509         var currentText;
69510         var hierarchyFacts;
69511         var taggedTemplateStringDeclarations;
69512         function recordTaggedTemplateString(temp) {
69513             taggedTemplateStringDeclarations = ts.append(taggedTemplateStringDeclarations, ts.createVariableDeclaration(temp));
69514         }
69515         var convertedLoopState;
69516         var enabledSubstitutions;
69517         return ts.chainBundle(transformSourceFile);
69518         function transformSourceFile(node) {
69519             if (node.isDeclarationFile) {
69520                 return node;
69521             }
69522             currentSourceFile = node;
69523             currentText = node.text;
69524             var visited = visitSourceFile(node);
69525             ts.addEmitHelpers(visited, context.readEmitHelpers());
69526             currentSourceFile = undefined;
69527             currentText = undefined;
69528             taggedTemplateStringDeclarations = undefined;
69529             hierarchyFacts = 0;
69530             return visited;
69531         }
69532         function enterSubtree(excludeFacts, includeFacts) {
69533             var ancestorFacts = hierarchyFacts;
69534             hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383;
69535             return ancestorFacts;
69536         }
69537         function exitSubtree(ancestorFacts, excludeFacts, includeFacts) {
69538             hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 | ancestorFacts;
69539         }
69540         function isReturnVoidStatementInConstructorWithCapturedSuper(node) {
69541             return (hierarchyFacts & 8192) !== 0
69542                 && node.kind === 235
69543                 && !node.expression;
69544         }
69545         function shouldVisitNode(node) {
69546             return (node.transformFlags & 256) !== 0
69547                 || convertedLoopState !== undefined
69548                 || (hierarchyFacts & 8192 && (ts.isStatement(node) || (node.kind === 223)))
69549                 || (ts.isIterationStatement(node, false) && shouldConvertIterationStatement(node))
69550                 || (ts.getEmitFlags(node) & 33554432) !== 0;
69551         }
69552         function visitor(node) {
69553             if (shouldVisitNode(node)) {
69554                 return visitJavaScript(node);
69555             }
69556             else {
69557                 return node;
69558             }
69559         }
69560         function callExpressionVisitor(node) {
69561             if (node.kind === 102) {
69562                 return visitSuperKeyword(true);
69563             }
69564             return visitor(node);
69565         }
69566         function visitJavaScript(node) {
69567             switch (node.kind) {
69568                 case 120:
69569                     return undefined;
69570                 case 245:
69571                     return visitClassDeclaration(node);
69572                 case 214:
69573                     return visitClassExpression(node);
69574                 case 156:
69575                     return visitParameter(node);
69576                 case 244:
69577                     return visitFunctionDeclaration(node);
69578                 case 202:
69579                     return visitArrowFunction(node);
69580                 case 201:
69581                     return visitFunctionExpression(node);
69582                 case 242:
69583                     return visitVariableDeclaration(node);
69584                 case 75:
69585                     return visitIdentifier(node);
69586                 case 243:
69587                     return visitVariableDeclarationList(node);
69588                 case 237:
69589                     return visitSwitchStatement(node);
69590                 case 251:
69591                     return visitCaseBlock(node);
69592                 case 223:
69593                     return visitBlock(node, false);
69594                 case 234:
69595                 case 233:
69596                     return visitBreakOrContinueStatement(node);
69597                 case 238:
69598                     return visitLabeledStatement(node);
69599                 case 228:
69600                 case 229:
69601                     return visitDoOrWhileStatement(node, undefined);
69602                 case 230:
69603                     return visitForStatement(node, undefined);
69604                 case 231:
69605                     return visitForInStatement(node, undefined);
69606                 case 232:
69607                     return visitForOfStatement(node, undefined);
69608                 case 226:
69609                     return visitExpressionStatement(node);
69610                 case 193:
69611                     return visitObjectLiteralExpression(node);
69612                 case 280:
69613                     return visitCatchClause(node);
69614                 case 282:
69615                     return visitShorthandPropertyAssignment(node);
69616                 case 154:
69617                     return visitComputedPropertyName(node);
69618                 case 192:
69619                     return visitArrayLiteralExpression(node);
69620                 case 196:
69621                     return visitCallExpression(node);
69622                 case 197:
69623                     return visitNewExpression(node);
69624                 case 200:
69625                     return visitParenthesizedExpression(node, true);
69626                 case 209:
69627                     return visitBinaryExpression(node, true);
69628                 case 14:
69629                 case 15:
69630                 case 16:
69631                 case 17:
69632                     return visitTemplateLiteral(node);
69633                 case 10:
69634                     return visitStringLiteral(node);
69635                 case 8:
69636                     return visitNumericLiteral(node);
69637                 case 198:
69638                     return visitTaggedTemplateExpression(node);
69639                 case 211:
69640                     return visitTemplateExpression(node);
69641                 case 212:
69642                     return visitYieldExpression(node);
69643                 case 213:
69644                     return visitSpreadElement(node);
69645                 case 102:
69646                     return visitSuperKeyword(false);
69647                 case 104:
69648                     return visitThisKeyword(node);
69649                 case 219:
69650                     return visitMetaProperty(node);
69651                 case 161:
69652                     return visitMethodDeclaration(node);
69653                 case 163:
69654                 case 164:
69655                     return visitAccessorDeclaration(node);
69656                 case 225:
69657                     return visitVariableStatement(node);
69658                 case 235:
69659                     return visitReturnStatement(node);
69660                 default:
69661                     return ts.visitEachChild(node, visitor, context);
69662             }
69663         }
69664         function visitSourceFile(node) {
69665             var ancestorFacts = enterSubtree(8064, 64);
69666             var prologue = [];
69667             var statements = [];
69668             startLexicalEnvironment();
69669             var statementOffset = ts.addStandardPrologue(prologue, node.statements, false);
69670             statementOffset = ts.addCustomPrologue(prologue, node.statements, statementOffset, visitor);
69671             ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset));
69672             if (taggedTemplateStringDeclarations) {
69673                 statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(taggedTemplateStringDeclarations)));
69674             }
69675             ts.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
69676             insertCaptureThisForNodeIfNeeded(prologue, node);
69677             exitSubtree(ancestorFacts, 0, 0);
69678             return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(ts.concatenate(prologue, statements)), node.statements));
69679         }
69680         function visitSwitchStatement(node) {
69681             if (convertedLoopState !== undefined) {
69682                 var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps;
69683                 convertedLoopState.allowedNonLabeledJumps |= 2;
69684                 var result = ts.visitEachChild(node, visitor, context);
69685                 convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps;
69686                 return result;
69687             }
69688             return ts.visitEachChild(node, visitor, context);
69689         }
69690         function visitCaseBlock(node) {
69691             var ancestorFacts = enterSubtree(7104, 0);
69692             var updated = ts.visitEachChild(node, visitor, context);
69693             exitSubtree(ancestorFacts, 0, 0);
69694             return updated;
69695         }
69696         function returnCapturedThis(node) {
69697             return ts.setOriginalNode(ts.createReturn(ts.createFileLevelUniqueName("_this")), node);
69698         }
69699         function visitReturnStatement(node) {
69700             if (convertedLoopState) {
69701                 convertedLoopState.nonLocalJumps |= 8;
69702                 if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) {
69703                     node = returnCapturedThis(node);
69704                 }
69705                 return ts.createReturn(ts.createObjectLiteral([
69706                     ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression
69707                         ? ts.visitNode(node.expression, visitor, ts.isExpression)
69708                         : ts.createVoidZero())
69709                 ]));
69710             }
69711             else if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) {
69712                 return returnCapturedThis(node);
69713             }
69714             return ts.visitEachChild(node, visitor, context);
69715         }
69716         function visitThisKeyword(node) {
69717             if (hierarchyFacts & 2) {
69718                 hierarchyFacts |= 32768;
69719             }
69720             if (convertedLoopState) {
69721                 if (hierarchyFacts & 2) {
69722                     convertedLoopState.containsLexicalThis = true;
69723                     return node;
69724                 }
69725                 return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this"));
69726             }
69727             return node;
69728         }
69729         function visitIdentifier(node) {
69730             if (!convertedLoopState) {
69731                 return node;
69732             }
69733             if (ts.isGeneratedIdentifier(node)) {
69734                 return node;
69735             }
69736             if (node.escapedText !== "arguments" || !resolver.isArgumentsLocalBinding(node)) {
69737                 return node;
69738             }
69739             return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments"));
69740         }
69741         function visitBreakOrContinueStatement(node) {
69742             if (convertedLoopState) {
69743                 var jump = node.kind === 234 ? 2 : 4;
69744                 var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) ||
69745                     (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump));
69746                 if (!canUseBreakOrContinue) {
69747                     var labelMarker = void 0;
69748                     var label = node.label;
69749                     if (!label) {
69750                         if (node.kind === 234) {
69751                             convertedLoopState.nonLocalJumps |= 2;
69752                             labelMarker = "break";
69753                         }
69754                         else {
69755                             convertedLoopState.nonLocalJumps |= 4;
69756                             labelMarker = "continue";
69757                         }
69758                     }
69759                     else {
69760                         if (node.kind === 234) {
69761                             labelMarker = "break-" + label.escapedText;
69762                             setLabeledJump(convertedLoopState, true, ts.idText(label), labelMarker);
69763                         }
69764                         else {
69765                             labelMarker = "continue-" + label.escapedText;
69766                             setLabeledJump(convertedLoopState, false, ts.idText(label), labelMarker);
69767                         }
69768                     }
69769                     var returnExpression = ts.createLiteral(labelMarker);
69770                     if (convertedLoopState.loopOutParameters.length) {
69771                         var outParams = convertedLoopState.loopOutParameters;
69772                         var expr = void 0;
69773                         for (var i = 0; i < outParams.length; i++) {
69774                             var copyExpr = copyOutParameter(outParams[i], 1);
69775                             if (i === 0) {
69776                                 expr = copyExpr;
69777                             }
69778                             else {
69779                                 expr = ts.createBinary(expr, 27, copyExpr);
69780                             }
69781                         }
69782                         returnExpression = ts.createBinary(expr, 27, returnExpression);
69783                     }
69784                     return ts.createReturn(returnExpression);
69785                 }
69786             }
69787             return ts.visitEachChild(node, visitor, context);
69788         }
69789         function visitClassDeclaration(node) {
69790             var variable = ts.createVariableDeclaration(ts.getLocalName(node, true), undefined, transformClassLikeDeclarationToExpression(node));
69791             ts.setOriginalNode(variable, node);
69792             var statements = [];
69793             var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([variable]));
69794             ts.setOriginalNode(statement, node);
69795             ts.setTextRange(statement, node);
69796             ts.startOnNewLine(statement);
69797             statements.push(statement);
69798             if (ts.hasModifier(node, 1)) {
69799                 var exportStatement = ts.hasModifier(node, 512)
69800                     ? ts.createExportDefault(ts.getLocalName(node))
69801                     : ts.createExternalModuleExport(ts.getLocalName(node));
69802                 ts.setOriginalNode(exportStatement, statement);
69803                 statements.push(exportStatement);
69804             }
69805             var emitFlags = ts.getEmitFlags(node);
69806             if ((emitFlags & 4194304) === 0) {
69807                 statements.push(ts.createEndOfDeclarationMarker(node));
69808                 ts.setEmitFlags(statement, emitFlags | 4194304);
69809             }
69810             return ts.singleOrMany(statements);
69811         }
69812         function visitClassExpression(node) {
69813             return transformClassLikeDeclarationToExpression(node);
69814         }
69815         function transformClassLikeDeclarationToExpression(node) {
69816             if (node.name) {
69817                 enableSubstitutionsForBlockScopedBindings();
69818             }
69819             var extendsClauseElement = ts.getClassExtendsHeritageElement(node);
69820             var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter(undefined, undefined, undefined, ts.createFileLevelUniqueName("_super"))] : [], undefined, transformClassBody(node, extendsClauseElement));
69821             ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536) | 524288);
69822             var inner = ts.createPartiallyEmittedExpression(classFunction);
69823             inner.end = node.end;
69824             ts.setEmitFlags(inner, 1536);
69825             var outer = ts.createPartiallyEmittedExpression(inner);
69826             outer.end = ts.skipTrivia(currentText, node.pos);
69827             ts.setEmitFlags(outer, 1536);
69828             var result = ts.createParen(ts.createCall(outer, undefined, extendsClauseElement
69829                 ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)]
69830                 : []));
69831             ts.addSyntheticLeadingComment(result, 3, "* @class ");
69832             return result;
69833         }
69834         function transformClassBody(node, extendsClauseElement) {
69835             var statements = [];
69836             startLexicalEnvironment();
69837             addExtendsHelperIfNeeded(statements, node, extendsClauseElement);
69838             addConstructor(statements, node, extendsClauseElement);
69839             addClassMembers(statements, node);
69840             var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19);
69841             var localName = ts.getInternalName(node);
69842             var outer = ts.createPartiallyEmittedExpression(localName);
69843             outer.end = closingBraceLocation.end;
69844             ts.setEmitFlags(outer, 1536);
69845             var statement = ts.createReturn(outer);
69846             statement.pos = closingBraceLocation.pos;
69847             ts.setEmitFlags(statement, 1536 | 384);
69848             statements.push(statement);
69849             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
69850             var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), node.members), true);
69851             ts.setEmitFlags(block, 1536);
69852             return block;
69853         }
69854         function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) {
69855             if (extendsClauseElement) {
69856                 statements.push(ts.setTextRange(ts.createExpressionStatement(createExtendsHelper(context, ts.getInternalName(node))), extendsClauseElement));
69857             }
69858         }
69859         function addConstructor(statements, node, extendsClauseElement) {
69860             var savedConvertedLoopState = convertedLoopState;
69861             convertedLoopState = undefined;
69862             var ancestorFacts = enterSubtree(16278, 73);
69863             var constructor = ts.getFirstConstructorWithBody(node);
69864             var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined);
69865             var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getInternalName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper));
69866             ts.setTextRange(constructorFunction, constructor || node);
69867             if (extendsClauseElement) {
69868                 ts.setEmitFlags(constructorFunction, 8);
69869             }
69870             statements.push(constructorFunction);
69871             exitSubtree(ancestorFacts, 49152, 0);
69872             convertedLoopState = savedConvertedLoopState;
69873         }
69874         function transformConstructorParameters(constructor, hasSynthesizedSuper) {
69875             return ts.visitParameterList(constructor && !hasSynthesizedSuper ? constructor.parameters : undefined, visitor, context)
69876                 || [];
69877         }
69878         function createDefaultConstructorBody(node, isDerivedClass) {
69879             var statements = [];
69880             resumeLexicalEnvironment();
69881             ts.mergeLexicalEnvironment(statements, endLexicalEnvironment());
69882             if (isDerivedClass) {
69883                 statements.push(ts.createReturn(createDefaultSuperCallOrThis()));
69884             }
69885             var statementsArray = ts.createNodeArray(statements);
69886             ts.setTextRange(statementsArray, node.members);
69887             var block = ts.createBlock(statementsArray, true);
69888             ts.setTextRange(block, node);
69889             ts.setEmitFlags(block, 1536);
69890             return block;
69891         }
69892         function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) {
69893             var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 100;
69894             if (!constructor)
69895                 return createDefaultConstructorBody(node, isDerivedClass);
69896             var prologue = [];
69897             var statements = [];
69898             resumeLexicalEnvironment();
69899             var statementOffset = 0;
69900             if (!hasSynthesizedSuper)
69901                 statementOffset = ts.addStandardPrologue(prologue, constructor.body.statements, false);
69902             addDefaultValueAssignmentsIfNeeded(statements, constructor);
69903             addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper);
69904             if (!hasSynthesizedSuper)
69905                 statementOffset = ts.addCustomPrologue(statements, constructor.body.statements, statementOffset, visitor);
69906             var superCallExpression;
69907             if (hasSynthesizedSuper) {
69908                 superCallExpression = createDefaultSuperCallOrThis();
69909             }
69910             else if (isDerivedClass && statementOffset < constructor.body.statements.length) {
69911                 var firstStatement = constructor.body.statements[statementOffset];
69912                 if (ts.isExpressionStatement(firstStatement) && ts.isSuperCall(firstStatement.expression)) {
69913                     superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression);
69914                 }
69915             }
69916             if (superCallExpression) {
69917                 hierarchyFacts |= 8192;
69918                 statementOffset++;
69919             }
69920             ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset));
69921             ts.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
69922             insertCaptureNewTargetIfNeeded(prologue, constructor, false);
69923             if (isDerivedClass) {
69924                 if (superCallExpression && statementOffset === constructor.body.statements.length && !(constructor.body.transformFlags & 4096)) {
69925                     var superCall = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression);
69926                     var returnStatement = ts.createReturn(superCallExpression);
69927                     ts.setCommentRange(returnStatement, ts.getCommentRange(superCall));
69928                     ts.setEmitFlags(superCall, 1536);
69929                     statements.push(returnStatement);
69930                 }
69931                 else {
69932                     insertCaptureThisForNode(statements, constructor, superCallExpression || createActualThis());
69933                     if (!isSufficientlyCoveredByReturnStatements(constructor.body)) {
69934                         statements.push(ts.createReturn(ts.createFileLevelUniqueName("_this")));
69935                     }
69936                 }
69937             }
69938             else {
69939                 insertCaptureThisForNodeIfNeeded(prologue, constructor);
69940             }
69941             var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(ts.concatenate(prologue, statements)), constructor.body.statements), true);
69942             ts.setTextRange(block, constructor.body);
69943             return block;
69944         }
69945         function isSufficientlyCoveredByReturnStatements(statement) {
69946             if (statement.kind === 235) {
69947                 return true;
69948             }
69949             else if (statement.kind === 227) {
69950                 var ifStatement = statement;
69951                 if (ifStatement.elseStatement) {
69952                     return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) &&
69953                         isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement);
69954                 }
69955             }
69956             else if (statement.kind === 223) {
69957                 var lastStatement = ts.lastOrUndefined(statement.statements);
69958                 if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) {
69959                     return true;
69960                 }
69961             }
69962             return false;
69963         }
69964         function createActualThis() {
69965             return ts.setEmitFlags(ts.createThis(), 4);
69966         }
69967         function createDefaultSuperCallOrThis() {
69968             return ts.createLogicalOr(ts.createLogicalAnd(ts.createStrictInequality(ts.createFileLevelUniqueName("_super"), ts.createNull()), ts.createFunctionApply(ts.createFileLevelUniqueName("_super"), createActualThis(), ts.createIdentifier("arguments"))), createActualThis());
69969         }
69970         function visitParameter(node) {
69971             if (node.dotDotDotToken) {
69972                 return undefined;
69973             }
69974             else if (ts.isBindingPattern(node.name)) {
69975                 return ts.setOriginalNode(ts.setTextRange(ts.createParameter(undefined, undefined, undefined, ts.getGeneratedNameForNode(node), undefined, undefined, undefined), node), node);
69976             }
69977             else if (node.initializer) {
69978                 return ts.setOriginalNode(ts.setTextRange(ts.createParameter(undefined, undefined, undefined, node.name, undefined, undefined, undefined), node), node);
69979             }
69980             else {
69981                 return node;
69982             }
69983         }
69984         function hasDefaultValueOrBindingPattern(node) {
69985             return node.initializer !== undefined
69986                 || ts.isBindingPattern(node.name);
69987         }
69988         function addDefaultValueAssignmentsIfNeeded(statements, node) {
69989             if (!ts.some(node.parameters, hasDefaultValueOrBindingPattern)) {
69990                 return false;
69991             }
69992             var added = false;
69993             for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
69994                 var parameter = _a[_i];
69995                 var name = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken;
69996                 if (dotDotDotToken) {
69997                     continue;
69998                 }
69999                 if (ts.isBindingPattern(name)) {
70000                     added = insertDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) || added;
70001                 }
70002                 else if (initializer) {
70003                     insertDefaultValueAssignmentForInitializer(statements, parameter, name, initializer);
70004                     added = true;
70005                 }
70006             }
70007             return added;
70008         }
70009         function insertDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) {
70010             if (name.elements.length > 0) {
70011                 ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, ts.getGeneratedNameForNode(parameter)))), 1048576));
70012                 return true;
70013             }
70014             else if (initializer) {
70015                 ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(ts.createExpressionStatement(ts.createAssignment(ts.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576));
70016                 return true;
70017             }
70018             return false;
70019         }
70020         function insertDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) {
70021             initializer = ts.visitNode(initializer, visitor, ts.isExpression);
70022             var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.setTextRange(ts.createBlock([
70023                 ts.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer) | 1536)), parameter), 1536))
70024             ]), parameter), 1 | 32 | 384 | 1536));
70025             ts.startOnNewLine(statement);
70026             ts.setTextRange(statement, parameter);
70027             ts.setEmitFlags(statement, 384 | 32 | 1048576 | 1536);
70028             ts.insertStatementAfterCustomPrologue(statements, statement);
70029         }
70030         function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) {
70031             return !!(node && node.dotDotDotToken && !inConstructorWithSynthesizedSuper);
70032         }
70033         function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) {
70034             var prologueStatements = [];
70035             var parameter = ts.lastOrUndefined(node.parameters);
70036             if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) {
70037                 return false;
70038             }
70039             var declarationName = parameter.name.kind === 75 ? ts.getMutableClone(parameter.name) : ts.createTempVariable(undefined);
70040             ts.setEmitFlags(declarationName, 48);
70041             var expressionName = parameter.name.kind === 75 ? ts.getSynthesizedClone(parameter.name) : declarationName;
70042             var restIndex = node.parameters.length - 1;
70043             var temp = ts.createLoopVariable();
70044             prologueStatements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
70045                 ts.createVariableDeclaration(declarationName, undefined, ts.createArrayLiteral([]))
70046             ])), parameter), 1048576));
70047             var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([
70048                 ts.createVariableDeclaration(temp, undefined, ts.createLiteral(restIndex))
70049             ]), parameter), ts.setTextRange(ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length")), parameter), ts.setTextRange(ts.createPostfixIncrement(temp), parameter), ts.createBlock([
70050                 ts.startOnNewLine(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0
70051                     ? temp
70052                     : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), parameter))
70053             ]));
70054             ts.setEmitFlags(forStatement, 1048576);
70055             ts.startOnNewLine(forStatement);
70056             prologueStatements.push(forStatement);
70057             if (parameter.name.kind !== 75) {
70058                 prologueStatements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, expressionName))), parameter), 1048576));
70059             }
70060             ts.insertStatementsAfterCustomPrologue(statements, prologueStatements);
70061             return true;
70062         }
70063         function insertCaptureThisForNodeIfNeeded(statements, node) {
70064             if (hierarchyFacts & 32768 && node.kind !== 202) {
70065                 insertCaptureThisForNode(statements, node, ts.createThis());
70066                 return true;
70067             }
70068             return false;
70069         }
70070         function insertCaptureThisForNode(statements, node, initializer) {
70071             enableSubstitutionsForCapturedThis();
70072             var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
70073                 ts.createVariableDeclaration(ts.createFileLevelUniqueName("_this"), undefined, initializer)
70074             ]));
70075             ts.setEmitFlags(captureThisStatement, 1536 | 1048576);
70076             ts.setSourceMapRange(captureThisStatement, node);
70077             ts.insertStatementAfterCustomPrologue(statements, captureThisStatement);
70078         }
70079         function insertCaptureNewTargetIfNeeded(statements, node, copyOnWrite) {
70080             if (hierarchyFacts & 16384) {
70081                 var newTarget = void 0;
70082                 switch (node.kind) {
70083                     case 202:
70084                         return statements;
70085                     case 161:
70086                     case 163:
70087                     case 164:
70088                         newTarget = ts.createVoidZero();
70089                         break;
70090                     case 162:
70091                         newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor");
70092                         break;
70093                     case 244:
70094                     case 201:
70095                         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());
70096                         break;
70097                     default:
70098                         return ts.Debug.failBadSyntaxKind(node);
70099                 }
70100                 var captureNewTargetStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
70101                     ts.createVariableDeclaration(ts.createFileLevelUniqueName("_newTarget"), undefined, newTarget)
70102                 ]));
70103                 ts.setEmitFlags(captureNewTargetStatement, 1536 | 1048576);
70104                 if (copyOnWrite) {
70105                     statements = statements.slice();
70106                 }
70107                 ts.insertStatementAfterCustomPrologue(statements, captureNewTargetStatement);
70108             }
70109             return statements;
70110         }
70111         function addClassMembers(statements, node) {
70112             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
70113                 var member = _a[_i];
70114                 switch (member.kind) {
70115                     case 222:
70116                         statements.push(transformSemicolonClassElementToStatement(member));
70117                         break;
70118                     case 161:
70119                         statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node));
70120                         break;
70121                     case 163:
70122                     case 164:
70123                         var accessors = ts.getAllAccessorDeclarations(node.members, member);
70124                         if (member === accessors.firstAccessor) {
70125                             statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node));
70126                         }
70127                         break;
70128                     case 162:
70129                         break;
70130                     default:
70131                         ts.Debug.failBadSyntaxKind(member, currentSourceFile && currentSourceFile.fileName);
70132                         break;
70133                 }
70134             }
70135         }
70136         function transformSemicolonClassElementToStatement(member) {
70137             return ts.setTextRange(ts.createEmptyStatement(), member);
70138         }
70139         function transformClassMethodDeclarationToStatement(receiver, member, container) {
70140             var commentRange = ts.getCommentRange(member);
70141             var sourceMapRange = ts.getSourceMapRange(member);
70142             var memberFunction = transformFunctionLikeToExpression(member, member, undefined, container);
70143             var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName);
70144             var e;
70145             if (!ts.isPrivateIdentifier(propertyName) && context.getCompilerOptions().useDefineForClassFields) {
70146                 var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression
70147                     : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText))
70148                         : propertyName;
70149                 e = ts.createObjectDefinePropertyCall(receiver, name, ts.createPropertyDescriptor({ value: memberFunction, enumerable: false, writable: true, configurable: true }));
70150             }
70151             else {
70152                 var memberName = ts.createMemberAccessForPropertyName(receiver, propertyName, member.name);
70153                 e = ts.createAssignment(memberName, memberFunction);
70154             }
70155             ts.setEmitFlags(memberFunction, 1536);
70156             ts.setSourceMapRange(memberFunction, sourceMapRange);
70157             var statement = ts.setTextRange(ts.createExpressionStatement(e), member);
70158             ts.setOriginalNode(statement, member);
70159             ts.setCommentRange(statement, commentRange);
70160             ts.setEmitFlags(statement, 48);
70161             return statement;
70162         }
70163         function transformAccessorsToStatement(receiver, accessors, container) {
70164             var statement = ts.createExpressionStatement(transformAccessorsToExpression(receiver, accessors, container, false));
70165             ts.setEmitFlags(statement, 1536);
70166             ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor));
70167             return statement;
70168         }
70169         function transformAccessorsToExpression(receiver, _a, container, startsOnNewLine) {
70170             var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor;
70171             var target = ts.getMutableClone(receiver);
70172             ts.setEmitFlags(target, 1536 | 32);
70173             ts.setSourceMapRange(target, firstAccessor.name);
70174             var visitedAccessorName = ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName);
70175             if (ts.isPrivateIdentifier(visitedAccessorName)) {
70176                 return ts.Debug.failBadSyntaxKind(visitedAccessorName, "Encountered unhandled private identifier while transforming ES2015.");
70177             }
70178             var propertyName = ts.createExpressionForPropertyName(visitedAccessorName);
70179             ts.setEmitFlags(propertyName, 1536 | 16);
70180             ts.setSourceMapRange(propertyName, firstAccessor.name);
70181             var properties = [];
70182             if (getAccessor) {
70183                 var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined, container);
70184                 ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor));
70185                 ts.setEmitFlags(getterFunction, 512);
70186                 var getter = ts.createPropertyAssignment("get", getterFunction);
70187                 ts.setCommentRange(getter, ts.getCommentRange(getAccessor));
70188                 properties.push(getter);
70189             }
70190             if (setAccessor) {
70191                 var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined, container);
70192                 ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor));
70193                 ts.setEmitFlags(setterFunction, 512);
70194                 var setter = ts.createPropertyAssignment("set", setterFunction);
70195                 ts.setCommentRange(setter, ts.getCommentRange(setAccessor));
70196                 properties.push(setter);
70197             }
70198             properties.push(ts.createPropertyAssignment("enumerable", getAccessor || setAccessor ? ts.createFalse() : ts.createTrue()), ts.createPropertyAssignment("configurable", ts.createTrue()));
70199             var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [
70200                 target,
70201                 propertyName,
70202                 ts.createObjectLiteral(properties, true)
70203             ]);
70204             if (startsOnNewLine) {
70205                 ts.startOnNewLine(call);
70206             }
70207             return call;
70208         }
70209         function visitArrowFunction(node) {
70210             if (node.transformFlags & 4096) {
70211                 hierarchyFacts |= 32768;
70212             }
70213             var savedConvertedLoopState = convertedLoopState;
70214             convertedLoopState = undefined;
70215             var ancestorFacts = enterSubtree(15232, 66);
70216             var func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node));
70217             ts.setTextRange(func, node);
70218             ts.setOriginalNode(func, node);
70219             ts.setEmitFlags(func, 8);
70220             if (hierarchyFacts & 32768) {
70221                 enableSubstitutionsForCapturedThis();
70222             }
70223             exitSubtree(ancestorFacts, 0, 0);
70224             convertedLoopState = savedConvertedLoopState;
70225             return func;
70226         }
70227         function visitFunctionExpression(node) {
70228             var ancestorFacts = ts.getEmitFlags(node) & 262144
70229                 ? enterSubtree(16278, 69)
70230                 : enterSubtree(16286, 65);
70231             var savedConvertedLoopState = convertedLoopState;
70232             convertedLoopState = undefined;
70233             var parameters = ts.visitParameterList(node.parameters, visitor, context);
70234             var body = transformFunctionBody(node);
70235             var name = hierarchyFacts & 16384
70236                 ? ts.getLocalName(node)
70237                 : node.name;
70238             exitSubtree(ancestorFacts, 49152, 0);
70239             convertedLoopState = savedConvertedLoopState;
70240             return ts.updateFunctionExpression(node, undefined, node.asteriskToken, name, undefined, parameters, undefined, body);
70241         }
70242         function visitFunctionDeclaration(node) {
70243             var savedConvertedLoopState = convertedLoopState;
70244             convertedLoopState = undefined;
70245             var ancestorFacts = enterSubtree(16286, 65);
70246             var parameters = ts.visitParameterList(node.parameters, visitor, context);
70247             var body = transformFunctionBody(node);
70248             var name = hierarchyFacts & 16384
70249                 ? ts.getLocalName(node)
70250                 : node.name;
70251             exitSubtree(ancestorFacts, 49152, 0);
70252             convertedLoopState = savedConvertedLoopState;
70253             return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, undefined, parameters, undefined, body);
70254         }
70255         function transformFunctionLikeToExpression(node, location, name, container) {
70256             var savedConvertedLoopState = convertedLoopState;
70257             convertedLoopState = undefined;
70258             var ancestorFacts = container && ts.isClassLike(container) && !ts.hasModifier(node, 32)
70259                 ? enterSubtree(16286, 65 | 8)
70260                 : enterSubtree(16286, 65);
70261             var parameters = ts.visitParameterList(node.parameters, visitor, context);
70262             var body = transformFunctionBody(node);
70263             if (hierarchyFacts & 16384 && !name && (node.kind === 244 || node.kind === 201)) {
70264                 name = ts.getGeneratedNameForNode(node);
70265             }
70266             exitSubtree(ancestorFacts, 49152, 0);
70267             convertedLoopState = savedConvertedLoopState;
70268             return ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, parameters, undefined, body), location), node);
70269         }
70270         function transformFunctionBody(node) {
70271             var multiLine = false;
70272             var singleLine = false;
70273             var statementsLocation;
70274             var closeBraceLocation;
70275             var prologue = [];
70276             var statements = [];
70277             var body = node.body;
70278             var statementOffset;
70279             resumeLexicalEnvironment();
70280             if (ts.isBlock(body)) {
70281                 statementOffset = ts.addStandardPrologue(prologue, body.statements, false);
70282                 statementOffset = ts.addCustomPrologue(statements, body.statements, statementOffset, visitor, ts.isHoistedFunction);
70283                 statementOffset = ts.addCustomPrologue(statements, body.statements, statementOffset, visitor, ts.isHoistedVariableStatement);
70284             }
70285             multiLine = addDefaultValueAssignmentsIfNeeded(statements, node) || multiLine;
70286             multiLine = addRestParameterIfNeeded(statements, node, false) || multiLine;
70287             if (ts.isBlock(body)) {
70288                 statementOffset = ts.addCustomPrologue(statements, body.statements, statementOffset, visitor);
70289                 statementsLocation = body.statements;
70290                 ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset));
70291                 if (!multiLine && body.multiLine) {
70292                     multiLine = true;
70293                 }
70294             }
70295             else {
70296                 ts.Debug.assert(node.kind === 202);
70297                 statementsLocation = ts.moveRangeEnd(body, -1);
70298                 var equalsGreaterThanToken = node.equalsGreaterThanToken;
70299                 if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) {
70300                     if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) {
70301                         singleLine = true;
70302                     }
70303                     else {
70304                         multiLine = true;
70305                     }
70306                 }
70307                 var expression = ts.visitNode(body, visitor, ts.isExpression);
70308                 var returnStatement = ts.createReturn(expression);
70309                 ts.setTextRange(returnStatement, body);
70310                 ts.moveSyntheticComments(returnStatement, body);
70311                 ts.setEmitFlags(returnStatement, 384 | 32 | 1024);
70312                 statements.push(returnStatement);
70313                 closeBraceLocation = body;
70314             }
70315             ts.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
70316             insertCaptureNewTargetIfNeeded(prologue, node, false);
70317             insertCaptureThisForNodeIfNeeded(prologue, node);
70318             if (ts.some(prologue)) {
70319                 multiLine = true;
70320             }
70321             statements.unshift.apply(statements, prologue);
70322             if (ts.isBlock(body) && ts.arrayIsEqualTo(statements, body.statements)) {
70323                 return body;
70324             }
70325             var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), multiLine);
70326             ts.setTextRange(block, node.body);
70327             if (!multiLine && singleLine) {
70328                 ts.setEmitFlags(block, 1);
70329             }
70330             if (closeBraceLocation) {
70331                 ts.setTokenSourceMapRange(block, 19, closeBraceLocation);
70332             }
70333             ts.setOriginalNode(block, node.body);
70334             return block;
70335         }
70336         function visitBlock(node, isFunctionBody) {
70337             if (isFunctionBody) {
70338                 return ts.visitEachChild(node, visitor, context);
70339             }
70340             var ancestorFacts = hierarchyFacts & 256
70341                 ? enterSubtree(7104, 512)
70342                 : enterSubtree(6976, 128);
70343             var updated = ts.visitEachChild(node, visitor, context);
70344             exitSubtree(ancestorFacts, 0, 0);
70345             return updated;
70346         }
70347         function visitExpressionStatement(node) {
70348             switch (node.expression.kind) {
70349                 case 200:
70350                     return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, false));
70351                 case 209:
70352                     return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, false));
70353             }
70354             return ts.visitEachChild(node, visitor, context);
70355         }
70356         function visitParenthesizedExpression(node, needsDestructuringValue) {
70357             if (!needsDestructuringValue) {
70358                 switch (node.expression.kind) {
70359                     case 200:
70360                         return ts.updateParen(node, visitParenthesizedExpression(node.expression, false));
70361                     case 209:
70362                         return ts.updateParen(node, visitBinaryExpression(node.expression, false));
70363                 }
70364             }
70365             return ts.visitEachChild(node, visitor, context);
70366         }
70367         function visitBinaryExpression(node, needsDestructuringValue) {
70368             if (ts.isDestructuringAssignment(node)) {
70369                 return ts.flattenDestructuringAssignment(node, visitor, context, 0, needsDestructuringValue);
70370             }
70371             return ts.visitEachChild(node, visitor, context);
70372         }
70373         function isVariableStatementOfTypeScriptClassWrapper(node) {
70374             return node.declarationList.declarations.length === 1
70375                 && !!node.declarationList.declarations[0].initializer
70376                 && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432);
70377         }
70378         function visitVariableStatement(node) {
70379             var ancestorFacts = enterSubtree(0, ts.hasModifier(node, 1) ? 32 : 0);
70380             var updated;
70381             if (convertedLoopState && (node.declarationList.flags & 3) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) {
70382                 var assignments = void 0;
70383                 for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
70384                     var decl = _a[_i];
70385                     hoistVariableDeclarationDeclaredInConvertedLoop(convertedLoopState, decl);
70386                     if (decl.initializer) {
70387                         var assignment = void 0;
70388                         if (ts.isBindingPattern(decl.name)) {
70389                             assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0);
70390                         }
70391                         else {
70392                             assignment = ts.createBinary(decl.name, 62, ts.visitNode(decl.initializer, visitor, ts.isExpression));
70393                             ts.setTextRange(assignment, decl);
70394                         }
70395                         assignments = ts.append(assignments, assignment);
70396                     }
70397                 }
70398                 if (assignments) {
70399                     updated = ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(assignments)), node);
70400                 }
70401                 else {
70402                     updated = undefined;
70403                 }
70404             }
70405             else {
70406                 updated = ts.visitEachChild(node, visitor, context);
70407             }
70408             exitSubtree(ancestorFacts, 0, 0);
70409             return updated;
70410         }
70411         function visitVariableDeclarationList(node) {
70412             if (node.flags & 3 || node.transformFlags & 131072) {
70413                 if (node.flags & 3) {
70414                     enableSubstitutionsForBlockScopedBindings();
70415                 }
70416                 var declarations = ts.flatMap(node.declarations, node.flags & 1
70417                     ? visitVariableDeclarationInLetDeclarationList
70418                     : visitVariableDeclaration);
70419                 var declarationList = ts.createVariableDeclarationList(declarations);
70420                 ts.setOriginalNode(declarationList, node);
70421                 ts.setTextRange(declarationList, node);
70422                 ts.setCommentRange(declarationList, node);
70423                 if (node.transformFlags & 131072
70424                     && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) {
70425                     ts.setSourceMapRange(declarationList, getRangeUnion(declarations));
70426                 }
70427                 return declarationList;
70428             }
70429             return ts.visitEachChild(node, visitor, context);
70430         }
70431         function getRangeUnion(declarations) {
70432             var pos = -1, end = -1;
70433             for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) {
70434                 var node = declarations_10[_i];
70435                 pos = pos === -1 ? node.pos : node.pos === -1 ? pos : Math.min(pos, node.pos);
70436                 end = Math.max(end, node.end);
70437             }
70438             return ts.createRange(pos, end);
70439         }
70440         function shouldEmitExplicitInitializerForLetDeclaration(node) {
70441             var flags = resolver.getNodeCheckFlags(node);
70442             var isCapturedInFunction = flags & 262144;
70443             var isDeclaredInLoop = flags & 524288;
70444             var emittedAsTopLevel = (hierarchyFacts & 64) !== 0
70445                 || (isCapturedInFunction
70446                     && isDeclaredInLoop
70447                     && (hierarchyFacts & 512) !== 0);
70448             var emitExplicitInitializer = !emittedAsTopLevel
70449                 && (hierarchyFacts & 4096) === 0
70450                 && (!resolver.isDeclarationWithCollidingName(node)
70451                     || (isDeclaredInLoop
70452                         && !isCapturedInFunction
70453                         && (hierarchyFacts & (2048 | 4096)) === 0));
70454             return emitExplicitInitializer;
70455         }
70456         function visitVariableDeclarationInLetDeclarationList(node) {
70457             var name = node.name;
70458             if (ts.isBindingPattern(name)) {
70459                 return visitVariableDeclaration(node);
70460             }
70461             if (!node.initializer && shouldEmitExplicitInitializerForLetDeclaration(node)) {
70462                 var clone_3 = ts.getMutableClone(node);
70463                 clone_3.initializer = ts.createVoidZero();
70464                 return clone_3;
70465             }
70466             return ts.visitEachChild(node, visitor, context);
70467         }
70468         function visitVariableDeclaration(node) {
70469             var ancestorFacts = enterSubtree(32, 0);
70470             var updated;
70471             if (ts.isBindingPattern(node.name)) {
70472                 updated = ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, (ancestorFacts & 32) !== 0);
70473             }
70474             else {
70475                 updated = ts.visitEachChild(node, visitor, context);
70476             }
70477             exitSubtree(ancestorFacts, 0, 0);
70478             return updated;
70479         }
70480         function recordLabel(node) {
70481             convertedLoopState.labels.set(ts.idText(node.label), true);
70482         }
70483         function resetLabel(node) {
70484             convertedLoopState.labels.set(ts.idText(node.label), false);
70485         }
70486         function visitLabeledStatement(node) {
70487             if (convertedLoopState && !convertedLoopState.labels) {
70488                 convertedLoopState.labels = ts.createMap();
70489             }
70490             var statement = ts.unwrapInnermostStatementOfLabel(node, convertedLoopState && recordLabel);
70491             return ts.isIterationStatement(statement, false)
70492                 ? visitIterationStatement(statement, node)
70493                 : ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, ts.liftToBlock), node, convertedLoopState && resetLabel);
70494         }
70495         function visitIterationStatement(node, outermostLabeledStatement) {
70496             switch (node.kind) {
70497                 case 228:
70498                 case 229:
70499                     return visitDoOrWhileStatement(node, outermostLabeledStatement);
70500                 case 230:
70501                     return visitForStatement(node, outermostLabeledStatement);
70502                 case 231:
70503                     return visitForInStatement(node, outermostLabeledStatement);
70504                 case 232:
70505                     return visitForOfStatement(node, outermostLabeledStatement);
70506             }
70507         }
70508         function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) {
70509             var ancestorFacts = enterSubtree(excludeFacts, includeFacts);
70510             var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert);
70511             exitSubtree(ancestorFacts, 0, 0);
70512             return updated;
70513         }
70514         function visitDoOrWhileStatement(node, outermostLabeledStatement) {
70515             return visitIterationStatementWithFacts(0, 1280, node, outermostLabeledStatement);
70516         }
70517         function visitForStatement(node, outermostLabeledStatement) {
70518             return visitIterationStatementWithFacts(5056, 3328, node, outermostLabeledStatement);
70519         }
70520         function visitForInStatement(node, outermostLabeledStatement) {
70521             return visitIterationStatementWithFacts(3008, 5376, node, outermostLabeledStatement);
70522         }
70523         function visitForOfStatement(node, outermostLabeledStatement) {
70524             return visitIterationStatementWithFacts(3008, 5376, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray);
70525         }
70526         function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) {
70527             var statements = [];
70528             var initializer = node.initializer;
70529             if (ts.isVariableDeclarationList(initializer)) {
70530                 if (node.initializer.flags & 3) {
70531                     enableSubstitutionsForBlockScopedBindings();
70532                 }
70533                 var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations);
70534                 if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) {
70535                     var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0, boundValue);
70536                     var declarationList = ts.setTextRange(ts.createVariableDeclarationList(declarations), node.initializer);
70537                     ts.setOriginalNode(declarationList, node.initializer);
70538                     ts.setSourceMapRange(declarationList, ts.createRange(declarations[0].pos, ts.last(declarations).end));
70539                     statements.push(ts.createVariableStatement(undefined, declarationList));
70540                 }
70541                 else {
70542                     statements.push(ts.setTextRange(ts.createVariableStatement(undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([
70543                         ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, boundValue)
70544                     ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1)));
70545                 }
70546             }
70547             else {
70548                 var assignment = ts.createAssignment(initializer, boundValue);
70549                 if (ts.isDestructuringAssignment(assignment)) {
70550                     ts.aggregateTransformFlags(assignment);
70551                     statements.push(ts.createExpressionStatement(visitBinaryExpression(assignment, false)));
70552                 }
70553                 else {
70554                     assignment.end = initializer.end;
70555                     statements.push(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1)));
70556                 }
70557             }
70558             if (convertedLoopBodyStatements) {
70559                 return createSyntheticBlockForConvertedStatements(ts.addRange(statements, convertedLoopBodyStatements));
70560             }
70561             else {
70562                 var statement = ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock);
70563                 if (ts.isBlock(statement)) {
70564                     return ts.updateBlock(statement, ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, statement.statements)), statement.statements));
70565                 }
70566                 else {
70567                     statements.push(statement);
70568                     return createSyntheticBlockForConvertedStatements(statements);
70569                 }
70570             }
70571         }
70572         function createSyntheticBlockForConvertedStatements(statements) {
70573             return ts.setEmitFlags(ts.createBlock(ts.createNodeArray(statements), true), 48 | 384);
70574         }
70575         function convertForOfStatementForArray(node, outermostLabeledStatement, convertedLoopBodyStatements) {
70576             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
70577             var counter = ts.createLoopVariable();
70578             var rhsReference = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(undefined);
70579             ts.setEmitFlags(expression, 48 | ts.getEmitFlags(expression));
70580             var forStatement = ts.setTextRange(ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([
70581                 ts.setTextRange(ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0)), ts.moveRangePos(node.expression, -1)),
70582                 ts.setTextRange(ts.createVariableDeclaration(rhsReference, undefined, expression), node.expression)
70583             ]), 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);
70584             ts.setEmitFlags(forStatement, 256);
70585             ts.setTextRange(forStatement, node);
70586             return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel);
70587         }
70588         function convertForOfStatementForIterable(node, outermostLabeledStatement, convertedLoopBodyStatements, ancestorFacts) {
70589             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
70590             var iterator = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(undefined);
70591             var result = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(iterator) : ts.createTempVariable(undefined);
70592             var errorRecord = ts.createUniqueName("e");
70593             var catchVariable = ts.getGeneratedNameForNode(errorRecord);
70594             var returnMethod = ts.createTempVariable(undefined);
70595             var values = ts.createValuesHelper(context, expression, node.expression);
70596             var next = ts.createCall(ts.createPropertyAccess(iterator, "next"), undefined, []);
70597             hoistVariableDeclaration(errorRecord);
70598             hoistVariableDeclaration(returnMethod);
70599             var initializer = ancestorFacts & 1024
70600                 ? ts.inlineExpressions([ts.createAssignment(errorRecord, ts.createVoidZero()), values])
70601                 : values;
70602             var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([
70603                 ts.setTextRange(ts.createVariableDeclaration(iterator, undefined, initializer), node.expression),
70604                 ts.createVariableDeclaration(result, undefined, next)
70605             ]), node.expression), 2097152), ts.createLogicalNot(ts.createPropertyAccess(result, "done")), ts.createAssignment(result, next), convertForOfStatementHead(node, ts.createPropertyAccess(result, "value"), convertedLoopBodyStatements)), node), 256);
70606             return ts.createTry(ts.createBlock([
70607                 ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel)
70608             ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([
70609                 ts.createExpressionStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([
70610                     ts.createPropertyAssignment("error", catchVariable)
70611                 ])))
70612             ]), 1)), ts.createBlock([
70613                 ts.createTry(ts.createBlock([
70614                     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),
70615                 ]), undefined, ts.setEmitFlags(ts.createBlock([
70616                     ts.setEmitFlags(ts.createIf(errorRecord, ts.createThrow(ts.createPropertyAccess(errorRecord, "error"))), 1)
70617                 ]), 1))
70618             ]));
70619         }
70620         function visitObjectLiteralExpression(node) {
70621             var properties = node.properties;
70622             var numProperties = properties.length;
70623             var numInitialProperties = numProperties;
70624             var numInitialPropertiesWithoutYield = numProperties;
70625             for (var i = 0; i < numProperties; i++) {
70626                 var property = properties[i];
70627                 if ((property.transformFlags & 262144 && hierarchyFacts & 4)
70628                     && i < numInitialPropertiesWithoutYield) {
70629                     numInitialPropertiesWithoutYield = i;
70630                 }
70631                 if (property.name.kind === 154) {
70632                     numInitialProperties = i;
70633                     break;
70634                 }
70635             }
70636             if (numInitialProperties !== numProperties) {
70637                 if (numInitialPropertiesWithoutYield < numInitialProperties) {
70638                     numInitialProperties = numInitialPropertiesWithoutYield;
70639                 }
70640                 var temp = ts.createTempVariable(hoistVariableDeclaration);
70641                 var expressions = [];
70642                 var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), 65536));
70643                 if (node.multiLine) {
70644                     ts.startOnNewLine(assignment);
70645                 }
70646                 expressions.push(assignment);
70647                 addObjectLiteralMembers(expressions, node, temp, numInitialProperties);
70648                 expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp);
70649                 return ts.inlineExpressions(expressions);
70650             }
70651             return ts.visitEachChild(node, visitor, context);
70652         }
70653         function shouldConvertPartOfIterationStatement(node) {
70654             return (resolver.getNodeCheckFlags(node) & 131072) !== 0;
70655         }
70656         function shouldConvertInitializerOfForStatement(node) {
70657             return ts.isForStatement(node) && !!node.initializer && shouldConvertPartOfIterationStatement(node.initializer);
70658         }
70659         function shouldConvertConditionOfForStatement(node) {
70660             return ts.isForStatement(node) && !!node.condition && shouldConvertPartOfIterationStatement(node.condition);
70661         }
70662         function shouldConvertIncrementorOfForStatement(node) {
70663             return ts.isForStatement(node) && !!node.incrementor && shouldConvertPartOfIterationStatement(node.incrementor);
70664         }
70665         function shouldConvertIterationStatement(node) {
70666             return shouldConvertBodyOfIterationStatement(node)
70667                 || shouldConvertInitializerOfForStatement(node);
70668         }
70669         function shouldConvertBodyOfIterationStatement(node) {
70670             return (resolver.getNodeCheckFlags(node) & 65536) !== 0;
70671         }
70672         function hoistVariableDeclarationDeclaredInConvertedLoop(state, node) {
70673             if (!state.hoistedLocalVariables) {
70674                 state.hoistedLocalVariables = [];
70675             }
70676             visit(node.name);
70677             function visit(node) {
70678                 if (node.kind === 75) {
70679                     state.hoistedLocalVariables.push(node);
70680                 }
70681                 else {
70682                     for (var _i = 0, _a = node.elements; _i < _a.length; _i++) {
70683                         var element = _a[_i];
70684                         if (!ts.isOmittedExpression(element)) {
70685                             visit(element.name);
70686                         }
70687                     }
70688                 }
70689             }
70690         }
70691         function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert) {
70692             if (!shouldConvertIterationStatement(node)) {
70693                 var saveAllowedNonLabeledJumps = void 0;
70694                 if (convertedLoopState) {
70695                     saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps;
70696                     convertedLoopState.allowedNonLabeledJumps = 2 | 4;
70697                 }
70698                 var result = convert
70699                     ? convert(node, outermostLabeledStatement, undefined, ancestorFacts)
70700                     : ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel);
70701                 if (convertedLoopState) {
70702                     convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps;
70703                 }
70704                 return result;
70705             }
70706             var currentState = createConvertedLoopState(node);
70707             var statements = [];
70708             var outerConvertedLoopState = convertedLoopState;
70709             convertedLoopState = currentState;
70710             var initializerFunction = shouldConvertInitializerOfForStatement(node) ? createFunctionForInitializerOfForStatement(node, currentState) : undefined;
70711             var bodyFunction = shouldConvertBodyOfIterationStatement(node) ? createFunctionForBodyOfIterationStatement(node, currentState, outerConvertedLoopState) : undefined;
70712             convertedLoopState = outerConvertedLoopState;
70713             if (initializerFunction)
70714                 statements.push(initializerFunction.functionDeclaration);
70715             if (bodyFunction)
70716                 statements.push(bodyFunction.functionDeclaration);
70717             addExtraDeclarationsForConvertedLoop(statements, currentState, outerConvertedLoopState);
70718             if (initializerFunction) {
70719                 statements.push(generateCallToConvertedLoopInitializer(initializerFunction.functionName, initializerFunction.containsYield));
70720             }
70721             var loop;
70722             if (bodyFunction) {
70723                 if (convert) {
70724                     loop = convert(node, outermostLabeledStatement, bodyFunction.part, ancestorFacts);
70725                 }
70726                 else {
70727                     var clone_4 = convertIterationStatementCore(node, initializerFunction, ts.createBlock(bodyFunction.part, true));
70728                     ts.aggregateTransformFlags(clone_4);
70729                     loop = ts.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel);
70730                 }
70731             }
70732             else {
70733                 var clone_5 = convertIterationStatementCore(node, initializerFunction, ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
70734                 ts.aggregateTransformFlags(clone_5);
70735                 loop = ts.restoreEnclosingLabel(clone_5, outermostLabeledStatement, convertedLoopState && resetLabel);
70736             }
70737             statements.push(loop);
70738             return statements;
70739         }
70740         function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) {
70741             switch (node.kind) {
70742                 case 230: return convertForStatement(node, initializerFunction, convertedLoopBody);
70743                 case 231: return convertForInStatement(node, convertedLoopBody);
70744                 case 232: return convertForOfStatement(node, convertedLoopBody);
70745                 case 228: return convertDoStatement(node, convertedLoopBody);
70746                 case 229: return convertWhileStatement(node, convertedLoopBody);
70747                 default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected");
70748             }
70749         }
70750         function convertForStatement(node, initializerFunction, convertedLoopBody) {
70751             var shouldConvertCondition = node.condition && shouldConvertPartOfIterationStatement(node.condition);
70752             var shouldConvertIncrementor = shouldConvertCondition || node.incrementor && shouldConvertPartOfIterationStatement(node.incrementor);
70753             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);
70754         }
70755         function convertForOfStatement(node, convertedLoopBody) {
70756             return ts.updateForOf(node, undefined, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), convertedLoopBody);
70757         }
70758         function convertForInStatement(node, convertedLoopBody) {
70759             return ts.updateForIn(node, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), convertedLoopBody);
70760         }
70761         function convertDoStatement(node, convertedLoopBody) {
70762             return ts.updateDo(node, convertedLoopBody, ts.visitNode(node.expression, visitor, ts.isExpression));
70763         }
70764         function convertWhileStatement(node, convertedLoopBody) {
70765             return ts.updateWhile(node, ts.visitNode(node.expression, visitor, ts.isExpression), convertedLoopBody);
70766         }
70767         function createConvertedLoopState(node) {
70768             var loopInitializer;
70769             switch (node.kind) {
70770                 case 230:
70771                 case 231:
70772                 case 232:
70773                     var initializer = node.initializer;
70774                     if (initializer && initializer.kind === 243) {
70775                         loopInitializer = initializer;
70776                     }
70777                     break;
70778             }
70779             var loopParameters = [];
70780             var loopOutParameters = [];
70781             if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3)) {
70782                 var hasCapturedBindingsInForInitializer = shouldConvertInitializerOfForStatement(node);
70783                 for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) {
70784                     var decl = _a[_i];
70785                     processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
70786                 }
70787             }
70788             var currentState = { loopParameters: loopParameters, loopOutParameters: loopOutParameters };
70789             if (convertedLoopState) {
70790                 if (convertedLoopState.argumentsName) {
70791                     currentState.argumentsName = convertedLoopState.argumentsName;
70792                 }
70793                 if (convertedLoopState.thisName) {
70794                     currentState.thisName = convertedLoopState.thisName;
70795                 }
70796                 if (convertedLoopState.hoistedLocalVariables) {
70797                     currentState.hoistedLocalVariables = convertedLoopState.hoistedLocalVariables;
70798                 }
70799             }
70800             return currentState;
70801         }
70802         function addExtraDeclarationsForConvertedLoop(statements, state, outerState) {
70803             var extraVariableDeclarations;
70804             if (state.argumentsName) {
70805                 if (outerState) {
70806                     outerState.argumentsName = state.argumentsName;
70807                 }
70808                 else {
70809                     (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(state.argumentsName, undefined, ts.createIdentifier("arguments")));
70810                 }
70811             }
70812             if (state.thisName) {
70813                 if (outerState) {
70814                     outerState.thisName = state.thisName;
70815                 }
70816                 else {
70817                     (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(state.thisName, undefined, ts.createIdentifier("this")));
70818                 }
70819             }
70820             if (state.hoistedLocalVariables) {
70821                 if (outerState) {
70822                     outerState.hoistedLocalVariables = state.hoistedLocalVariables;
70823                 }
70824                 else {
70825                     if (!extraVariableDeclarations) {
70826                         extraVariableDeclarations = [];
70827                     }
70828                     for (var _i = 0, _a = state.hoistedLocalVariables; _i < _a.length; _i++) {
70829                         var identifier = _a[_i];
70830                         extraVariableDeclarations.push(ts.createVariableDeclaration(identifier));
70831                     }
70832                 }
70833             }
70834             if (state.loopOutParameters.length) {
70835                 if (!extraVariableDeclarations) {
70836                     extraVariableDeclarations = [];
70837                 }
70838                 for (var _b = 0, _c = state.loopOutParameters; _b < _c.length; _b++) {
70839                     var outParam = _c[_b];
70840                     extraVariableDeclarations.push(ts.createVariableDeclaration(outParam.outParamName));
70841                 }
70842             }
70843             if (state.conditionVariable) {
70844                 if (!extraVariableDeclarations) {
70845                     extraVariableDeclarations = [];
70846                 }
70847                 extraVariableDeclarations.push(ts.createVariableDeclaration(state.conditionVariable, undefined, ts.createFalse()));
70848             }
70849             if (extraVariableDeclarations) {
70850                 statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(extraVariableDeclarations)));
70851             }
70852         }
70853         function createOutVariable(p) {
70854             return ts.createVariableDeclaration(p.originalName, undefined, p.outParamName);
70855         }
70856         function createFunctionForInitializerOfForStatement(node, currentState) {
70857             var functionName = ts.createUniqueName("_loop_init");
70858             var containsYield = (node.initializer.transformFlags & 262144) !== 0;
70859             var emitFlags = 0;
70860             if (currentState.containsLexicalThis)
70861                 emitFlags |= 8;
70862             if (containsYield && hierarchyFacts & 4)
70863                 emitFlags |= 262144;
70864             var statements = [];
70865             statements.push(ts.createVariableStatement(undefined, node.initializer));
70866             copyOutParameters(currentState.loopOutParameters, 2, 1, statements);
70867             var functionDeclaration = ts.createVariableStatement(undefined, ts.setEmitFlags(ts.createVariableDeclarationList([
70868                 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))
70869             ]), 2097152));
70870             var part = ts.createVariableDeclarationList(ts.map(currentState.loopOutParameters, createOutVariable));
70871             return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part };
70872         }
70873         function createFunctionForBodyOfIterationStatement(node, currentState, outerState) {
70874             var functionName = ts.createUniqueName("_loop");
70875             startLexicalEnvironment();
70876             var statement = ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock);
70877             var lexicalEnvironment = endLexicalEnvironment();
70878             var statements = [];
70879             if (shouldConvertConditionOfForStatement(node) || shouldConvertIncrementorOfForStatement(node)) {
70880                 currentState.conditionVariable = ts.createUniqueName("inc");
70881                 statements.push(ts.createIf(currentState.conditionVariable, ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), ts.createStatement(ts.createAssignment(currentState.conditionVariable, ts.createTrue()))));
70882                 if (shouldConvertConditionOfForStatement(node)) {
70883                     statements.push(ts.createIf(ts.createPrefix(53, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement)));
70884                 }
70885             }
70886             if (ts.isBlock(statement)) {
70887                 ts.addRange(statements, statement.statements);
70888             }
70889             else {
70890                 statements.push(statement);
70891             }
70892             copyOutParameters(currentState.loopOutParameters, 1, 1, statements);
70893             ts.insertStatementsAfterStandardPrologue(statements, lexicalEnvironment);
70894             var loopBody = ts.createBlock(statements, true);
70895             if (ts.isBlock(statement))
70896                 ts.setOriginalNode(loopBody, statement);
70897             var containsYield = (node.statement.transformFlags & 262144) !== 0;
70898             var emitFlags = 0;
70899             if (currentState.containsLexicalThis)
70900                 emitFlags |= 8;
70901             if (containsYield && (hierarchyFacts & 4) !== 0)
70902                 emitFlags |= 262144;
70903             var functionDeclaration = ts.createVariableStatement(undefined, ts.setEmitFlags(ts.createVariableDeclarationList([
70904                 ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, containsYield ? ts.createToken(41) : undefined, undefined, undefined, currentState.loopParameters, undefined, loopBody), emitFlags))
70905             ]), 2097152));
70906             var part = generateCallToConvertedLoop(functionName, currentState, outerState, containsYield);
70907             return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part };
70908         }
70909         function copyOutParameter(outParam, copyDirection) {
70910             var source = copyDirection === 0 ? outParam.outParamName : outParam.originalName;
70911             var target = copyDirection === 0 ? outParam.originalName : outParam.outParamName;
70912             return ts.createBinary(target, 62, source);
70913         }
70914         function copyOutParameters(outParams, partFlags, copyDirection, statements) {
70915             for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) {
70916                 var outParam = outParams_1[_i];
70917                 if (outParam.flags & partFlags) {
70918                     statements.push(ts.createExpressionStatement(copyOutParameter(outParam, copyDirection)));
70919                 }
70920             }
70921         }
70922         function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) {
70923             var call = ts.createCall(initFunctionExpressionName, undefined, []);
70924             var callResult = containsYield
70925                 ? ts.createYield(ts.createToken(41), ts.setEmitFlags(call, 8388608))
70926                 : call;
70927             return ts.createStatement(callResult);
70928         }
70929         function generateCallToConvertedLoop(loopFunctionExpressionName, state, outerState, containsYield) {
70930             var statements = [];
70931             var isSimpleLoop = !(state.nonLocalJumps & ~4) &&
70932                 !state.labeledNonLocalBreaks &&
70933                 !state.labeledNonLocalContinues;
70934             var call = ts.createCall(loopFunctionExpressionName, undefined, ts.map(state.loopParameters, function (p) { return p.name; }));
70935             var callResult = containsYield
70936                 ? ts.createYield(ts.createToken(41), ts.setEmitFlags(call, 8388608))
70937                 : call;
70938             if (isSimpleLoop) {
70939                 statements.push(ts.createExpressionStatement(callResult));
70940                 copyOutParameters(state.loopOutParameters, 1, 0, statements);
70941             }
70942             else {
70943                 var loopResultName = ts.createUniqueName("state");
70944                 var stateVariable = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ts.createVariableDeclaration(loopResultName, undefined, callResult)]));
70945                 statements.push(stateVariable);
70946                 copyOutParameters(state.loopOutParameters, 1, 0, statements);
70947                 if (state.nonLocalJumps & 8) {
70948                     var returnStatement = void 0;
70949                     if (outerState) {
70950                         outerState.nonLocalJumps |= 8;
70951                         returnStatement = ts.createReturn(loopResultName);
70952                     }
70953                     else {
70954                         returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value"));
70955                     }
70956                     statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 36, ts.createLiteral("object")), returnStatement));
70957                 }
70958                 if (state.nonLocalJumps & 2) {
70959                     statements.push(ts.createIf(ts.createBinary(loopResultName, 36, ts.createLiteral("break")), ts.createBreak()));
70960                 }
70961                 if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) {
70962                     var caseClauses = [];
70963                     processLabeledJumps(state.labeledNonLocalBreaks, true, loopResultName, outerState, caseClauses);
70964                     processLabeledJumps(state.labeledNonLocalContinues, false, loopResultName, outerState, caseClauses);
70965                     statements.push(ts.createSwitch(loopResultName, ts.createCaseBlock(caseClauses)));
70966                 }
70967             }
70968             return statements;
70969         }
70970         function setLabeledJump(state, isBreak, labelText, labelMarker) {
70971             if (isBreak) {
70972                 if (!state.labeledNonLocalBreaks) {
70973                     state.labeledNonLocalBreaks = ts.createMap();
70974                 }
70975                 state.labeledNonLocalBreaks.set(labelText, labelMarker);
70976             }
70977             else {
70978                 if (!state.labeledNonLocalContinues) {
70979                     state.labeledNonLocalContinues = ts.createMap();
70980                 }
70981                 state.labeledNonLocalContinues.set(labelText, labelMarker);
70982             }
70983         }
70984         function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) {
70985             if (!table) {
70986                 return;
70987             }
70988             table.forEach(function (labelMarker, labelText) {
70989                 var statements = [];
70990                 if (!outerLoop || (outerLoop.labels && outerLoop.labels.get(labelText))) {
70991                     var label = ts.createIdentifier(labelText);
70992                     statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label));
70993                 }
70994                 else {
70995                     setLabeledJump(outerLoop, isBreak, labelText, labelMarker);
70996                     statements.push(ts.createReturn(loopResultName));
70997                 }
70998                 caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements));
70999             });
71000         }
71001         function processLoopVariableDeclaration(container, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer) {
71002             var name = decl.name;
71003             if (ts.isBindingPattern(name)) {
71004                 for (var _i = 0, _a = name.elements; _i < _a.length; _i++) {
71005                     var element = _a[_i];
71006                     if (!ts.isOmittedExpression(element)) {
71007                         processLoopVariableDeclaration(container, element, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
71008                     }
71009                 }
71010             }
71011             else {
71012                 loopParameters.push(ts.createParameter(undefined, undefined, undefined, name));
71013                 var checkFlags = resolver.getNodeCheckFlags(decl);
71014                 if (checkFlags & 4194304 || hasCapturedBindingsInForInitializer) {
71015                     var outParamName = ts.createUniqueName("out_" + ts.idText(name));
71016                     var flags = 0;
71017                     if (checkFlags & 4194304) {
71018                         flags |= 1;
71019                     }
71020                     if (ts.isForStatement(container) && container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) {
71021                         flags |= 2;
71022                     }
71023                     loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName });
71024                 }
71025             }
71026         }
71027         function addObjectLiteralMembers(expressions, node, receiver, start) {
71028             var properties = node.properties;
71029             var numProperties = properties.length;
71030             for (var i = start; i < numProperties; i++) {
71031                 var property = properties[i];
71032                 switch (property.kind) {
71033                     case 163:
71034                     case 164:
71035                         var accessors = ts.getAllAccessorDeclarations(node.properties, property);
71036                         if (property === accessors.firstAccessor) {
71037                             expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine));
71038                         }
71039                         break;
71040                     case 161:
71041                         expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine));
71042                         break;
71043                     case 281:
71044                         expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine));
71045                         break;
71046                     case 282:
71047                         expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine));
71048                         break;
71049                     default:
71050                         ts.Debug.failBadSyntaxKind(node);
71051                         break;
71052                 }
71053             }
71054         }
71055         function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) {
71056             var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression));
71057             ts.setTextRange(expression, property);
71058             if (startsOnNewLine) {
71059                 ts.startOnNewLine(expression);
71060             }
71061             return expression;
71062         }
71063         function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) {
71064             var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name));
71065             ts.setTextRange(expression, property);
71066             if (startsOnNewLine) {
71067                 ts.startOnNewLine(expression);
71068             }
71069             return expression;
71070         }
71071         function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) {
71072             var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined, container));
71073             ts.setTextRange(expression, method);
71074             if (startsOnNewLine) {
71075                 ts.startOnNewLine(expression);
71076             }
71077             return expression;
71078         }
71079         function visitCatchClause(node) {
71080             var ancestorFacts = enterSubtree(7104, 0);
71081             var updated;
71082             ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015.");
71083             if (ts.isBindingPattern(node.variableDeclaration.name)) {
71084                 var temp = ts.createTempVariable(undefined);
71085                 var newVariableDeclaration = ts.createVariableDeclaration(temp);
71086                 ts.setTextRange(newVariableDeclaration, node.variableDeclaration);
71087                 var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp);
71088                 var list = ts.createVariableDeclarationList(vars);
71089                 ts.setTextRange(list, node.variableDeclaration);
71090                 var destructure = ts.createVariableStatement(undefined, list);
71091                 updated = ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure));
71092             }
71093             else {
71094                 updated = ts.visitEachChild(node, visitor, context);
71095             }
71096             exitSubtree(ancestorFacts, 0, 0);
71097             return updated;
71098         }
71099         function addStatementToStartOfBlock(block, statement) {
71100             var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement);
71101             return ts.updateBlock(block, __spreadArrays([statement], transformedStatements));
71102         }
71103         function visitMethodDeclaration(node) {
71104             ts.Debug.assert(!ts.isComputedPropertyName(node.name));
71105             var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined, undefined);
71106             ts.setEmitFlags(functionExpression, 512 | ts.getEmitFlags(functionExpression));
71107             return ts.setTextRange(ts.createPropertyAssignment(node.name, functionExpression), node);
71108         }
71109         function visitAccessorDeclaration(node) {
71110             ts.Debug.assert(!ts.isComputedPropertyName(node.name));
71111             var savedConvertedLoopState = convertedLoopState;
71112             convertedLoopState = undefined;
71113             var ancestorFacts = enterSubtree(16286, 65);
71114             var updated;
71115             var parameters = ts.visitParameterList(node.parameters, visitor, context);
71116             var body = transformFunctionBody(node);
71117             if (node.kind === 163) {
71118                 updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body);
71119             }
71120             else {
71121                 updated = ts.updateSetAccessor(node, node.decorators, node.modifiers, node.name, parameters, body);
71122             }
71123             exitSubtree(ancestorFacts, 49152, 0);
71124             convertedLoopState = savedConvertedLoopState;
71125             return updated;
71126         }
71127         function visitShorthandPropertyAssignment(node) {
71128             return ts.setTextRange(ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name)), node);
71129         }
71130         function visitComputedPropertyName(node) {
71131             return ts.visitEachChild(node, visitor, context);
71132         }
71133         function visitYieldExpression(node) {
71134             return ts.visitEachChild(node, visitor, context);
71135         }
71136         function visitArrayLiteralExpression(node) {
71137             if (ts.some(node.elements, ts.isSpreadElement)) {
71138                 return transformAndSpreadElements(node.elements, true, !!node.multiLine, !!node.elements.hasTrailingComma);
71139             }
71140             return ts.visitEachChild(node, visitor, context);
71141         }
71142         function visitCallExpression(node) {
71143             if (ts.getEmitFlags(node) & 33554432) {
71144                 return visitTypeScriptClassWrapper(node);
71145             }
71146             var expression = ts.skipOuterExpressions(node.expression);
71147             if (expression.kind === 102 ||
71148                 ts.isSuperProperty(expression) ||
71149                 ts.some(node.arguments, ts.isSpreadElement)) {
71150                 return visitCallExpressionWithPotentialCapturedThisAssignment(node, true);
71151             }
71152             return ts.updateCall(node, ts.visitNode(node.expression, callExpressionVisitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression));
71153         }
71154         function visitTypeScriptClassWrapper(node) {
71155             var body = ts.cast(ts.cast(ts.skipOuterExpressions(node.expression), ts.isArrowFunction).body, ts.isBlock);
71156             var isVariableStatementWithInitializer = function (stmt) { return ts.isVariableStatement(stmt) && !!ts.first(stmt.declarationList.declarations).initializer; };
71157             var savedConvertedLoopState = convertedLoopState;
71158             convertedLoopState = undefined;
71159             var bodyStatements = ts.visitNodes(body.statements, visitor, ts.isStatement);
71160             convertedLoopState = savedConvertedLoopState;
71161             var classStatements = ts.filter(bodyStatements, isVariableStatementWithInitializer);
71162             var remainingStatements = ts.filter(bodyStatements, function (stmt) { return !isVariableStatementWithInitializer(stmt); });
71163             var varStatement = ts.cast(ts.first(classStatements), ts.isVariableStatement);
71164             var variable = varStatement.declarationList.declarations[0];
71165             var initializer = ts.skipOuterExpressions(variable.initializer);
71166             var aliasAssignment = ts.tryCast(initializer, ts.isAssignmentExpression);
71167             var call = ts.cast(aliasAssignment ? ts.skipOuterExpressions(aliasAssignment.right) : initializer, ts.isCallExpression);
71168             var func = ts.cast(ts.skipOuterExpressions(call.expression), ts.isFunctionExpression);
71169             var funcStatements = func.body.statements;
71170             var classBodyStart = 0;
71171             var classBodyEnd = -1;
71172             var statements = [];
71173             if (aliasAssignment) {
71174                 var extendsCall = ts.tryCast(funcStatements[classBodyStart], ts.isExpressionStatement);
71175                 if (extendsCall) {
71176                     statements.push(extendsCall);
71177                     classBodyStart++;
71178                 }
71179                 statements.push(funcStatements[classBodyStart]);
71180                 classBodyStart++;
71181                 statements.push(ts.createExpressionStatement(ts.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier))));
71182             }
71183             while (!ts.isReturnStatement(ts.elementAt(funcStatements, classBodyEnd))) {
71184                 classBodyEnd--;
71185             }
71186             ts.addRange(statements, funcStatements, classBodyStart, classBodyEnd);
71187             if (classBodyEnd < -1) {
71188                 ts.addRange(statements, funcStatements, classBodyEnd + 1);
71189             }
71190             ts.addRange(statements, remainingStatements);
71191             ts.addRange(statements, classStatements, 1);
71192             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))));
71193         }
71194         function visitImmediateSuperCallInBody(node) {
71195             return visitCallExpressionWithPotentialCapturedThisAssignment(node, false);
71196         }
71197         function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
71198             if (node.transformFlags & 8192 ||
71199                 node.expression.kind === 102 ||
71200                 ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) {
71201                 var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
71202                 if (node.expression.kind === 102) {
71203                     ts.setEmitFlags(thisArg, 4);
71204                 }
71205                 var resultingCall = void 0;
71206                 if (node.transformFlags & 8192) {
71207                     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));
71208                 }
71209                 else {
71210                     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);
71211                 }
71212                 if (node.expression.kind === 102) {
71213                     var initializer = ts.createLogicalOr(resultingCall, createActualThis());
71214                     resultingCall = assignToCapturedThis
71215                         ? ts.createAssignment(ts.createFileLevelUniqueName("_this"), initializer)
71216                         : initializer;
71217                 }
71218                 return ts.setOriginalNode(resultingCall, node);
71219             }
71220             return ts.visitEachChild(node, visitor, context);
71221         }
71222         function visitNewExpression(node) {
71223             if (ts.some(node.arguments, ts.isSpreadElement)) {
71224                 var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
71225                 return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray(__spreadArrays([ts.createVoidZero()], node.arguments)), false, false, false)), undefined, []);
71226             }
71227             return ts.visitEachChild(node, visitor, context);
71228         }
71229         function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) {
71230             var numElements = elements.length;
71231             var segments = ts.flatten(ts.spanMap(elements, partitionSpread, function (partition, visitPartition, _start, end) {
71232                 return visitPartition(partition, multiLine, hasTrailingComma && end === numElements);
71233             }));
71234             if (compilerOptions.downlevelIteration) {
71235                 if (segments.length === 1) {
71236                     var firstSegment = segments[0];
71237                     if (isCallToHelper(firstSegment, "___spread")) {
71238                         return segments[0];
71239                     }
71240                 }
71241                 return ts.createSpreadHelper(context, segments);
71242             }
71243             else {
71244                 if (segments.length === 1) {
71245                     var firstSegment = segments[0];
71246                     if (!needsUniqueCopy
71247                         || isPackedArrayLiteral(firstSegment)
71248                         || isCallToHelper(firstSegment, "___spreadArrays")) {
71249                         return segments[0];
71250                     }
71251                 }
71252                 return ts.createSpreadArraysHelper(context, segments);
71253             }
71254         }
71255         function isPackedElement(node) {
71256             return !ts.isOmittedExpression(node);
71257         }
71258         function isPackedArrayLiteral(node) {
71259             return ts.isArrayLiteralExpression(node) && ts.every(node.elements, isPackedElement);
71260         }
71261         function isCallToHelper(firstSegment, helperName) {
71262             return ts.isCallExpression(firstSegment)
71263                 && ts.isIdentifier(firstSegment.expression)
71264                 && (ts.getEmitFlags(firstSegment.expression) & 4096)
71265                 && firstSegment.expression.escapedText === helperName;
71266         }
71267         function partitionSpread(node) {
71268             return ts.isSpreadElement(node)
71269                 ? visitSpanOfSpreads
71270                 : visitSpanOfNonSpreads;
71271         }
71272         function visitSpanOfSpreads(chunk) {
71273             return ts.map(chunk, visitExpressionOfSpread);
71274         }
71275         function visitSpanOfNonSpreads(chunk, multiLine, hasTrailingComma) {
71276             return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine);
71277         }
71278         function visitSpreadElement(node) {
71279             return ts.visitNode(node.expression, visitor, ts.isExpression);
71280         }
71281         function visitExpressionOfSpread(node) {
71282             return ts.visitNode(node.expression, visitor, ts.isExpression);
71283         }
71284         function visitTemplateLiteral(node) {
71285             return ts.setTextRange(ts.createLiteral(node.text), node);
71286         }
71287         function visitStringLiteral(node) {
71288             if (node.hasExtendedUnicodeEscape) {
71289                 return ts.setTextRange(ts.createLiteral(node.text), node);
71290             }
71291             return node;
71292         }
71293         function visitNumericLiteral(node) {
71294             if (node.numericLiteralFlags & 384) {
71295                 return ts.setTextRange(ts.createNumericLiteral(node.text), node);
71296             }
71297             return node;
71298         }
71299         function visitTaggedTemplateExpression(node) {
71300             return ts.processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, ts.ProcessLevel.All);
71301         }
71302         function visitTemplateExpression(node) {
71303             var expressions = [];
71304             addTemplateHead(expressions, node);
71305             addTemplateSpans(expressions, node);
71306             var expression = ts.reduceLeft(expressions, ts.createAdd);
71307             if (ts.nodeIsSynthesized(expression)) {
71308                 expression.pos = node.pos;
71309                 expression.end = node.end;
71310             }
71311             return expression;
71312         }
71313         function shouldAddTemplateHead(node) {
71314             ts.Debug.assert(node.templateSpans.length !== 0);
71315             return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0;
71316         }
71317         function addTemplateHead(expressions, node) {
71318             if (!shouldAddTemplateHead(node)) {
71319                 return;
71320             }
71321             expressions.push(ts.createLiteral(node.head.text));
71322         }
71323         function addTemplateSpans(expressions, node) {
71324             for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) {
71325                 var span = _a[_i];
71326                 expressions.push(ts.visitNode(span.expression, visitor, ts.isExpression));
71327                 if (span.literal.text.length !== 0) {
71328                     expressions.push(ts.createLiteral(span.literal.text));
71329                 }
71330             }
71331         }
71332         function visitSuperKeyword(isExpressionOfCall) {
71333             return hierarchyFacts & 8 && !isExpressionOfCall ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") :
71334                 ts.createFileLevelUniqueName("_super");
71335         }
71336         function visitMetaProperty(node) {
71337             if (node.keywordToken === 99 && node.name.escapedText === "target") {
71338                 hierarchyFacts |= 16384;
71339                 return ts.createFileLevelUniqueName("_newTarget");
71340             }
71341             return node;
71342         }
71343         function onEmitNode(hint, node, emitCallback) {
71344             if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) {
71345                 var ancestorFacts = enterSubtree(16286, ts.getEmitFlags(node) & 8
71346                     ? 65 | 16
71347                     : 65);
71348                 previousOnEmitNode(hint, node, emitCallback);
71349                 exitSubtree(ancestorFacts, 0, 0);
71350                 return;
71351             }
71352             previousOnEmitNode(hint, node, emitCallback);
71353         }
71354         function enableSubstitutionsForBlockScopedBindings() {
71355             if ((enabledSubstitutions & 2) === 0) {
71356                 enabledSubstitutions |= 2;
71357                 context.enableSubstitution(75);
71358             }
71359         }
71360         function enableSubstitutionsForCapturedThis() {
71361             if ((enabledSubstitutions & 1) === 0) {
71362                 enabledSubstitutions |= 1;
71363                 context.enableSubstitution(104);
71364                 context.enableEmitNotification(162);
71365                 context.enableEmitNotification(161);
71366                 context.enableEmitNotification(163);
71367                 context.enableEmitNotification(164);
71368                 context.enableEmitNotification(202);
71369                 context.enableEmitNotification(201);
71370                 context.enableEmitNotification(244);
71371             }
71372         }
71373         function onSubstituteNode(hint, node) {
71374             node = previousOnSubstituteNode(hint, node);
71375             if (hint === 1) {
71376                 return substituteExpression(node);
71377             }
71378             if (ts.isIdentifier(node)) {
71379                 return substituteIdentifier(node);
71380             }
71381             return node;
71382         }
71383         function substituteIdentifier(node) {
71384             if (enabledSubstitutions & 2 && !ts.isInternalName(node)) {
71385                 var original = ts.getParseTreeNode(node, ts.isIdentifier);
71386                 if (original && isNameOfDeclarationWithCollidingName(original)) {
71387                     return ts.setTextRange(ts.getGeneratedNameForNode(original), node);
71388                 }
71389             }
71390             return node;
71391         }
71392         function isNameOfDeclarationWithCollidingName(node) {
71393             switch (node.parent.kind) {
71394                 case 191:
71395                 case 245:
71396                 case 248:
71397                 case 242:
71398                     return node.parent.name === node
71399                         && resolver.isDeclarationWithCollidingName(node.parent);
71400             }
71401             return false;
71402         }
71403         function substituteExpression(node) {
71404             switch (node.kind) {
71405                 case 75:
71406                     return substituteExpressionIdentifier(node);
71407                 case 104:
71408                     return substituteThisKeyword(node);
71409             }
71410             return node;
71411         }
71412         function substituteExpressionIdentifier(node) {
71413             if (enabledSubstitutions & 2 && !ts.isInternalName(node)) {
71414                 var declaration = resolver.getReferencedDeclarationWithCollidingName(node);
71415                 if (declaration && !(ts.isClassLike(declaration) && isPartOfClassBody(declaration, node))) {
71416                     return ts.setTextRange(ts.getGeneratedNameForNode(ts.getNameOfDeclaration(declaration)), node);
71417                 }
71418             }
71419             return node;
71420         }
71421         function isPartOfClassBody(declaration, node) {
71422             var currentNode = ts.getParseTreeNode(node);
71423             if (!currentNode || currentNode === declaration || currentNode.end <= declaration.pos || currentNode.pos >= declaration.end) {
71424                 return false;
71425             }
71426             var blockScope = ts.getEnclosingBlockScopeContainer(declaration);
71427             while (currentNode) {
71428                 if (currentNode === blockScope || currentNode === declaration) {
71429                     return false;
71430                 }
71431                 if (ts.isClassElement(currentNode) && currentNode.parent === declaration) {
71432                     return true;
71433                 }
71434                 currentNode = currentNode.parent;
71435             }
71436             return false;
71437         }
71438         function substituteThisKeyword(node) {
71439             if (enabledSubstitutions & 1
71440                 && hierarchyFacts & 16) {
71441                 return ts.setTextRange(ts.createFileLevelUniqueName("_this"), node);
71442             }
71443             return node;
71444         }
71445         function getClassMemberPrefix(node, member) {
71446             return ts.hasModifier(member, 32)
71447                 ? ts.getInternalName(node)
71448                 : ts.createPropertyAccess(ts.getInternalName(node), "prototype");
71449         }
71450         function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) {
71451             if (!constructor || !hasExtendsClause) {
71452                 return false;
71453             }
71454             if (ts.some(constructor.parameters)) {
71455                 return false;
71456             }
71457             var statement = ts.firstOrUndefined(constructor.body.statements);
71458             if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 226) {
71459                 return false;
71460             }
71461             var statementExpression = statement.expression;
71462             if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 196) {
71463                 return false;
71464             }
71465             var callTarget = statementExpression.expression;
71466             if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 102) {
71467                 return false;
71468             }
71469             var callArgument = ts.singleOrUndefined(statementExpression.arguments);
71470             if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 213) {
71471                 return false;
71472             }
71473             var expression = callArgument.expression;
71474             return ts.isIdentifier(expression) && expression.escapedText === "arguments";
71475         }
71476     }
71477     ts.transformES2015 = transformES2015;
71478     function createExtendsHelper(context, name) {
71479         context.requestEmitHelper(ts.extendsHelper);
71480         return ts.createCall(ts.getUnscopedHelperName("__extends"), undefined, [
71481             name,
71482             ts.createFileLevelUniqueName("_super")
71483         ]);
71484     }
71485     ts.extendsHelper = {
71486         name: "typescript:extends",
71487         importName: "__extends",
71488         scoped: false,
71489         priority: 0,
71490         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            })();"
71491     };
71492 })(ts || (ts = {}));
71493 var ts;
71494 (function (ts) {
71495     function transformES5(context) {
71496         var compilerOptions = context.getCompilerOptions();
71497         var previousOnEmitNode;
71498         var noSubstitution;
71499         if (compilerOptions.jsx === 1 || compilerOptions.jsx === 3) {
71500             previousOnEmitNode = context.onEmitNode;
71501             context.onEmitNode = onEmitNode;
71502             context.enableEmitNotification(268);
71503             context.enableEmitNotification(269);
71504             context.enableEmitNotification(267);
71505             noSubstitution = [];
71506         }
71507         var previousOnSubstituteNode = context.onSubstituteNode;
71508         context.onSubstituteNode = onSubstituteNode;
71509         context.enableSubstitution(194);
71510         context.enableSubstitution(281);
71511         return ts.chainBundle(transformSourceFile);
71512         function transformSourceFile(node) {
71513             return node;
71514         }
71515         function onEmitNode(hint, node, emitCallback) {
71516             switch (node.kind) {
71517                 case 268:
71518                 case 269:
71519                 case 267:
71520                     var tagName = node.tagName;
71521                     noSubstitution[ts.getOriginalNodeId(tagName)] = true;
71522                     break;
71523             }
71524             previousOnEmitNode(hint, node, emitCallback);
71525         }
71526         function onSubstituteNode(hint, node) {
71527             if (node.id && noSubstitution && noSubstitution[node.id]) {
71528                 return previousOnSubstituteNode(hint, node);
71529             }
71530             node = previousOnSubstituteNode(hint, node);
71531             if (ts.isPropertyAccessExpression(node)) {
71532                 return substitutePropertyAccessExpression(node);
71533             }
71534             else if (ts.isPropertyAssignment(node)) {
71535                 return substitutePropertyAssignment(node);
71536             }
71537             return node;
71538         }
71539         function substitutePropertyAccessExpression(node) {
71540             if (ts.isPrivateIdentifier(node.name)) {
71541                 return node;
71542             }
71543             var literalName = trySubstituteReservedName(node.name);
71544             if (literalName) {
71545                 return ts.setTextRange(ts.createElementAccess(node.expression, literalName), node);
71546             }
71547             return node;
71548         }
71549         function substitutePropertyAssignment(node) {
71550             var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name);
71551             if (literalName) {
71552                 return ts.updatePropertyAssignment(node, literalName, node.initializer);
71553             }
71554             return node;
71555         }
71556         function trySubstituteReservedName(name) {
71557             var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined);
71558             if (token !== undefined && token >= 77 && token <= 112) {
71559                 return ts.setTextRange(ts.createLiteral(name), name);
71560             }
71561             return undefined;
71562         }
71563     }
71564     ts.transformES5 = transformES5;
71565 })(ts || (ts = {}));
71566 var ts;
71567 (function (ts) {
71568     function getInstructionName(instruction) {
71569         switch (instruction) {
71570             case 2: return "return";
71571             case 3: return "break";
71572             case 4: return "yield";
71573             case 5: return "yield*";
71574             case 7: return "endfinally";
71575             default: return undefined;
71576         }
71577     }
71578     function transformGenerators(context) {
71579         var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration;
71580         var compilerOptions = context.getCompilerOptions();
71581         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
71582         var resolver = context.getEmitResolver();
71583         var previousOnSubstituteNode = context.onSubstituteNode;
71584         context.onSubstituteNode = onSubstituteNode;
71585         var renamedCatchVariables;
71586         var renamedCatchVariableDeclarations;
71587         var inGeneratorFunctionBody;
71588         var inStatementContainingYield;
71589         var blocks;
71590         var blockOffsets;
71591         var blockActions;
71592         var blockStack;
71593         var labelOffsets;
71594         var labelExpressions;
71595         var nextLabelId = 1;
71596         var operations;
71597         var operationArguments;
71598         var operationLocations;
71599         var state;
71600         var blockIndex = 0;
71601         var labelNumber = 0;
71602         var labelNumbers;
71603         var lastOperationWasAbrupt;
71604         var lastOperationWasCompletion;
71605         var clauses;
71606         var statements;
71607         var exceptionBlockStack;
71608         var currentExceptionBlock;
71609         var withBlockStack;
71610         return ts.chainBundle(transformSourceFile);
71611         function transformSourceFile(node) {
71612             if (node.isDeclarationFile || (node.transformFlags & 512) === 0) {
71613                 return node;
71614             }
71615             var visited = ts.visitEachChild(node, visitor, context);
71616             ts.addEmitHelpers(visited, context.readEmitHelpers());
71617             return visited;
71618         }
71619         function visitor(node) {
71620             var transformFlags = node.transformFlags;
71621             if (inStatementContainingYield) {
71622                 return visitJavaScriptInStatementContainingYield(node);
71623             }
71624             else if (inGeneratorFunctionBody) {
71625                 return visitJavaScriptInGeneratorFunctionBody(node);
71626             }
71627             else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) {
71628                 return visitGenerator(node);
71629             }
71630             else if (transformFlags & 512) {
71631                 return ts.visitEachChild(node, visitor, context);
71632             }
71633             else {
71634                 return node;
71635             }
71636         }
71637         function visitJavaScriptInStatementContainingYield(node) {
71638             switch (node.kind) {
71639                 case 228:
71640                     return visitDoStatement(node);
71641                 case 229:
71642                     return visitWhileStatement(node);
71643                 case 237:
71644                     return visitSwitchStatement(node);
71645                 case 238:
71646                     return visitLabeledStatement(node);
71647                 default:
71648                     return visitJavaScriptInGeneratorFunctionBody(node);
71649             }
71650         }
71651         function visitJavaScriptInGeneratorFunctionBody(node) {
71652             switch (node.kind) {
71653                 case 244:
71654                     return visitFunctionDeclaration(node);
71655                 case 201:
71656                     return visitFunctionExpression(node);
71657                 case 163:
71658                 case 164:
71659                     return visitAccessorDeclaration(node);
71660                 case 225:
71661                     return visitVariableStatement(node);
71662                 case 230:
71663                     return visitForStatement(node);
71664                 case 231:
71665                     return visitForInStatement(node);
71666                 case 234:
71667                     return visitBreakStatement(node);
71668                 case 233:
71669                     return visitContinueStatement(node);
71670                 case 235:
71671                     return visitReturnStatement(node);
71672                 default:
71673                     if (node.transformFlags & 262144) {
71674                         return visitJavaScriptContainingYield(node);
71675                     }
71676                     else if (node.transformFlags & (512 | 1048576)) {
71677                         return ts.visitEachChild(node, visitor, context);
71678                     }
71679                     else {
71680                         return node;
71681                     }
71682             }
71683         }
71684         function visitJavaScriptContainingYield(node) {
71685             switch (node.kind) {
71686                 case 209:
71687                     return visitBinaryExpression(node);
71688                 case 210:
71689                     return visitConditionalExpression(node);
71690                 case 212:
71691                     return visitYieldExpression(node);
71692                 case 192:
71693                     return visitArrayLiteralExpression(node);
71694                 case 193:
71695                     return visitObjectLiteralExpression(node);
71696                 case 195:
71697                     return visitElementAccessExpression(node);
71698                 case 196:
71699                     return visitCallExpression(node);
71700                 case 197:
71701                     return visitNewExpression(node);
71702                 default:
71703                     return ts.visitEachChild(node, visitor, context);
71704             }
71705         }
71706         function visitGenerator(node) {
71707             switch (node.kind) {
71708                 case 244:
71709                     return visitFunctionDeclaration(node);
71710                 case 201:
71711                     return visitFunctionExpression(node);
71712                 default:
71713                     return ts.Debug.failBadSyntaxKind(node);
71714             }
71715         }
71716         function visitFunctionDeclaration(node) {
71717             if (node.asteriskToken) {
71718                 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);
71719             }
71720             else {
71721                 var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
71722                 var savedInStatementContainingYield = inStatementContainingYield;
71723                 inGeneratorFunctionBody = false;
71724                 inStatementContainingYield = false;
71725                 node = ts.visitEachChild(node, visitor, context);
71726                 inGeneratorFunctionBody = savedInGeneratorFunctionBody;
71727                 inStatementContainingYield = savedInStatementContainingYield;
71728             }
71729             if (inGeneratorFunctionBody) {
71730                 hoistFunctionDeclaration(node);
71731                 return undefined;
71732             }
71733             else {
71734                 return node;
71735             }
71736         }
71737         function visitFunctionExpression(node) {
71738             if (node.asteriskToken) {
71739                 node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(undefined, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node);
71740             }
71741             else {
71742                 var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
71743                 var savedInStatementContainingYield = inStatementContainingYield;
71744                 inGeneratorFunctionBody = false;
71745                 inStatementContainingYield = false;
71746                 node = ts.visitEachChild(node, visitor, context);
71747                 inGeneratorFunctionBody = savedInGeneratorFunctionBody;
71748                 inStatementContainingYield = savedInStatementContainingYield;
71749             }
71750             return node;
71751         }
71752         function visitAccessorDeclaration(node) {
71753             var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
71754             var savedInStatementContainingYield = inStatementContainingYield;
71755             inGeneratorFunctionBody = false;
71756             inStatementContainingYield = false;
71757             node = ts.visitEachChild(node, visitor, context);
71758             inGeneratorFunctionBody = savedInGeneratorFunctionBody;
71759             inStatementContainingYield = savedInStatementContainingYield;
71760             return node;
71761         }
71762         function transformGeneratorFunctionBody(body) {
71763             var statements = [];
71764             var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
71765             var savedInStatementContainingYield = inStatementContainingYield;
71766             var savedBlocks = blocks;
71767             var savedBlockOffsets = blockOffsets;
71768             var savedBlockActions = blockActions;
71769             var savedBlockStack = blockStack;
71770             var savedLabelOffsets = labelOffsets;
71771             var savedLabelExpressions = labelExpressions;
71772             var savedNextLabelId = nextLabelId;
71773             var savedOperations = operations;
71774             var savedOperationArguments = operationArguments;
71775             var savedOperationLocations = operationLocations;
71776             var savedState = state;
71777             inGeneratorFunctionBody = true;
71778             inStatementContainingYield = false;
71779             blocks = undefined;
71780             blockOffsets = undefined;
71781             blockActions = undefined;
71782             blockStack = undefined;
71783             labelOffsets = undefined;
71784             labelExpressions = undefined;
71785             nextLabelId = 1;
71786             operations = undefined;
71787             operationArguments = undefined;
71788             operationLocations = undefined;
71789             state = ts.createTempVariable(undefined);
71790             resumeLexicalEnvironment();
71791             var statementOffset = ts.addPrologue(statements, body.statements, false, visitor);
71792             transformAndEmitStatements(body.statements, statementOffset);
71793             var buildResult = build();
71794             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
71795             statements.push(ts.createReturn(buildResult));
71796             inGeneratorFunctionBody = savedInGeneratorFunctionBody;
71797             inStatementContainingYield = savedInStatementContainingYield;
71798             blocks = savedBlocks;
71799             blockOffsets = savedBlockOffsets;
71800             blockActions = savedBlockActions;
71801             blockStack = savedBlockStack;
71802             labelOffsets = savedLabelOffsets;
71803             labelExpressions = savedLabelExpressions;
71804             nextLabelId = savedNextLabelId;
71805             operations = savedOperations;
71806             operationArguments = savedOperationArguments;
71807             operationLocations = savedOperationLocations;
71808             state = savedState;
71809             return ts.setTextRange(ts.createBlock(statements, body.multiLine), body);
71810         }
71811         function visitVariableStatement(node) {
71812             if (node.transformFlags & 262144) {
71813                 transformAndEmitVariableDeclarationList(node.declarationList);
71814                 return undefined;
71815             }
71816             else {
71817                 if (ts.getEmitFlags(node) & 1048576) {
71818                     return node;
71819                 }
71820                 for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
71821                     var variable = _a[_i];
71822                     hoistVariableDeclaration(variable.name);
71823                 }
71824                 var variables = ts.getInitializedVariables(node.declarationList);
71825                 if (variables.length === 0) {
71826                     return undefined;
71827                 }
71828                 return ts.setSourceMapRange(ts.createExpressionStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable))), node);
71829             }
71830         }
71831         function visitBinaryExpression(node) {
71832             var assoc = ts.getExpressionAssociativity(node);
71833             switch (assoc) {
71834                 case 0:
71835                     return visitLeftAssociativeBinaryExpression(node);
71836                 case 1:
71837                     return visitRightAssociativeBinaryExpression(node);
71838                 default:
71839                     return ts.Debug.assertNever(assoc);
71840             }
71841         }
71842         function visitRightAssociativeBinaryExpression(node) {
71843             var left = node.left, right = node.right;
71844             if (containsYield(right)) {
71845                 var target = void 0;
71846                 switch (left.kind) {
71847                     case 194:
71848                         target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name);
71849                         break;
71850                     case 195:
71851                         target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression)));
71852                         break;
71853                     default:
71854                         target = ts.visitNode(left, visitor, ts.isExpression);
71855                         break;
71856                 }
71857                 var operator = node.operatorToken.kind;
71858                 if (ts.isCompoundAssignment(operator)) {
71859                     return ts.setTextRange(ts.createAssignment(target, ts.setTextRange(ts.createBinary(cacheExpression(target), ts.getNonAssignmentOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression)), node)), node);
71860                 }
71861                 else {
71862                     return ts.updateBinary(node, target, ts.visitNode(right, visitor, ts.isExpression));
71863                 }
71864             }
71865             return ts.visitEachChild(node, visitor, context);
71866         }
71867         function visitLeftAssociativeBinaryExpression(node) {
71868             if (containsYield(node.right)) {
71869                 if (ts.isLogicalOperator(node.operatorToken.kind)) {
71870                     return visitLogicalBinaryExpression(node);
71871                 }
71872                 else if (node.operatorToken.kind === 27) {
71873                     return visitCommaExpression(node);
71874                 }
71875                 var clone_6 = ts.getMutableClone(node);
71876                 clone_6.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression));
71877                 clone_6.right = ts.visitNode(node.right, visitor, ts.isExpression);
71878                 return clone_6;
71879             }
71880             return ts.visitEachChild(node, visitor, context);
71881         }
71882         function visitLogicalBinaryExpression(node) {
71883             var resultLabel = defineLabel();
71884             var resultLocal = declareLocal();
71885             emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), node.left);
71886             if (node.operatorToken.kind === 55) {
71887                 emitBreakWhenFalse(resultLabel, resultLocal, node.left);
71888             }
71889             else {
71890                 emitBreakWhenTrue(resultLabel, resultLocal, node.left);
71891             }
71892             emitAssignment(resultLocal, ts.visitNode(node.right, visitor, ts.isExpression), node.right);
71893             markLabel(resultLabel);
71894             return resultLocal;
71895         }
71896         function visitCommaExpression(node) {
71897             var pendingExpressions = [];
71898             visit(node.left);
71899             visit(node.right);
71900             return ts.inlineExpressions(pendingExpressions);
71901             function visit(node) {
71902                 if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27) {
71903                     visit(node.left);
71904                     visit(node.right);
71905                 }
71906                 else {
71907                     if (containsYield(node) && pendingExpressions.length > 0) {
71908                         emitWorker(1, [ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))]);
71909                         pendingExpressions = [];
71910                     }
71911                     pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression));
71912                 }
71913             }
71914         }
71915         function visitConditionalExpression(node) {
71916             if (containsYield(node.whenTrue) || containsYield(node.whenFalse)) {
71917                 var whenFalseLabel = defineLabel();
71918                 var resultLabel = defineLabel();
71919                 var resultLocal = declareLocal();
71920                 emitBreakWhenFalse(whenFalseLabel, ts.visitNode(node.condition, visitor, ts.isExpression), node.condition);
71921                 emitAssignment(resultLocal, ts.visitNode(node.whenTrue, visitor, ts.isExpression), node.whenTrue);
71922                 emitBreak(resultLabel);
71923                 markLabel(whenFalseLabel);
71924                 emitAssignment(resultLocal, ts.visitNode(node.whenFalse, visitor, ts.isExpression), node.whenFalse);
71925                 markLabel(resultLabel);
71926                 return resultLocal;
71927             }
71928             return ts.visitEachChild(node, visitor, context);
71929         }
71930         function visitYieldExpression(node) {
71931             var resumeLabel = defineLabel();
71932             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
71933             if (node.asteriskToken) {
71934                 var iterator = (ts.getEmitFlags(node.expression) & 8388608) === 0
71935                     ? ts.createValuesHelper(context, expression, node)
71936                     : expression;
71937                 emitYieldStar(iterator, node);
71938             }
71939             else {
71940                 emitYield(expression, node);
71941             }
71942             markLabel(resumeLabel);
71943             return createGeneratorResume(node);
71944         }
71945         function visitArrayLiteralExpression(node) {
71946             return visitElements(node.elements, undefined, undefined, node.multiLine);
71947         }
71948         function visitElements(elements, leadingElement, location, multiLine) {
71949             var numInitialElements = countInitialNodesWithoutYield(elements);
71950             var temp;
71951             if (numInitialElements > 0) {
71952                 temp = declareLocal();
71953                 var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements);
71954                 emitAssignment(temp, ts.createArrayLiteral(leadingElement
71955                     ? __spreadArrays([leadingElement], initialElements) : initialElements));
71956                 leadingElement = undefined;
71957             }
71958             var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements);
71959             return temp
71960                 ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)])
71961                 : ts.setTextRange(ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine), location);
71962             function reduceElement(expressions, element) {
71963                 if (containsYield(element) && expressions.length > 0) {
71964                     var hasAssignedTemp = temp !== undefined;
71965                     if (!temp) {
71966                         temp = declareLocal();
71967                     }
71968                     emitAssignment(temp, hasAssignedTemp
71969                         ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)])
71970                         : ts.createArrayLiteral(leadingElement ? __spreadArrays([leadingElement], expressions) : expressions, multiLine));
71971                     leadingElement = undefined;
71972                     expressions = [];
71973                 }
71974                 expressions.push(ts.visitNode(element, visitor, ts.isExpression));
71975                 return expressions;
71976             }
71977         }
71978         function visitObjectLiteralExpression(node) {
71979             var properties = node.properties;
71980             var multiLine = node.multiLine;
71981             var numInitialProperties = countInitialNodesWithoutYield(properties);
71982             var temp = declareLocal();
71983             emitAssignment(temp, ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), multiLine));
71984             var expressions = ts.reduceLeft(properties, reduceProperty, [], numInitialProperties);
71985             expressions.push(multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp);
71986             return ts.inlineExpressions(expressions);
71987             function reduceProperty(expressions, property) {
71988                 if (containsYield(property) && expressions.length > 0) {
71989                     emitStatement(ts.createExpressionStatement(ts.inlineExpressions(expressions)));
71990                     expressions = [];
71991                 }
71992                 var expression = ts.createExpressionForObjectLiteralElementLike(node, property, temp);
71993                 var visited = ts.visitNode(expression, visitor, ts.isExpression);
71994                 if (visited) {
71995                     if (multiLine) {
71996                         ts.startOnNewLine(visited);
71997                     }
71998                     expressions.push(visited);
71999                 }
72000                 return expressions;
72001             }
72002         }
72003         function visitElementAccessExpression(node) {
72004             if (containsYield(node.argumentExpression)) {
72005                 var clone_7 = ts.getMutableClone(node);
72006                 clone_7.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression));
72007                 clone_7.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression);
72008                 return clone_7;
72009             }
72010             return ts.visitEachChild(node, visitor, context);
72011         }
72012         function visitCallExpression(node) {
72013             if (!ts.isImportCall(node) && ts.forEach(node.arguments, containsYield)) {
72014                 var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion, true), target = _a.target, thisArg = _a.thisArg;
72015                 return ts.setOriginalNode(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments), node), node);
72016             }
72017             return ts.visitEachChild(node, visitor, context);
72018         }
72019         function visitNewExpression(node) {
72020             if (ts.forEach(node.arguments, containsYield)) {
72021                 var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
72022                 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);
72023             }
72024             return ts.visitEachChild(node, visitor, context);
72025         }
72026         function transformAndEmitStatements(statements, start) {
72027             if (start === void 0) { start = 0; }
72028             var numStatements = statements.length;
72029             for (var i = start; i < numStatements; i++) {
72030                 transformAndEmitStatement(statements[i]);
72031             }
72032         }
72033         function transformAndEmitEmbeddedStatement(node) {
72034             if (ts.isBlock(node)) {
72035                 transformAndEmitStatements(node.statements);
72036             }
72037             else {
72038                 transformAndEmitStatement(node);
72039             }
72040         }
72041         function transformAndEmitStatement(node) {
72042             var savedInStatementContainingYield = inStatementContainingYield;
72043             if (!inStatementContainingYield) {
72044                 inStatementContainingYield = containsYield(node);
72045             }
72046             transformAndEmitStatementWorker(node);
72047             inStatementContainingYield = savedInStatementContainingYield;
72048         }
72049         function transformAndEmitStatementWorker(node) {
72050             switch (node.kind) {
72051                 case 223:
72052                     return transformAndEmitBlock(node);
72053                 case 226:
72054                     return transformAndEmitExpressionStatement(node);
72055                 case 227:
72056                     return transformAndEmitIfStatement(node);
72057                 case 228:
72058                     return transformAndEmitDoStatement(node);
72059                 case 229:
72060                     return transformAndEmitWhileStatement(node);
72061                 case 230:
72062                     return transformAndEmitForStatement(node);
72063                 case 231:
72064                     return transformAndEmitForInStatement(node);
72065                 case 233:
72066                     return transformAndEmitContinueStatement(node);
72067                 case 234:
72068                     return transformAndEmitBreakStatement(node);
72069                 case 235:
72070                     return transformAndEmitReturnStatement(node);
72071                 case 236:
72072                     return transformAndEmitWithStatement(node);
72073                 case 237:
72074                     return transformAndEmitSwitchStatement(node);
72075                 case 238:
72076                     return transformAndEmitLabeledStatement(node);
72077                 case 239:
72078                     return transformAndEmitThrowStatement(node);
72079                 case 240:
72080                     return transformAndEmitTryStatement(node);
72081                 default:
72082                     return emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72083             }
72084         }
72085         function transformAndEmitBlock(node) {
72086             if (containsYield(node)) {
72087                 transformAndEmitStatements(node.statements);
72088             }
72089             else {
72090                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72091             }
72092         }
72093         function transformAndEmitExpressionStatement(node) {
72094             emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72095         }
72096         function transformAndEmitVariableDeclarationList(node) {
72097             for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) {
72098                 var variable = _a[_i];
72099                 var name = ts.getSynthesizedClone(variable.name);
72100                 ts.setCommentRange(name, variable.name);
72101                 hoistVariableDeclaration(name);
72102             }
72103             var variables = ts.getInitializedVariables(node);
72104             var numVariables = variables.length;
72105             var variablesWritten = 0;
72106             var pendingExpressions = [];
72107             while (variablesWritten < numVariables) {
72108                 for (var i = variablesWritten; i < numVariables; i++) {
72109                     var variable = variables[i];
72110                     if (containsYield(variable.initializer) && pendingExpressions.length > 0) {
72111                         break;
72112                     }
72113                     pendingExpressions.push(transformInitializedVariable(variable));
72114                 }
72115                 if (pendingExpressions.length) {
72116                     emitStatement(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions)));
72117                     variablesWritten += pendingExpressions.length;
72118                     pendingExpressions = [];
72119                 }
72120             }
72121             return undefined;
72122         }
72123         function transformInitializedVariable(node) {
72124             return ts.setSourceMapRange(ts.createAssignment(ts.setSourceMapRange(ts.getSynthesizedClone(node.name), node.name), ts.visitNode(node.initializer, visitor, ts.isExpression)), node);
72125         }
72126         function transformAndEmitIfStatement(node) {
72127             if (containsYield(node)) {
72128                 if (containsYield(node.thenStatement) || containsYield(node.elseStatement)) {
72129                     var endLabel = defineLabel();
72130                     var elseLabel = node.elseStatement ? defineLabel() : undefined;
72131                     emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression), node.expression);
72132                     transformAndEmitEmbeddedStatement(node.thenStatement);
72133                     if (node.elseStatement) {
72134                         emitBreak(endLabel);
72135                         markLabel(elseLabel);
72136                         transformAndEmitEmbeddedStatement(node.elseStatement);
72137                     }
72138                     markLabel(endLabel);
72139                 }
72140                 else {
72141                     emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72142                 }
72143             }
72144             else {
72145                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72146             }
72147         }
72148         function transformAndEmitDoStatement(node) {
72149             if (containsYield(node)) {
72150                 var conditionLabel = defineLabel();
72151                 var loopLabel = defineLabel();
72152                 beginLoopBlock(conditionLabel);
72153                 markLabel(loopLabel);
72154                 transformAndEmitEmbeddedStatement(node.statement);
72155                 markLabel(conditionLabel);
72156                 emitBreakWhenTrue(loopLabel, ts.visitNode(node.expression, visitor, ts.isExpression));
72157                 endLoopBlock();
72158             }
72159             else {
72160                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72161             }
72162         }
72163         function visitDoStatement(node) {
72164             if (inStatementContainingYield) {
72165                 beginScriptLoopBlock();
72166                 node = ts.visitEachChild(node, visitor, context);
72167                 endLoopBlock();
72168                 return node;
72169             }
72170             else {
72171                 return ts.visitEachChild(node, visitor, context);
72172             }
72173         }
72174         function transformAndEmitWhileStatement(node) {
72175             if (containsYield(node)) {
72176                 var loopLabel = defineLabel();
72177                 var endLabel = beginLoopBlock(loopLabel);
72178                 markLabel(loopLabel);
72179                 emitBreakWhenFalse(endLabel, ts.visitNode(node.expression, visitor, ts.isExpression));
72180                 transformAndEmitEmbeddedStatement(node.statement);
72181                 emitBreak(loopLabel);
72182                 endLoopBlock();
72183             }
72184             else {
72185                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72186             }
72187         }
72188         function visitWhileStatement(node) {
72189             if (inStatementContainingYield) {
72190                 beginScriptLoopBlock();
72191                 node = ts.visitEachChild(node, visitor, context);
72192                 endLoopBlock();
72193                 return node;
72194             }
72195             else {
72196                 return ts.visitEachChild(node, visitor, context);
72197             }
72198         }
72199         function transformAndEmitForStatement(node) {
72200             if (containsYield(node)) {
72201                 var conditionLabel = defineLabel();
72202                 var incrementLabel = defineLabel();
72203                 var endLabel = beginLoopBlock(incrementLabel);
72204                 if (node.initializer) {
72205                     var initializer = node.initializer;
72206                     if (ts.isVariableDeclarationList(initializer)) {
72207                         transformAndEmitVariableDeclarationList(initializer);
72208                     }
72209                     else {
72210                         emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer));
72211                     }
72212                 }
72213                 markLabel(conditionLabel);
72214                 if (node.condition) {
72215                     emitBreakWhenFalse(endLabel, ts.visitNode(node.condition, visitor, ts.isExpression));
72216                 }
72217                 transformAndEmitEmbeddedStatement(node.statement);
72218                 markLabel(incrementLabel);
72219                 if (node.incrementor) {
72220                     emitStatement(ts.setTextRange(ts.createExpressionStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor));
72221                 }
72222                 emitBreak(conditionLabel);
72223                 endLoopBlock();
72224             }
72225             else {
72226                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72227             }
72228         }
72229         function visitForStatement(node) {
72230             if (inStatementContainingYield) {
72231                 beginScriptLoopBlock();
72232             }
72233             var initializer = node.initializer;
72234             if (initializer && ts.isVariableDeclarationList(initializer)) {
72235                 for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
72236                     var variable = _a[_i];
72237                     hoistVariableDeclaration(variable.name);
72238                 }
72239                 var variables = ts.getInitializedVariables(initializer);
72240                 node = ts.updateFor(node, variables.length > 0
72241                     ? ts.inlineExpressions(ts.map(variables, transformInitializedVariable))
72242                     : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
72243             }
72244             else {
72245                 node = ts.visitEachChild(node, visitor, context);
72246             }
72247             if (inStatementContainingYield) {
72248                 endLoopBlock();
72249             }
72250             return node;
72251         }
72252         function transformAndEmitForInStatement(node) {
72253             if (containsYield(node)) {
72254                 var keysArray = declareLocal();
72255                 var key = declareLocal();
72256                 var keysIndex = ts.createLoopVariable();
72257                 var initializer = node.initializer;
72258                 hoistVariableDeclaration(keysIndex);
72259                 emitAssignment(keysArray, ts.createArrayLiteral());
72260                 emitStatement(ts.createForIn(key, ts.visitNode(node.expression, visitor, ts.isExpression), ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(keysArray, "push"), undefined, [key]))));
72261                 emitAssignment(keysIndex, ts.createLiteral(0));
72262                 var conditionLabel = defineLabel();
72263                 var incrementLabel = defineLabel();
72264                 var endLabel = beginLoopBlock(incrementLabel);
72265                 markLabel(conditionLabel);
72266                 emitBreakWhenFalse(endLabel, ts.createLessThan(keysIndex, ts.createPropertyAccess(keysArray, "length")));
72267                 var variable = void 0;
72268                 if (ts.isVariableDeclarationList(initializer)) {
72269                     for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
72270                         var variable_1 = _a[_i];
72271                         hoistVariableDeclaration(variable_1.name);
72272                     }
72273                     variable = ts.getSynthesizedClone(initializer.declarations[0].name);
72274                 }
72275                 else {
72276                     variable = ts.visitNode(initializer, visitor, ts.isExpression);
72277                     ts.Debug.assert(ts.isLeftHandSideExpression(variable));
72278                 }
72279                 emitAssignment(variable, ts.createElementAccess(keysArray, keysIndex));
72280                 transformAndEmitEmbeddedStatement(node.statement);
72281                 markLabel(incrementLabel);
72282                 emitStatement(ts.createExpressionStatement(ts.createPostfixIncrement(keysIndex)));
72283                 emitBreak(conditionLabel);
72284                 endLoopBlock();
72285             }
72286             else {
72287                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72288             }
72289         }
72290         function visitForInStatement(node) {
72291             if (inStatementContainingYield) {
72292                 beginScriptLoopBlock();
72293             }
72294             var initializer = node.initializer;
72295             if (ts.isVariableDeclarationList(initializer)) {
72296                 for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
72297                     var variable = _a[_i];
72298                     hoistVariableDeclaration(variable.name);
72299                 }
72300                 node = ts.updateForIn(node, initializer.declarations[0].name, ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock));
72301             }
72302             else {
72303                 node = ts.visitEachChild(node, visitor, context);
72304             }
72305             if (inStatementContainingYield) {
72306                 endLoopBlock();
72307             }
72308             return node;
72309         }
72310         function transformAndEmitContinueStatement(node) {
72311             var label = findContinueTarget(node.label ? ts.idText(node.label) : undefined);
72312             if (label > 0) {
72313                 emitBreak(label, node);
72314             }
72315             else {
72316                 emitStatement(node);
72317             }
72318         }
72319         function visitContinueStatement(node) {
72320             if (inStatementContainingYield) {
72321                 var label = findContinueTarget(node.label && ts.idText(node.label));
72322                 if (label > 0) {
72323                     return createInlineBreak(label, node);
72324                 }
72325             }
72326             return ts.visitEachChild(node, visitor, context);
72327         }
72328         function transformAndEmitBreakStatement(node) {
72329             var label = findBreakTarget(node.label ? ts.idText(node.label) : undefined);
72330             if (label > 0) {
72331                 emitBreak(label, node);
72332             }
72333             else {
72334                 emitStatement(node);
72335             }
72336         }
72337         function visitBreakStatement(node) {
72338             if (inStatementContainingYield) {
72339                 var label = findBreakTarget(node.label && ts.idText(node.label));
72340                 if (label > 0) {
72341                     return createInlineBreak(label, node);
72342                 }
72343             }
72344             return ts.visitEachChild(node, visitor, context);
72345         }
72346         function transformAndEmitReturnStatement(node) {
72347             emitReturn(ts.visitNode(node.expression, visitor, ts.isExpression), node);
72348         }
72349         function visitReturnStatement(node) {
72350             return createInlineReturn(ts.visitNode(node.expression, visitor, ts.isExpression), node);
72351         }
72352         function transformAndEmitWithStatement(node) {
72353             if (containsYield(node)) {
72354                 beginWithBlock(cacheExpression(ts.visitNode(node.expression, visitor, ts.isExpression)));
72355                 transformAndEmitEmbeddedStatement(node.statement);
72356                 endWithBlock();
72357             }
72358             else {
72359                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72360             }
72361         }
72362         function transformAndEmitSwitchStatement(node) {
72363             if (containsYield(node.caseBlock)) {
72364                 var caseBlock = node.caseBlock;
72365                 var numClauses = caseBlock.clauses.length;
72366                 var endLabel = beginSwitchBlock();
72367                 var expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isExpression));
72368                 var clauseLabels = [];
72369                 var defaultClauseIndex = -1;
72370                 for (var i = 0; i < numClauses; i++) {
72371                     var clause = caseBlock.clauses[i];
72372                     clauseLabels.push(defineLabel());
72373                     if (clause.kind === 278 && defaultClauseIndex === -1) {
72374                         defaultClauseIndex = i;
72375                     }
72376                 }
72377                 var clausesWritten = 0;
72378                 var pendingClauses = [];
72379                 while (clausesWritten < numClauses) {
72380                     var defaultClausesSkipped = 0;
72381                     for (var i = clausesWritten; i < numClauses; i++) {
72382                         var clause = caseBlock.clauses[i];
72383                         if (clause.kind === 277) {
72384                             if (containsYield(clause.expression) && pendingClauses.length > 0) {
72385                                 break;
72386                             }
72387                             pendingClauses.push(ts.createCaseClause(ts.visitNode(clause.expression, visitor, ts.isExpression), [
72388                                 createInlineBreak(clauseLabels[i], clause.expression)
72389                             ]));
72390                         }
72391                         else {
72392                             defaultClausesSkipped++;
72393                         }
72394                     }
72395                     if (pendingClauses.length) {
72396                         emitStatement(ts.createSwitch(expression, ts.createCaseBlock(pendingClauses)));
72397                         clausesWritten += pendingClauses.length;
72398                         pendingClauses = [];
72399                     }
72400                     if (defaultClausesSkipped > 0) {
72401                         clausesWritten += defaultClausesSkipped;
72402                         defaultClausesSkipped = 0;
72403                     }
72404                 }
72405                 if (defaultClauseIndex >= 0) {
72406                     emitBreak(clauseLabels[defaultClauseIndex]);
72407                 }
72408                 else {
72409                     emitBreak(endLabel);
72410                 }
72411                 for (var i = 0; i < numClauses; i++) {
72412                     markLabel(clauseLabels[i]);
72413                     transformAndEmitStatements(caseBlock.clauses[i].statements);
72414                 }
72415                 endSwitchBlock();
72416             }
72417             else {
72418                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72419             }
72420         }
72421         function visitSwitchStatement(node) {
72422             if (inStatementContainingYield) {
72423                 beginScriptSwitchBlock();
72424             }
72425             node = ts.visitEachChild(node, visitor, context);
72426             if (inStatementContainingYield) {
72427                 endSwitchBlock();
72428             }
72429             return node;
72430         }
72431         function transformAndEmitLabeledStatement(node) {
72432             if (containsYield(node)) {
72433                 beginLabeledBlock(ts.idText(node.label));
72434                 transformAndEmitEmbeddedStatement(node.statement);
72435                 endLabeledBlock();
72436             }
72437             else {
72438                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
72439             }
72440         }
72441         function visitLabeledStatement(node) {
72442             if (inStatementContainingYield) {
72443                 beginScriptLabeledBlock(ts.idText(node.label));
72444             }
72445             node = ts.visitEachChild(node, visitor, context);
72446             if (inStatementContainingYield) {
72447                 endLabeledBlock();
72448             }
72449             return node;
72450         }
72451         function transformAndEmitThrowStatement(node) {
72452             emitThrow(ts.visitNode(node.expression, visitor, ts.isExpression), node);
72453         }
72454         function transformAndEmitTryStatement(node) {
72455             if (containsYield(node)) {
72456                 beginExceptionBlock();
72457                 transformAndEmitEmbeddedStatement(node.tryBlock);
72458                 if (node.catchClause) {
72459                     beginCatchBlock(node.catchClause.variableDeclaration);
72460                     transformAndEmitEmbeddedStatement(node.catchClause.block);
72461                 }
72462                 if (node.finallyBlock) {
72463                     beginFinallyBlock();
72464                     transformAndEmitEmbeddedStatement(node.finallyBlock);
72465                 }
72466                 endExceptionBlock();
72467             }
72468             else {
72469                 emitStatement(ts.visitEachChild(node, visitor, context));
72470             }
72471         }
72472         function containsYield(node) {
72473             return !!node && (node.transformFlags & 262144) !== 0;
72474         }
72475         function countInitialNodesWithoutYield(nodes) {
72476             var numNodes = nodes.length;
72477             for (var i = 0; i < numNodes; i++) {
72478                 if (containsYield(nodes[i])) {
72479                     return i;
72480                 }
72481             }
72482             return -1;
72483         }
72484         function onSubstituteNode(hint, node) {
72485             node = previousOnSubstituteNode(hint, node);
72486             if (hint === 1) {
72487                 return substituteExpression(node);
72488             }
72489             return node;
72490         }
72491         function substituteExpression(node) {
72492             if (ts.isIdentifier(node)) {
72493                 return substituteExpressionIdentifier(node);
72494             }
72495             return node;
72496         }
72497         function substituteExpressionIdentifier(node) {
72498             if (!ts.isGeneratedIdentifier(node) && renamedCatchVariables && renamedCatchVariables.has(ts.idText(node))) {
72499                 var original = ts.getOriginalNode(node);
72500                 if (ts.isIdentifier(original) && original.parent) {
72501                     var declaration = resolver.getReferencedValueDeclaration(original);
72502                     if (declaration) {
72503                         var name = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)];
72504                         if (name) {
72505                             var clone_8 = ts.getMutableClone(name);
72506                             ts.setSourceMapRange(clone_8, node);
72507                             ts.setCommentRange(clone_8, node);
72508                             return clone_8;
72509                         }
72510                     }
72511                 }
72512             }
72513             return node;
72514         }
72515         function cacheExpression(node) {
72516             if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096) {
72517                 return node;
72518             }
72519             var temp = ts.createTempVariable(hoistVariableDeclaration);
72520             emitAssignment(temp, node, node);
72521             return temp;
72522         }
72523         function declareLocal(name) {
72524             var temp = name
72525                 ? ts.createUniqueName(name)
72526                 : ts.createTempVariable(undefined);
72527             hoistVariableDeclaration(temp);
72528             return temp;
72529         }
72530         function defineLabel() {
72531             if (!labelOffsets) {
72532                 labelOffsets = [];
72533             }
72534             var label = nextLabelId;
72535             nextLabelId++;
72536             labelOffsets[label] = -1;
72537             return label;
72538         }
72539         function markLabel(label) {
72540             ts.Debug.assert(labelOffsets !== undefined, "No labels were defined.");
72541             labelOffsets[label] = operations ? operations.length : 0;
72542         }
72543         function beginBlock(block) {
72544             if (!blocks) {
72545                 blocks = [];
72546                 blockActions = [];
72547                 blockOffsets = [];
72548                 blockStack = [];
72549             }
72550             var index = blockActions.length;
72551             blockActions[index] = 0;
72552             blockOffsets[index] = operations ? operations.length : 0;
72553             blocks[index] = block;
72554             blockStack.push(block);
72555             return index;
72556         }
72557         function endBlock() {
72558             var block = peekBlock();
72559             if (block === undefined)
72560                 return ts.Debug.fail("beginBlock was never called.");
72561             var index = blockActions.length;
72562             blockActions[index] = 1;
72563             blockOffsets[index] = operations ? operations.length : 0;
72564             blocks[index] = block;
72565             blockStack.pop();
72566             return block;
72567         }
72568         function peekBlock() {
72569             return ts.lastOrUndefined(blockStack);
72570         }
72571         function peekBlockKind() {
72572             var block = peekBlock();
72573             return block && block.kind;
72574         }
72575         function beginWithBlock(expression) {
72576             var startLabel = defineLabel();
72577             var endLabel = defineLabel();
72578             markLabel(startLabel);
72579             beginBlock({
72580                 kind: 1,
72581                 expression: expression,
72582                 startLabel: startLabel,
72583                 endLabel: endLabel
72584             });
72585         }
72586         function endWithBlock() {
72587             ts.Debug.assert(peekBlockKind() === 1);
72588             var block = endBlock();
72589             markLabel(block.endLabel);
72590         }
72591         function beginExceptionBlock() {
72592             var startLabel = defineLabel();
72593             var endLabel = defineLabel();
72594             markLabel(startLabel);
72595             beginBlock({
72596                 kind: 0,
72597                 state: 0,
72598                 startLabel: startLabel,
72599                 endLabel: endLabel
72600             });
72601             emitNop();
72602             return endLabel;
72603         }
72604         function beginCatchBlock(variable) {
72605             ts.Debug.assert(peekBlockKind() === 0);
72606             var name;
72607             if (ts.isGeneratedIdentifier(variable.name)) {
72608                 name = variable.name;
72609                 hoistVariableDeclaration(variable.name);
72610             }
72611             else {
72612                 var text = ts.idText(variable.name);
72613                 name = declareLocal(text);
72614                 if (!renamedCatchVariables) {
72615                     renamedCatchVariables = ts.createMap();
72616                     renamedCatchVariableDeclarations = [];
72617                     context.enableSubstitution(75);
72618                 }
72619                 renamedCatchVariables.set(text, true);
72620                 renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name;
72621             }
72622             var exception = peekBlock();
72623             ts.Debug.assert(exception.state < 1);
72624             var endLabel = exception.endLabel;
72625             emitBreak(endLabel);
72626             var catchLabel = defineLabel();
72627             markLabel(catchLabel);
72628             exception.state = 1;
72629             exception.catchVariable = name;
72630             exception.catchLabel = catchLabel;
72631             emitAssignment(name, ts.createCall(ts.createPropertyAccess(state, "sent"), undefined, []));
72632             emitNop();
72633         }
72634         function beginFinallyBlock() {
72635             ts.Debug.assert(peekBlockKind() === 0);
72636             var exception = peekBlock();
72637             ts.Debug.assert(exception.state < 2);
72638             var endLabel = exception.endLabel;
72639             emitBreak(endLabel);
72640             var finallyLabel = defineLabel();
72641             markLabel(finallyLabel);
72642             exception.state = 2;
72643             exception.finallyLabel = finallyLabel;
72644         }
72645         function endExceptionBlock() {
72646             ts.Debug.assert(peekBlockKind() === 0);
72647             var exception = endBlock();
72648             var state = exception.state;
72649             if (state < 2) {
72650                 emitBreak(exception.endLabel);
72651             }
72652             else {
72653                 emitEndfinally();
72654             }
72655             markLabel(exception.endLabel);
72656             emitNop();
72657             exception.state = 3;
72658         }
72659         function beginScriptLoopBlock() {
72660             beginBlock({
72661                 kind: 3,
72662                 isScript: true,
72663                 breakLabel: -1,
72664                 continueLabel: -1
72665             });
72666         }
72667         function beginLoopBlock(continueLabel) {
72668             var breakLabel = defineLabel();
72669             beginBlock({
72670                 kind: 3,
72671                 isScript: false,
72672                 breakLabel: breakLabel,
72673                 continueLabel: continueLabel,
72674             });
72675             return breakLabel;
72676         }
72677         function endLoopBlock() {
72678             ts.Debug.assert(peekBlockKind() === 3);
72679             var block = endBlock();
72680             var breakLabel = block.breakLabel;
72681             if (!block.isScript) {
72682                 markLabel(breakLabel);
72683             }
72684         }
72685         function beginScriptSwitchBlock() {
72686             beginBlock({
72687                 kind: 2,
72688                 isScript: true,
72689                 breakLabel: -1
72690             });
72691         }
72692         function beginSwitchBlock() {
72693             var breakLabel = defineLabel();
72694             beginBlock({
72695                 kind: 2,
72696                 isScript: false,
72697                 breakLabel: breakLabel,
72698             });
72699             return breakLabel;
72700         }
72701         function endSwitchBlock() {
72702             ts.Debug.assert(peekBlockKind() === 2);
72703             var block = endBlock();
72704             var breakLabel = block.breakLabel;
72705             if (!block.isScript) {
72706                 markLabel(breakLabel);
72707             }
72708         }
72709         function beginScriptLabeledBlock(labelText) {
72710             beginBlock({
72711                 kind: 4,
72712                 isScript: true,
72713                 labelText: labelText,
72714                 breakLabel: -1
72715             });
72716         }
72717         function beginLabeledBlock(labelText) {
72718             var breakLabel = defineLabel();
72719             beginBlock({
72720                 kind: 4,
72721                 isScript: false,
72722                 labelText: labelText,
72723                 breakLabel: breakLabel
72724             });
72725         }
72726         function endLabeledBlock() {
72727             ts.Debug.assert(peekBlockKind() === 4);
72728             var block = endBlock();
72729             if (!block.isScript) {
72730                 markLabel(block.breakLabel);
72731             }
72732         }
72733         function supportsUnlabeledBreak(block) {
72734             return block.kind === 2
72735                 || block.kind === 3;
72736         }
72737         function supportsLabeledBreakOrContinue(block) {
72738             return block.kind === 4;
72739         }
72740         function supportsUnlabeledContinue(block) {
72741             return block.kind === 3;
72742         }
72743         function hasImmediateContainingLabeledBlock(labelText, start) {
72744             for (var j = start; j >= 0; j--) {
72745                 var containingBlock = blockStack[j];
72746                 if (supportsLabeledBreakOrContinue(containingBlock)) {
72747                     if (containingBlock.labelText === labelText) {
72748                         return true;
72749                     }
72750                 }
72751                 else {
72752                     break;
72753                 }
72754             }
72755             return false;
72756         }
72757         function findBreakTarget(labelText) {
72758             if (blockStack) {
72759                 if (labelText) {
72760                     for (var i = blockStack.length - 1; i >= 0; i--) {
72761                         var block = blockStack[i];
72762                         if (supportsLabeledBreakOrContinue(block) && block.labelText === labelText) {
72763                             return block.breakLabel;
72764                         }
72765                         else if (supportsUnlabeledBreak(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) {
72766                             return block.breakLabel;
72767                         }
72768                     }
72769                 }
72770                 else {
72771                     for (var i = blockStack.length - 1; i >= 0; i--) {
72772                         var block = blockStack[i];
72773                         if (supportsUnlabeledBreak(block)) {
72774                             return block.breakLabel;
72775                         }
72776                     }
72777                 }
72778             }
72779             return 0;
72780         }
72781         function findContinueTarget(labelText) {
72782             if (blockStack) {
72783                 if (labelText) {
72784                     for (var i = blockStack.length - 1; i >= 0; i--) {
72785                         var block = blockStack[i];
72786                         if (supportsUnlabeledContinue(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) {
72787                             return block.continueLabel;
72788                         }
72789                     }
72790                 }
72791                 else {
72792                     for (var i = blockStack.length - 1; i >= 0; i--) {
72793                         var block = blockStack[i];
72794                         if (supportsUnlabeledContinue(block)) {
72795                             return block.continueLabel;
72796                         }
72797                     }
72798                 }
72799             }
72800             return 0;
72801         }
72802         function createLabel(label) {
72803             if (label !== undefined && label > 0) {
72804                 if (labelExpressions === undefined) {
72805                     labelExpressions = [];
72806                 }
72807                 var expression = ts.createLiteral(-1);
72808                 if (labelExpressions[label] === undefined) {
72809                     labelExpressions[label] = [expression];
72810                 }
72811                 else {
72812                     labelExpressions[label].push(expression);
72813                 }
72814                 return expression;
72815             }
72816             return ts.createOmittedExpression();
72817         }
72818         function createInstruction(instruction) {
72819             var literal = ts.createLiteral(instruction);
72820             ts.addSyntheticTrailingComment(literal, 3, getInstructionName(instruction));
72821             return literal;
72822         }
72823         function createInlineBreak(label, location) {
72824             ts.Debug.assertLessThan(0, label, "Invalid label");
72825             return ts.setTextRange(ts.createReturn(ts.createArrayLiteral([
72826                 createInstruction(3),
72827                 createLabel(label)
72828             ])), location);
72829         }
72830         function createInlineReturn(expression, location) {
72831             return ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression
72832                 ? [createInstruction(2), expression]
72833                 : [createInstruction(2)])), location);
72834         }
72835         function createGeneratorResume(location) {
72836             return ts.setTextRange(ts.createCall(ts.createPropertyAccess(state, "sent"), undefined, []), location);
72837         }
72838         function emitNop() {
72839             emitWorker(0);
72840         }
72841         function emitStatement(node) {
72842             if (node) {
72843                 emitWorker(1, [node]);
72844             }
72845             else {
72846                 emitNop();
72847             }
72848         }
72849         function emitAssignment(left, right, location) {
72850             emitWorker(2, [left, right], location);
72851         }
72852         function emitBreak(label, location) {
72853             emitWorker(3, [label], location);
72854         }
72855         function emitBreakWhenTrue(label, condition, location) {
72856             emitWorker(4, [label, condition], location);
72857         }
72858         function emitBreakWhenFalse(label, condition, location) {
72859             emitWorker(5, [label, condition], location);
72860         }
72861         function emitYieldStar(expression, location) {
72862             emitWorker(7, [expression], location);
72863         }
72864         function emitYield(expression, location) {
72865             emitWorker(6, [expression], location);
72866         }
72867         function emitReturn(expression, location) {
72868             emitWorker(8, [expression], location);
72869         }
72870         function emitThrow(expression, location) {
72871             emitWorker(9, [expression], location);
72872         }
72873         function emitEndfinally() {
72874             emitWorker(10);
72875         }
72876         function emitWorker(code, args, location) {
72877             if (operations === undefined) {
72878                 operations = [];
72879                 operationArguments = [];
72880                 operationLocations = [];
72881             }
72882             if (labelOffsets === undefined) {
72883                 markLabel(defineLabel());
72884             }
72885             var operationIndex = operations.length;
72886             operations[operationIndex] = code;
72887             operationArguments[operationIndex] = args;
72888             operationLocations[operationIndex] = location;
72889         }
72890         function build() {
72891             blockIndex = 0;
72892             labelNumber = 0;
72893             labelNumbers = undefined;
72894             lastOperationWasAbrupt = false;
72895             lastOperationWasCompletion = false;
72896             clauses = undefined;
72897             statements = undefined;
72898             exceptionBlockStack = undefined;
72899             currentExceptionBlock = undefined;
72900             withBlockStack = undefined;
72901             var buildResult = buildStatements();
72902             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));
72903         }
72904         function buildStatements() {
72905             if (operations) {
72906                 for (var operationIndex = 0; operationIndex < operations.length; operationIndex++) {
72907                     writeOperation(operationIndex);
72908                 }
72909                 flushFinalLabel(operations.length);
72910             }
72911             else {
72912                 flushFinalLabel(0);
72913             }
72914             if (clauses) {
72915                 var labelExpression = ts.createPropertyAccess(state, "label");
72916                 var switchStatement = ts.createSwitch(labelExpression, ts.createCaseBlock(clauses));
72917                 return [ts.startOnNewLine(switchStatement)];
72918             }
72919             if (statements) {
72920                 return statements;
72921             }
72922             return [];
72923         }
72924         function flushLabel() {
72925             if (!statements) {
72926                 return;
72927             }
72928             appendLabel(!lastOperationWasAbrupt);
72929             lastOperationWasAbrupt = false;
72930             lastOperationWasCompletion = false;
72931             labelNumber++;
72932         }
72933         function flushFinalLabel(operationIndex) {
72934             if (isFinalLabelReachable(operationIndex)) {
72935                 tryEnterLabel(operationIndex);
72936                 withBlockStack = undefined;
72937                 writeReturn(undefined, undefined);
72938             }
72939             if (statements && clauses) {
72940                 appendLabel(false);
72941             }
72942             updateLabelExpressions();
72943         }
72944         function isFinalLabelReachable(operationIndex) {
72945             if (!lastOperationWasCompletion) {
72946                 return true;
72947             }
72948             if (!labelOffsets || !labelExpressions) {
72949                 return false;
72950             }
72951             for (var label = 0; label < labelOffsets.length; label++) {
72952                 if (labelOffsets[label] === operationIndex && labelExpressions[label]) {
72953                     return true;
72954                 }
72955             }
72956             return false;
72957         }
72958         function appendLabel(markLabelEnd) {
72959             if (!clauses) {
72960                 clauses = [];
72961             }
72962             if (statements) {
72963                 if (withBlockStack) {
72964                     for (var i = withBlockStack.length - 1; i >= 0; i--) {
72965                         var withBlock = withBlockStack[i];
72966                         statements = [ts.createWith(withBlock.expression, ts.createBlock(statements))];
72967                     }
72968                 }
72969                 if (currentExceptionBlock) {
72970                     var startLabel = currentExceptionBlock.startLabel, catchLabel = currentExceptionBlock.catchLabel, finallyLabel = currentExceptionBlock.finallyLabel, endLabel = currentExceptionBlock.endLabel;
72971                     statements.unshift(ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createPropertyAccess(state, "trys"), "push"), undefined, [
72972                         ts.createArrayLiteral([
72973                             createLabel(startLabel),
72974                             createLabel(catchLabel),
72975                             createLabel(finallyLabel),
72976                             createLabel(endLabel)
72977                         ])
72978                     ])));
72979                     currentExceptionBlock = undefined;
72980                 }
72981                 if (markLabelEnd) {
72982                     statements.push(ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(state, "label"), ts.createLiteral(labelNumber + 1))));
72983                 }
72984             }
72985             clauses.push(ts.createCaseClause(ts.createLiteral(labelNumber), statements || []));
72986             statements = undefined;
72987         }
72988         function tryEnterLabel(operationIndex) {
72989             if (!labelOffsets) {
72990                 return;
72991             }
72992             for (var label = 0; label < labelOffsets.length; label++) {
72993                 if (labelOffsets[label] === operationIndex) {
72994                     flushLabel();
72995                     if (labelNumbers === undefined) {
72996                         labelNumbers = [];
72997                     }
72998                     if (labelNumbers[labelNumber] === undefined) {
72999                         labelNumbers[labelNumber] = [label];
73000                     }
73001                     else {
73002                         labelNumbers[labelNumber].push(label);
73003                     }
73004                 }
73005             }
73006         }
73007         function updateLabelExpressions() {
73008             if (labelExpressions !== undefined && labelNumbers !== undefined) {
73009                 for (var labelNumber_1 = 0; labelNumber_1 < labelNumbers.length; labelNumber_1++) {
73010                     var labels = labelNumbers[labelNumber_1];
73011                     if (labels !== undefined) {
73012                         for (var _i = 0, labels_1 = labels; _i < labels_1.length; _i++) {
73013                             var label = labels_1[_i];
73014                             var expressions = labelExpressions[label];
73015                             if (expressions !== undefined) {
73016                                 for (var _a = 0, expressions_1 = expressions; _a < expressions_1.length; _a++) {
73017                                     var expression = expressions_1[_a];
73018                                     expression.text = String(labelNumber_1);
73019                                 }
73020                             }
73021                         }
73022                     }
73023                 }
73024             }
73025         }
73026         function tryEnterOrLeaveBlock(operationIndex) {
73027             if (blocks) {
73028                 for (; blockIndex < blockActions.length && blockOffsets[blockIndex] <= operationIndex; blockIndex++) {
73029                     var block = blocks[blockIndex];
73030                     var blockAction = blockActions[blockIndex];
73031                     switch (block.kind) {
73032                         case 0:
73033                             if (blockAction === 0) {
73034                                 if (!exceptionBlockStack) {
73035                                     exceptionBlockStack = [];
73036                                 }
73037                                 if (!statements) {
73038                                     statements = [];
73039                                 }
73040                                 exceptionBlockStack.push(currentExceptionBlock);
73041                                 currentExceptionBlock = block;
73042                             }
73043                             else if (blockAction === 1) {
73044                                 currentExceptionBlock = exceptionBlockStack.pop();
73045                             }
73046                             break;
73047                         case 1:
73048                             if (blockAction === 0) {
73049                                 if (!withBlockStack) {
73050                                     withBlockStack = [];
73051                                 }
73052                                 withBlockStack.push(block);
73053                             }
73054                             else if (blockAction === 1) {
73055                                 withBlockStack.pop();
73056                             }
73057                             break;
73058                     }
73059                 }
73060             }
73061         }
73062         function writeOperation(operationIndex) {
73063             tryEnterLabel(operationIndex);
73064             tryEnterOrLeaveBlock(operationIndex);
73065             if (lastOperationWasAbrupt) {
73066                 return;
73067             }
73068             lastOperationWasAbrupt = false;
73069             lastOperationWasCompletion = false;
73070             var opcode = operations[operationIndex];
73071             if (opcode === 0) {
73072                 return;
73073             }
73074             else if (opcode === 10) {
73075                 return writeEndfinally();
73076             }
73077             var args = operationArguments[operationIndex];
73078             if (opcode === 1) {
73079                 return writeStatement(args[0]);
73080             }
73081             var location = operationLocations[operationIndex];
73082             switch (opcode) {
73083                 case 2:
73084                     return writeAssign(args[0], args[1], location);
73085                 case 3:
73086                     return writeBreak(args[0], location);
73087                 case 4:
73088                     return writeBreakWhenTrue(args[0], args[1], location);
73089                 case 5:
73090                     return writeBreakWhenFalse(args[0], args[1], location);
73091                 case 6:
73092                     return writeYield(args[0], location);
73093                 case 7:
73094                     return writeYieldStar(args[0], location);
73095                 case 8:
73096                     return writeReturn(args[0], location);
73097                 case 9:
73098                     return writeThrow(args[0], location);
73099             }
73100         }
73101         function writeStatement(statement) {
73102             if (statement) {
73103                 if (!statements) {
73104                     statements = [statement];
73105                 }
73106                 else {
73107                     statements.push(statement);
73108                 }
73109             }
73110         }
73111         function writeAssign(left, right, operationLocation) {
73112             writeStatement(ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(left, right)), operationLocation));
73113         }
73114         function writeThrow(expression, operationLocation) {
73115             lastOperationWasAbrupt = true;
73116             lastOperationWasCompletion = true;
73117             writeStatement(ts.setTextRange(ts.createThrow(expression), operationLocation));
73118         }
73119         function writeReturn(expression, operationLocation) {
73120             lastOperationWasAbrupt = true;
73121             lastOperationWasCompletion = true;
73122             writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression
73123                 ? [createInstruction(2), expression]
73124                 : [createInstruction(2)])), operationLocation), 384));
73125         }
73126         function writeBreak(label, operationLocation) {
73127             lastOperationWasAbrupt = true;
73128             writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([
73129                 createInstruction(3),
73130                 createLabel(label)
73131             ])), operationLocation), 384));
73132         }
73133         function writeBreakWhenTrue(label, condition, operationLocation) {
73134             writeStatement(ts.setEmitFlags(ts.createIf(condition, ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([
73135                 createInstruction(3),
73136                 createLabel(label)
73137             ])), operationLocation), 384)), 1));
73138         }
73139         function writeBreakWhenFalse(label, condition, operationLocation) {
73140             writeStatement(ts.setEmitFlags(ts.createIf(ts.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([
73141                 createInstruction(3),
73142                 createLabel(label)
73143             ])), operationLocation), 384)), 1));
73144         }
73145         function writeYield(expression, operationLocation) {
73146             lastOperationWasAbrupt = true;
73147             writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral(expression
73148                 ? [createInstruction(4), expression]
73149                 : [createInstruction(4)])), operationLocation), 384));
73150         }
73151         function writeYieldStar(expression, operationLocation) {
73152             lastOperationWasAbrupt = true;
73153             writeStatement(ts.setEmitFlags(ts.setTextRange(ts.createReturn(ts.createArrayLiteral([
73154                 createInstruction(5),
73155                 expression
73156             ])), operationLocation), 384));
73157         }
73158         function writeEndfinally() {
73159             lastOperationWasAbrupt = true;
73160             writeStatement(ts.createReturn(ts.createArrayLiteral([
73161                 createInstruction(7)
73162             ])));
73163         }
73164     }
73165     ts.transformGenerators = transformGenerators;
73166     function createGeneratorHelper(context, body) {
73167         context.requestEmitHelper(ts.generatorHelper);
73168         return ts.createCall(ts.getUnscopedHelperName("__generator"), undefined, [ts.createThis(), body]);
73169     }
73170     ts.generatorHelper = {
73171         name: "typescript:generator",
73172         importName: "__generator",
73173         scoped: false,
73174         priority: 6,
73175         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            };"
73176     };
73177 })(ts || (ts = {}));
73178 var ts;
73179 (function (ts) {
73180     function transformModule(context) {
73181         function getTransformModuleDelegate(moduleKind) {
73182             switch (moduleKind) {
73183                 case ts.ModuleKind.AMD: return transformAMDModule;
73184                 case ts.ModuleKind.UMD: return transformUMDModule;
73185                 default: return transformCommonJSModule;
73186             }
73187         }
73188         var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
73189         var compilerOptions = context.getCompilerOptions();
73190         var resolver = context.getEmitResolver();
73191         var host = context.getEmitHost();
73192         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
73193         var moduleKind = ts.getEmitModuleKind(compilerOptions);
73194         var previousOnSubstituteNode = context.onSubstituteNode;
73195         var previousOnEmitNode = context.onEmitNode;
73196         context.onSubstituteNode = onSubstituteNode;
73197         context.onEmitNode = onEmitNode;
73198         context.enableSubstitution(75);
73199         context.enableSubstitution(209);
73200         context.enableSubstitution(207);
73201         context.enableSubstitution(208);
73202         context.enableSubstitution(282);
73203         context.enableEmitNotification(290);
73204         var moduleInfoMap = [];
73205         var deferredExports = [];
73206         var currentSourceFile;
73207         var currentModuleInfo;
73208         var noSubstitution;
73209         var needUMDDynamicImportHelper;
73210         return ts.chainBundle(transformSourceFile);
73211         function transformSourceFile(node) {
73212             if (node.isDeclarationFile ||
73213                 !(ts.isEffectiveExternalModule(node, compilerOptions) ||
73214                     node.transformFlags & 2097152 ||
73215                     (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && (compilerOptions.out || compilerOptions.outFile)))) {
73216                 return node;
73217             }
73218             currentSourceFile = node;
73219             currentModuleInfo = ts.collectExternalModuleInfo(node, resolver, compilerOptions);
73220             moduleInfoMap[ts.getOriginalNodeId(node)] = currentModuleInfo;
73221             var transformModule = getTransformModuleDelegate(moduleKind);
73222             var updated = transformModule(node);
73223             currentSourceFile = undefined;
73224             currentModuleInfo = undefined;
73225             needUMDDynamicImportHelper = false;
73226             return ts.aggregateTransformFlags(updated);
73227         }
73228         function shouldEmitUnderscoreUnderscoreESModule() {
73229             if (!currentModuleInfo.exportEquals && ts.isExternalModule(currentSourceFile)) {
73230                 return true;
73231             }
73232             return false;
73233         }
73234         function transformCommonJSModule(node) {
73235             startLexicalEnvironment();
73236             var statements = [];
73237             var ensureUseStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile));
73238             var statementOffset = ts.addPrologue(statements, node.statements, ensureUseStrict && !ts.isJsonSourceFile(node), sourceElementVisitor);
73239             if (shouldEmitUnderscoreUnderscoreESModule()) {
73240                 ts.append(statements, createUnderscoreUnderscoreESModule());
73241             }
73242             if (ts.length(currentModuleInfo.exportedNames)) {
73243                 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())));
73244             }
73245             ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement));
73246             ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset));
73247             addExportEqualsIfNeeded(statements, false);
73248             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
73249             var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements));
73250             ts.addEmitHelpers(updated, context.readEmitHelpers());
73251             return updated;
73252         }
73253         function transformAMDModule(node) {
73254             var define = ts.createIdentifier("define");
73255             var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions);
73256             var jsonSourceFile = ts.isJsonSourceFile(node) && node;
73257             var _a = collectAsynchronousDependencies(node, true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames;
73258             var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([
73259                 ts.createExpressionStatement(ts.createCall(define, undefined, __spreadArrays((moduleName ? [moduleName] : []), [
73260                     ts.createArrayLiteral(jsonSourceFile ? ts.emptyArray : __spreadArrays([
73261                         ts.createLiteral("require"),
73262                         ts.createLiteral("exports")
73263                     ], aliasedModuleNames, unaliasedModuleNames)),
73264                     jsonSourceFile ?
73265                         jsonSourceFile.statements.length ? jsonSourceFile.statements[0].expression : ts.createObjectLiteral() :
73266                         ts.createFunctionExpression(undefined, undefined, undefined, undefined, __spreadArrays([
73267                             ts.createParameter(undefined, undefined, undefined, "require"),
73268                             ts.createParameter(undefined, undefined, undefined, "exports")
73269                         ], importAliasNames), undefined, transformAsynchronousModuleBody(node))
73270                 ])))
73271             ]), node.statements));
73272             ts.addEmitHelpers(updated, context.readEmitHelpers());
73273             return updated;
73274         }
73275         function transformUMDModule(node) {
73276             var _a = collectAsynchronousDependencies(node, false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames;
73277             var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions);
73278             var umdHeader = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, "factory")], undefined, ts.setTextRange(ts.createBlock([
73279                 ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([
73280                     ts.createVariableStatement(undefined, [
73281                         ts.createVariableDeclaration("v", undefined, ts.createCall(ts.createIdentifier("factory"), undefined, [
73282                             ts.createIdentifier("require"),
73283                             ts.createIdentifier("exports")
73284                         ]))
73285                     ]),
73286                     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)
73287                 ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([
73288                     ts.createExpressionStatement(ts.createCall(ts.createIdentifier("define"), undefined, __spreadArrays((moduleName ? [moduleName] : []), [
73289                         ts.createArrayLiteral(__spreadArrays([
73290                             ts.createLiteral("require"),
73291                             ts.createLiteral("exports")
73292                         ], aliasedModuleNames, unaliasedModuleNames)),
73293                         ts.createIdentifier("factory")
73294                     ])))
73295                 ])))
73296             ], true), undefined));
73297             var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([
73298                 ts.createExpressionStatement(ts.createCall(umdHeader, undefined, [
73299                     ts.createFunctionExpression(undefined, undefined, undefined, undefined, __spreadArrays([
73300                         ts.createParameter(undefined, undefined, undefined, "require"),
73301                         ts.createParameter(undefined, undefined, undefined, "exports")
73302                     ], importAliasNames), undefined, transformAsynchronousModuleBody(node))
73303                 ]))
73304             ]), node.statements));
73305             ts.addEmitHelpers(updated, context.readEmitHelpers());
73306             return updated;
73307         }
73308         function collectAsynchronousDependencies(node, includeNonAmdDependencies) {
73309             var aliasedModuleNames = [];
73310             var unaliasedModuleNames = [];
73311             var importAliasNames = [];
73312             for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) {
73313                 var amdDependency = _a[_i];
73314                 if (amdDependency.name) {
73315                     aliasedModuleNames.push(ts.createLiteral(amdDependency.path));
73316                     importAliasNames.push(ts.createParameter(undefined, undefined, undefined, amdDependency.name));
73317                 }
73318                 else {
73319                     unaliasedModuleNames.push(ts.createLiteral(amdDependency.path));
73320                 }
73321             }
73322             for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) {
73323                 var importNode = _c[_b];
73324                 var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions);
73325                 var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile);
73326                 if (externalModuleName) {
73327                     if (includeNonAmdDependencies && importAliasName) {
73328                         ts.setEmitFlags(importAliasName, 4);
73329                         aliasedModuleNames.push(externalModuleName);
73330                         importAliasNames.push(ts.createParameter(undefined, undefined, undefined, importAliasName));
73331                     }
73332                     else {
73333                         unaliasedModuleNames.push(externalModuleName);
73334                     }
73335                 }
73336             }
73337             return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames };
73338         }
73339         function getAMDImportExpressionForImport(node) {
73340             if (ts.isImportEqualsDeclaration(node) || ts.isExportDeclaration(node) || !ts.getExternalModuleNameLiteral(node, currentSourceFile, host, resolver, compilerOptions)) {
73341                 return undefined;
73342             }
73343             var name = ts.getLocalNameForExternalImport(node, currentSourceFile);
73344             var expr = getHelperExpressionForImport(node, name);
73345             if (expr === name) {
73346                 return undefined;
73347             }
73348             return ts.createExpressionStatement(ts.createAssignment(name, expr));
73349         }
73350         function transformAsynchronousModuleBody(node) {
73351             startLexicalEnvironment();
73352             var statements = [];
73353             var statementOffset = ts.addPrologue(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor);
73354             if (shouldEmitUnderscoreUnderscoreESModule()) {
73355                 ts.append(statements, createUnderscoreUnderscoreESModule());
73356             }
73357             if (ts.length(currentModuleInfo.exportedNames)) {
73358                 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())));
73359             }
73360             ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement));
73361             if (moduleKind === ts.ModuleKind.AMD) {
73362                 ts.addRange(statements, ts.mapDefined(currentModuleInfo.externalImports, getAMDImportExpressionForImport));
73363             }
73364             ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset));
73365             addExportEqualsIfNeeded(statements, true);
73366             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
73367             var body = ts.createBlock(statements, true);
73368             if (needUMDDynamicImportHelper) {
73369                 ts.addEmitHelper(body, dynamicImportUMDHelper);
73370             }
73371             return body;
73372         }
73373         function addExportEqualsIfNeeded(statements, emitAsReturn) {
73374             if (currentModuleInfo.exportEquals) {
73375                 var expressionResult = ts.visitNode(currentModuleInfo.exportEquals.expression, moduleExpressionElementVisitor);
73376                 if (expressionResult) {
73377                     if (emitAsReturn) {
73378                         var statement = ts.createReturn(expressionResult);
73379                         ts.setTextRange(statement, currentModuleInfo.exportEquals);
73380                         ts.setEmitFlags(statement, 384 | 1536);
73381                         statements.push(statement);
73382                     }
73383                     else {
73384                         var statement = ts.createExpressionStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult));
73385                         ts.setTextRange(statement, currentModuleInfo.exportEquals);
73386                         ts.setEmitFlags(statement, 1536);
73387                         statements.push(statement);
73388                     }
73389                 }
73390             }
73391         }
73392         function sourceElementVisitor(node) {
73393             switch (node.kind) {
73394                 case 254:
73395                     return visitImportDeclaration(node);
73396                 case 253:
73397                     return visitImportEqualsDeclaration(node);
73398                 case 260:
73399                     return visitExportDeclaration(node);
73400                 case 259:
73401                     return visitExportAssignment(node);
73402                 case 225:
73403                     return visitVariableStatement(node);
73404                 case 244:
73405                     return visitFunctionDeclaration(node);
73406                 case 245:
73407                     return visitClassDeclaration(node);
73408                 case 328:
73409                     return visitMergeDeclarationMarker(node);
73410                 case 329:
73411                     return visitEndOfDeclarationMarker(node);
73412                 default:
73413                     return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
73414             }
73415         }
73416         function moduleExpressionElementVisitor(node) {
73417             if (!(node.transformFlags & 2097152) && !(node.transformFlags & 1024)) {
73418                 return node;
73419             }
73420             if (ts.isImportCall(node)) {
73421                 return visitImportCallExpression(node);
73422             }
73423             else if (ts.isDestructuringAssignment(node)) {
73424                 return visitDestructuringAssignment(node);
73425             }
73426             else {
73427                 return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
73428             }
73429         }
73430         function destructuringNeedsFlattening(node) {
73431             if (ts.isObjectLiteralExpression(node)) {
73432                 for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
73433                     var elem = _a[_i];
73434                     switch (elem.kind) {
73435                         case 281:
73436                             if (destructuringNeedsFlattening(elem.initializer)) {
73437                                 return true;
73438                             }
73439                             break;
73440                         case 282:
73441                             if (destructuringNeedsFlattening(elem.name)) {
73442                                 return true;
73443                             }
73444                             break;
73445                         case 283:
73446                             if (destructuringNeedsFlattening(elem.expression)) {
73447                                 return true;
73448                             }
73449                             break;
73450                         case 161:
73451                         case 163:
73452                         case 164:
73453                             return false;
73454                         default: ts.Debug.assertNever(elem, "Unhandled object member kind");
73455                     }
73456                 }
73457             }
73458             else if (ts.isArrayLiteralExpression(node)) {
73459                 for (var _b = 0, _c = node.elements; _b < _c.length; _b++) {
73460                     var elem = _c[_b];
73461                     if (ts.isSpreadElement(elem)) {
73462                         if (destructuringNeedsFlattening(elem.expression)) {
73463                             return true;
73464                         }
73465                     }
73466                     else if (destructuringNeedsFlattening(elem)) {
73467                         return true;
73468                     }
73469                 }
73470             }
73471             else if (ts.isIdentifier(node)) {
73472                 return ts.length(getExports(node)) > (ts.isExportName(node) ? 1 : 0);
73473             }
73474             return false;
73475         }
73476         function visitDestructuringAssignment(node) {
73477             if (destructuringNeedsFlattening(node.left)) {
73478                 return ts.flattenDestructuringAssignment(node, moduleExpressionElementVisitor, context, 0, false, createAllExportExpressions);
73479             }
73480             return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
73481         }
73482         function visitImportCallExpression(node) {
73483             var argument = ts.visitNode(ts.firstOrUndefined(node.arguments), moduleExpressionElementVisitor);
73484             var containsLexicalThis = !!(node.transformFlags & 4096);
73485             switch (compilerOptions.module) {
73486                 case ts.ModuleKind.AMD:
73487                     return createImportCallExpressionAMD(argument, containsLexicalThis);
73488                 case ts.ModuleKind.UMD:
73489                     return createImportCallExpressionUMD(argument, containsLexicalThis);
73490                 case ts.ModuleKind.CommonJS:
73491                 default:
73492                     return createImportCallExpressionCommonJS(argument, containsLexicalThis);
73493             }
73494         }
73495         function createImportCallExpressionUMD(arg, containsLexicalThis) {
73496             needUMDDynamicImportHelper = true;
73497             if (ts.isSimpleCopiableExpression(arg)) {
73498                 var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? ts.createLiteral(arg) : ts.setEmitFlags(ts.setTextRange(ts.getSynthesizedClone(arg), arg), 1536);
73499                 return ts.createConditional(ts.createIdentifier("__syncRequire"), createImportCallExpressionCommonJS(arg, containsLexicalThis), createImportCallExpressionAMD(argClone, containsLexicalThis));
73500             }
73501             else {
73502                 var temp = ts.createTempVariable(hoistVariableDeclaration);
73503                 return ts.createComma(ts.createAssignment(temp, arg), ts.createConditional(ts.createIdentifier("__syncRequire"), createImportCallExpressionCommonJS(temp, containsLexicalThis), createImportCallExpressionAMD(temp, containsLexicalThis)));
73504             }
73505         }
73506         function createImportCallExpressionAMD(arg, containsLexicalThis) {
73507             var resolve = ts.createUniqueName("resolve");
73508             var reject = ts.createUniqueName("reject");
73509             var parameters = [
73510                 ts.createParameter(undefined, undefined, undefined, resolve),
73511                 ts.createParameter(undefined, undefined, undefined, reject)
73512             ];
73513             var body = ts.createBlock([
73514                 ts.createExpressionStatement(ts.createCall(ts.createIdentifier("require"), undefined, [ts.createArrayLiteral([arg || ts.createOmittedExpression()]), resolve, reject]))
73515             ]);
73516             var func;
73517             if (languageVersion >= 2) {
73518                 func = ts.createArrowFunction(undefined, undefined, parameters, undefined, undefined, body);
73519             }
73520             else {
73521                 func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, parameters, undefined, body);
73522                 if (containsLexicalThis) {
73523                     ts.setEmitFlags(func, 8);
73524                 }
73525             }
73526             var promise = ts.createNew(ts.createIdentifier("Promise"), undefined, [func]);
73527             if (compilerOptions.esModuleInterop) {
73528                 context.requestEmitHelper(ts.importStarHelper);
73529                 return ts.createCall(ts.createPropertyAccess(promise, ts.createIdentifier("then")), undefined, [ts.getUnscopedHelperName("__importStar")]);
73530             }
73531             return promise;
73532         }
73533         function createImportCallExpressionCommonJS(arg, containsLexicalThis) {
73534             var promiseResolveCall = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Promise"), "resolve"), undefined, []);
73535             var requireCall = ts.createCall(ts.createIdentifier("require"), undefined, arg ? [arg] : []);
73536             if (compilerOptions.esModuleInterop) {
73537                 context.requestEmitHelper(ts.importStarHelper);
73538                 requireCall = ts.createCall(ts.getUnscopedHelperName("__importStar"), undefined, [requireCall]);
73539             }
73540             var func;
73541             if (languageVersion >= 2) {
73542                 func = ts.createArrowFunction(undefined, undefined, [], undefined, undefined, requireCall);
73543             }
73544             else {
73545                 func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock([ts.createReturn(requireCall)]));
73546                 if (containsLexicalThis) {
73547                     ts.setEmitFlags(func, 8);
73548                 }
73549             }
73550             return ts.createCall(ts.createPropertyAccess(promiseResolveCall, "then"), undefined, [func]);
73551         }
73552         function getHelperExpressionForExport(node, innerExpr) {
73553             if (!compilerOptions.esModuleInterop || ts.getEmitFlags(node) & 67108864) {
73554                 return innerExpr;
73555             }
73556             if (ts.getExportNeedsImportStarHelper(node)) {
73557                 context.requestEmitHelper(ts.importStarHelper);
73558                 return ts.createCall(ts.getUnscopedHelperName("__importStar"), undefined, [innerExpr]);
73559             }
73560             return innerExpr;
73561         }
73562         function getHelperExpressionForImport(node, innerExpr) {
73563             if (!compilerOptions.esModuleInterop || ts.getEmitFlags(node) & 67108864) {
73564                 return innerExpr;
73565             }
73566             if (ts.getImportNeedsImportStarHelper(node)) {
73567                 context.requestEmitHelper(ts.importStarHelper);
73568                 return ts.createCall(ts.getUnscopedHelperName("__importStar"), undefined, [innerExpr]);
73569             }
73570             if (ts.getImportNeedsImportDefaultHelper(node)) {
73571                 context.requestEmitHelper(ts.importDefaultHelper);
73572                 return ts.createCall(ts.getUnscopedHelperName("__importDefault"), undefined, [innerExpr]);
73573             }
73574             return innerExpr;
73575         }
73576         function visitImportDeclaration(node) {
73577             var statements;
73578             var namespaceDeclaration = ts.getNamespaceDeclarationNode(node);
73579             if (moduleKind !== ts.ModuleKind.AMD) {
73580                 if (!node.importClause) {
73581                     return ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createRequireCall(node)), node), node);
73582                 }
73583                 else {
73584                     var variables = [];
73585                     if (namespaceDeclaration && !ts.isDefaultImport(node)) {
73586                         variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, getHelperExpressionForImport(node, createRequireCall(node))));
73587                     }
73588                     else {
73589                         variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), undefined, getHelperExpressionForImport(node, createRequireCall(node))));
73590                         if (namespaceDeclaration && ts.isDefaultImport(node)) {
73591                             variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node)));
73592                         }
73593                     }
73594                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(variables, languageVersion >= 2 ? 2 : 0)), node), node));
73595                 }
73596             }
73597             else if (namespaceDeclaration && ts.isDefaultImport(node)) {
73598                 statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
73599                     ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node)), node), node)
73600                 ], languageVersion >= 2 ? 2 : 0)));
73601             }
73602             if (hasAssociatedEndOfDeclarationMarker(node)) {
73603                 var id = ts.getOriginalNodeId(node);
73604                 deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node);
73605             }
73606             else {
73607                 statements = appendExportsOfImportDeclaration(statements, node);
73608             }
73609             return ts.singleOrMany(statements);
73610         }
73611         function createRequireCall(importNode) {
73612             var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions);
73613             var args = [];
73614             if (moduleName) {
73615                 args.push(moduleName);
73616             }
73617             return ts.createCall(ts.createIdentifier("require"), undefined, args);
73618         }
73619         function visitImportEqualsDeclaration(node) {
73620             ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer.");
73621             var statements;
73622             if (moduleKind !== ts.ModuleKind.AMD) {
73623                 if (ts.hasModifier(node, 1)) {
73624                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node), node));
73625                 }
73626                 else {
73627                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
73628                         ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), undefined, createRequireCall(node))
73629                     ], languageVersion >= 2 ? 2 : 0)), node), node));
73630                 }
73631             }
73632             else {
73633                 if (ts.hasModifier(node, 1)) {
73634                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node))), node), node));
73635                 }
73636             }
73637             if (hasAssociatedEndOfDeclarationMarker(node)) {
73638                 var id = ts.getOriginalNodeId(node);
73639                 deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node);
73640             }
73641             else {
73642                 statements = appendExportsOfImportEqualsDeclaration(statements, node);
73643             }
73644             return ts.singleOrMany(statements);
73645         }
73646         function visitExportDeclaration(node) {
73647             if (!node.moduleSpecifier) {
73648                 return undefined;
73649             }
73650             var generatedName = ts.getGeneratedNameForNode(node);
73651             if (node.exportClause && ts.isNamedExports(node.exportClause)) {
73652                 var statements = [];
73653                 if (moduleKind !== ts.ModuleKind.AMD) {
73654                     statements.push(ts.setOriginalNode(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
73655                         ts.createVariableDeclaration(generatedName, undefined, createRequireCall(node))
73656                     ])), node), node));
73657                 }
73658                 for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) {
73659                     var specifier = _a[_i];
73660                     if (languageVersion === 0) {
73661                         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));
73662                     }
73663                     else {
73664                         var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name);
73665                         statements.push(ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(specifier), exportedValue, undefined, true)), specifier), specifier));
73666                     }
73667                 }
73668                 return ts.singleOrMany(statements);
73669             }
73670             else if (node.exportClause) {
73671                 var statements = [];
73672                 statements.push(ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getSynthesizedClone(node.exportClause.name), moduleKind !== ts.ModuleKind.AMD ?
73673                     getHelperExpressionForExport(node, createRequireCall(node)) :
73674                     ts.createIdentifier(ts.idText(node.exportClause.name)))), node), node));
73675                 return ts.singleOrMany(statements);
73676             }
73677             else {
73678                 return ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createExportStarHelper(context, moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node), node);
73679             }
73680         }
73681         function visitExportAssignment(node) {
73682             if (node.isExportEquals) {
73683                 return undefined;
73684             }
73685             var statements;
73686             var original = node.original;
73687             if (original && hasAssociatedEndOfDeclarationMarker(original)) {
73688                 var id = ts.getOriginalNodeId(node);
73689                 deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), ts.visitNode(node.expression, moduleExpressionElementVisitor), node, true);
73690             }
73691             else {
73692                 statements = appendExportStatement(statements, ts.createIdentifier("default"), ts.visitNode(node.expression, moduleExpressionElementVisitor), node, true);
73693             }
73694             return ts.singleOrMany(statements);
73695         }
73696         function visitFunctionDeclaration(node) {
73697             var statements;
73698             if (ts.hasModifier(node, 1)) {
73699                 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));
73700             }
73701             else {
73702                 statements = ts.append(statements, ts.visitEachChild(node, moduleExpressionElementVisitor, context));
73703             }
73704             if (hasAssociatedEndOfDeclarationMarker(node)) {
73705                 var id = ts.getOriginalNodeId(node);
73706                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
73707             }
73708             else {
73709                 statements = appendExportsOfHoistedDeclaration(statements, node);
73710             }
73711             return ts.singleOrMany(statements);
73712         }
73713         function visitClassDeclaration(node) {
73714             var statements;
73715             if (ts.hasModifier(node, 1)) {
73716                 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));
73717             }
73718             else {
73719                 statements = ts.append(statements, ts.visitEachChild(node, moduleExpressionElementVisitor, context));
73720             }
73721             if (hasAssociatedEndOfDeclarationMarker(node)) {
73722                 var id = ts.getOriginalNodeId(node);
73723                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
73724             }
73725             else {
73726                 statements = appendExportsOfHoistedDeclaration(statements, node);
73727             }
73728             return ts.singleOrMany(statements);
73729         }
73730         function visitVariableStatement(node) {
73731             var statements;
73732             var variables;
73733             var expressions;
73734             if (ts.hasModifier(node, 1)) {
73735                 var modifiers = void 0;
73736                 for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
73737                     var variable = _a[_i];
73738                     if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) {
73739                         if (!modifiers) {
73740                             modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier);
73741                         }
73742                         variables = ts.append(variables, variable);
73743                     }
73744                     else if (variable.initializer) {
73745                         expressions = ts.append(expressions, transformInitializedVariable(variable));
73746                     }
73747                 }
73748                 if (variables) {
73749                     statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables)));
73750                 }
73751                 if (expressions) {
73752                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node), node));
73753                 }
73754             }
73755             else {
73756                 statements = ts.append(statements, ts.visitEachChild(node, moduleExpressionElementVisitor, context));
73757             }
73758             if (hasAssociatedEndOfDeclarationMarker(node)) {
73759                 var id = ts.getOriginalNodeId(node);
73760                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node);
73761             }
73762             else {
73763                 statements = appendExportsOfVariableStatement(statements, node);
73764             }
73765             return ts.singleOrMany(statements);
73766         }
73767         function createAllExportExpressions(name, value, location) {
73768             var exportedNames = getExports(name);
73769             if (exportedNames) {
73770                 var expression = ts.isExportName(name) ? value : ts.createAssignment(name, value);
73771                 for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) {
73772                     var exportName = exportedNames_1[_i];
73773                     ts.setEmitFlags(expression, 4);
73774                     expression = createExportExpression(exportName, expression, location);
73775                 }
73776                 return expression;
73777             }
73778             return ts.createAssignment(name, value);
73779         }
73780         function transformInitializedVariable(node) {
73781             if (ts.isBindingPattern(node.name)) {
73782                 return ts.flattenDestructuringAssignment(ts.visitNode(node, moduleExpressionElementVisitor), undefined, context, 0, false, createAllExportExpressions);
73783             }
73784             else {
73785                 return ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name), node.name), node.initializer ? ts.visitNode(node.initializer, moduleExpressionElementVisitor) : ts.createVoidZero());
73786             }
73787         }
73788         function visitMergeDeclarationMarker(node) {
73789             if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 225) {
73790                 var id = ts.getOriginalNodeId(node);
73791                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original);
73792             }
73793             return node;
73794         }
73795         function hasAssociatedEndOfDeclarationMarker(node) {
73796             return (ts.getEmitFlags(node) & 4194304) !== 0;
73797         }
73798         function visitEndOfDeclarationMarker(node) {
73799             var id = ts.getOriginalNodeId(node);
73800             var statements = deferredExports[id];
73801             if (statements) {
73802                 delete deferredExports[id];
73803                 return ts.append(statements, node);
73804             }
73805             return node;
73806         }
73807         function appendExportsOfImportDeclaration(statements, decl) {
73808             if (currentModuleInfo.exportEquals) {
73809                 return statements;
73810             }
73811             var importClause = decl.importClause;
73812             if (!importClause) {
73813                 return statements;
73814             }
73815             if (importClause.name) {
73816                 statements = appendExportsOfDeclaration(statements, importClause);
73817             }
73818             var namedBindings = importClause.namedBindings;
73819             if (namedBindings) {
73820                 switch (namedBindings.kind) {
73821                     case 256:
73822                         statements = appendExportsOfDeclaration(statements, namedBindings);
73823                         break;
73824                     case 257:
73825                         for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) {
73826                             var importBinding = _a[_i];
73827                             statements = appendExportsOfDeclaration(statements, importBinding, true);
73828                         }
73829                         break;
73830                 }
73831             }
73832             return statements;
73833         }
73834         function appendExportsOfImportEqualsDeclaration(statements, decl) {
73835             if (currentModuleInfo.exportEquals) {
73836                 return statements;
73837             }
73838             return appendExportsOfDeclaration(statements, decl);
73839         }
73840         function appendExportsOfVariableStatement(statements, node) {
73841             if (currentModuleInfo.exportEquals) {
73842                 return statements;
73843             }
73844             for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
73845                 var decl = _a[_i];
73846                 statements = appendExportsOfBindingElement(statements, decl);
73847             }
73848             return statements;
73849         }
73850         function appendExportsOfBindingElement(statements, decl) {
73851             if (currentModuleInfo.exportEquals) {
73852                 return statements;
73853             }
73854             if (ts.isBindingPattern(decl.name)) {
73855                 for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) {
73856                     var element = _a[_i];
73857                     if (!ts.isOmittedExpression(element)) {
73858                         statements = appendExportsOfBindingElement(statements, element);
73859                     }
73860                 }
73861             }
73862             else if (!ts.isGeneratedIdentifier(decl.name)) {
73863                 statements = appendExportsOfDeclaration(statements, decl);
73864             }
73865             return statements;
73866         }
73867         function appendExportsOfHoistedDeclaration(statements, decl) {
73868             if (currentModuleInfo.exportEquals) {
73869                 return statements;
73870             }
73871             if (ts.hasModifier(decl, 1)) {
73872                 var exportName = ts.hasModifier(decl, 512) ? ts.createIdentifier("default") : ts.getDeclarationName(decl);
73873                 statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), decl);
73874             }
73875             if (decl.name) {
73876                 statements = appendExportsOfDeclaration(statements, decl);
73877             }
73878             return statements;
73879         }
73880         function appendExportsOfDeclaration(statements, decl, liveBinding) {
73881             var name = ts.getDeclarationName(decl);
73882             var exportSpecifiers = currentModuleInfo.exportSpecifiers.get(ts.idText(name));
73883             if (exportSpecifiers) {
73884                 for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) {
73885                     var exportSpecifier = exportSpecifiers_1[_i];
73886                     statements = appendExportStatement(statements, exportSpecifier.name, name, exportSpecifier.name, undefined, liveBinding);
73887                 }
73888             }
73889             return statements;
73890         }
73891         function appendExportStatement(statements, exportName, expression, location, allowComments, liveBinding) {
73892             statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments, liveBinding));
73893             return statements;
73894         }
73895         function createUnderscoreUnderscoreESModule() {
73896             var statement;
73897             if (languageVersion === 0) {
73898                 statement = ts.createExpressionStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true)));
73899             }
73900             else {
73901                 statement = ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [
73902                     ts.createIdentifier("exports"),
73903                     ts.createLiteral("__esModule"),
73904                     ts.createObjectLiteral([
73905                         ts.createPropertyAssignment("value", ts.createLiteral(true))
73906                     ])
73907                 ]));
73908             }
73909             ts.setEmitFlags(statement, 1048576);
73910             return statement;
73911         }
73912         function createExportStatement(name, value, location, allowComments, liveBinding) {
73913             var statement = ts.setTextRange(ts.createExpressionStatement(createExportExpression(name, value, undefined, liveBinding)), location);
73914             ts.startOnNewLine(statement);
73915             if (!allowComments) {
73916                 ts.setEmitFlags(statement, 1536);
73917             }
73918             return statement;
73919         }
73920         function createExportExpression(name, value, location, liveBinding) {
73921             return ts.setTextRange(liveBinding && languageVersion !== 0 ? ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [
73922                 ts.createIdentifier("exports"),
73923                 ts.createLiteral(name),
73924                 ts.createObjectLiteral([
73925                     ts.createPropertyAssignment("enumerable", ts.createLiteral(true)),
73926                     ts.createPropertyAssignment("get", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock([ts.createReturn(value)])))
73927                 ])
73928             ]) : ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value), location);
73929         }
73930         function modifierVisitor(node) {
73931             switch (node.kind) {
73932                 case 89:
73933                 case 84:
73934                     return undefined;
73935             }
73936             return node;
73937         }
73938         function onEmitNode(hint, node, emitCallback) {
73939             if (node.kind === 290) {
73940                 currentSourceFile = node;
73941                 currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)];
73942                 noSubstitution = [];
73943                 previousOnEmitNode(hint, node, emitCallback);
73944                 currentSourceFile = undefined;
73945                 currentModuleInfo = undefined;
73946                 noSubstitution = undefined;
73947             }
73948             else {
73949                 previousOnEmitNode(hint, node, emitCallback);
73950             }
73951         }
73952         function onSubstituteNode(hint, node) {
73953             node = previousOnSubstituteNode(hint, node);
73954             if (node.id && noSubstitution[node.id]) {
73955                 return node;
73956             }
73957             if (hint === 1) {
73958                 return substituteExpression(node);
73959             }
73960             else if (ts.isShorthandPropertyAssignment(node)) {
73961                 return substituteShorthandPropertyAssignment(node);
73962             }
73963             return node;
73964         }
73965         function substituteShorthandPropertyAssignment(node) {
73966             var name = node.name;
73967             var exportedOrImportedName = substituteExpressionIdentifier(name);
73968             if (exportedOrImportedName !== name) {
73969                 if (node.objectAssignmentInitializer) {
73970                     var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer);
73971                     return ts.setTextRange(ts.createPropertyAssignment(name, initializer), node);
73972                 }
73973                 return ts.setTextRange(ts.createPropertyAssignment(name, exportedOrImportedName), node);
73974             }
73975             return node;
73976         }
73977         function substituteExpression(node) {
73978             switch (node.kind) {
73979                 case 75:
73980                     return substituteExpressionIdentifier(node);
73981                 case 209:
73982                     return substituteBinaryExpression(node);
73983                 case 208:
73984                 case 207:
73985                     return substituteUnaryExpression(node);
73986             }
73987             return node;
73988         }
73989         function substituteExpressionIdentifier(node) {
73990             if (ts.getEmitFlags(node) & 4096) {
73991                 var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile);
73992                 if (externalHelpersModuleName) {
73993                     return ts.createPropertyAccess(externalHelpersModuleName, node);
73994                 }
73995                 return node;
73996             }
73997             if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) {
73998                 var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node));
73999                 if (exportContainer && exportContainer.kind === 290) {
74000                     return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), node);
74001                 }
74002                 var importDeclaration = resolver.getReferencedImportDeclaration(node);
74003                 if (importDeclaration) {
74004                     if (ts.isImportClause(importDeclaration)) {
74005                         return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), node);
74006                     }
74007                     else if (ts.isImportSpecifier(importDeclaration)) {
74008                         var name = importDeclaration.propertyName || importDeclaration.name;
74009                         return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name)), node);
74010                     }
74011                 }
74012             }
74013             return node;
74014         }
74015         function substituteBinaryExpression(node) {
74016             if (ts.isAssignmentOperator(node.operatorToken.kind)
74017                 && ts.isIdentifier(node.left)
74018                 && !ts.isGeneratedIdentifier(node.left)
74019                 && !ts.isLocalName(node.left)
74020                 && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) {
74021                 var exportedNames = getExports(node.left);
74022                 if (exportedNames) {
74023                     var expression = node;
74024                     for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) {
74025                         var exportName = exportedNames_2[_i];
74026                         noSubstitution[ts.getNodeId(expression)] = true;
74027                         expression = createExportExpression(exportName, expression, node);
74028                     }
74029                     return expression;
74030                 }
74031             }
74032             return node;
74033         }
74034         function substituteUnaryExpression(node) {
74035             if ((node.operator === 45 || node.operator === 46)
74036                 && ts.isIdentifier(node.operand)
74037                 && !ts.isGeneratedIdentifier(node.operand)
74038                 && !ts.isLocalName(node.operand)
74039                 && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) {
74040                 var exportedNames = getExports(node.operand);
74041                 if (exportedNames) {
74042                     var expression = node.kind === 208
74043                         ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 45 ? 63 : 64), ts.createLiteral(1)), node)
74044                         : node;
74045                     for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) {
74046                         var exportName = exportedNames_3[_i];
74047                         noSubstitution[ts.getNodeId(expression)] = true;
74048                         expression = createExportExpression(exportName, expression);
74049                     }
74050                     return expression;
74051                 }
74052             }
74053             return node;
74054         }
74055         function getExports(name) {
74056             if (!ts.isGeneratedIdentifier(name)) {
74057                 var valueDeclaration = resolver.getReferencedImportDeclaration(name)
74058                     || resolver.getReferencedValueDeclaration(name);
74059                 if (valueDeclaration) {
74060                     return currentModuleInfo
74061                         && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)];
74062                 }
74063             }
74064         }
74065     }
74066     ts.transformModule = transformModule;
74067     ts.createBindingHelper = {
74068         name: "typescript:commonjscreatebinding",
74069         importName: "__createBinding",
74070         scoped: false,
74071         priority: 1,
74072         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}));"
74073     };
74074     function createCreateBindingHelper(context, module, inputName, outputName) {
74075         context.requestEmitHelper(ts.createBindingHelper);
74076         return ts.createCall(ts.getUnscopedHelperName("__createBinding"), undefined, __spreadArrays([ts.createIdentifier("exports"), module, inputName], (outputName ? [outputName] : [])));
74077     }
74078     ts.setModuleDefaultHelper = {
74079         name: "typescript:commonjscreatevalue",
74080         importName: "__setModuleDefault",
74081         scoped: false,
74082         priority: 1,
74083         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});"
74084     };
74085     var exportStarHelper = {
74086         name: "typescript:export-star",
74087         importName: "__exportStar",
74088         scoped: false,
74089         dependencies: [ts.createBindingHelper],
74090         priority: 2,
74091         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            };"
74092     };
74093     function createExportStarHelper(context, module) {
74094         context.requestEmitHelper(exportStarHelper);
74095         return ts.createCall(ts.getUnscopedHelperName("__exportStar"), undefined, [module, ts.createIdentifier("exports")]);
74096     }
74097     var dynamicImportUMDHelper = {
74098         name: "typescript:dynamicimport-sync-require",
74099         scoped: true,
74100         text: "\n            var __syncRequire = typeof module === \"object\" && typeof module.exports === \"object\";"
74101     };
74102     ts.importStarHelper = {
74103         name: "typescript:commonjsimportstar",
74104         importName: "__importStar",
74105         scoped: false,
74106         dependencies: [ts.createBindingHelper, ts.setModuleDefaultHelper],
74107         priority: 2,
74108         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};"
74109     };
74110     ts.importDefaultHelper = {
74111         name: "typescript:commonjsimportdefault",
74112         importName: "__importDefault",
74113         scoped: false,
74114         text: "\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};"
74115     };
74116 })(ts || (ts = {}));
74117 var ts;
74118 (function (ts) {
74119     function transformSystemModule(context) {
74120         var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
74121         var compilerOptions = context.getCompilerOptions();
74122         var resolver = context.getEmitResolver();
74123         var host = context.getEmitHost();
74124         var previousOnSubstituteNode = context.onSubstituteNode;
74125         var previousOnEmitNode = context.onEmitNode;
74126         context.onSubstituteNode = onSubstituteNode;
74127         context.onEmitNode = onEmitNode;
74128         context.enableSubstitution(75);
74129         context.enableSubstitution(282);
74130         context.enableSubstitution(209);
74131         context.enableSubstitution(207);
74132         context.enableSubstitution(208);
74133         context.enableSubstitution(219);
74134         context.enableEmitNotification(290);
74135         var moduleInfoMap = [];
74136         var deferredExports = [];
74137         var exportFunctionsMap = [];
74138         var noSubstitutionMap = [];
74139         var contextObjectMap = [];
74140         var currentSourceFile;
74141         var moduleInfo;
74142         var exportFunction;
74143         var contextObject;
74144         var hoistedStatements;
74145         var enclosingBlockScopedContainer;
74146         var noSubstitution;
74147         return ts.chainBundle(transformSourceFile);
74148         function transformSourceFile(node) {
74149             if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 2097152)) {
74150                 return node;
74151             }
74152             var id = ts.getOriginalNodeId(node);
74153             currentSourceFile = node;
74154             enclosingBlockScopedContainer = node;
74155             moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(node, resolver, compilerOptions);
74156             exportFunction = ts.createUniqueName("exports");
74157             exportFunctionsMap[id] = exportFunction;
74158             contextObject = contextObjectMap[id] = ts.createUniqueName("context");
74159             var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports);
74160             var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups);
74161             var moduleBodyFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [
74162                 ts.createParameter(undefined, undefined, undefined, exportFunction),
74163                 ts.createParameter(undefined, undefined, undefined, contextObject)
74164             ], undefined, moduleBodyBlock);
74165             var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions);
74166             var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; }));
74167             var updated = ts.setEmitFlags(ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([
74168                 ts.createExpressionStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), undefined, moduleName
74169                     ? [moduleName, dependencies, moduleBodyFunction]
74170                     : [dependencies, moduleBodyFunction]))
74171             ]), node.statements)), 1024);
74172             if (!(compilerOptions.outFile || compilerOptions.out)) {
74173                 ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; });
74174             }
74175             if (noSubstitution) {
74176                 noSubstitutionMap[id] = noSubstitution;
74177                 noSubstitution = undefined;
74178             }
74179             currentSourceFile = undefined;
74180             moduleInfo = undefined;
74181             exportFunction = undefined;
74182             contextObject = undefined;
74183             hoistedStatements = undefined;
74184             enclosingBlockScopedContainer = undefined;
74185             return ts.aggregateTransformFlags(updated);
74186         }
74187         function collectDependencyGroups(externalImports) {
74188             var groupIndices = ts.createMap();
74189             var dependencyGroups = [];
74190             for (var _i = 0, externalImports_1 = externalImports; _i < externalImports_1.length; _i++) {
74191                 var externalImport = externalImports_1[_i];
74192                 var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions);
74193                 if (externalModuleName) {
74194                     var text = externalModuleName.text;
74195                     var groupIndex = groupIndices.get(text);
74196                     if (groupIndex !== undefined) {
74197                         dependencyGroups[groupIndex].externalImports.push(externalImport);
74198                     }
74199                     else {
74200                         groupIndices.set(text, dependencyGroups.length);
74201                         dependencyGroups.push({
74202                             name: externalModuleName,
74203                             externalImports: [externalImport]
74204                         });
74205                     }
74206                 }
74207             }
74208             return dependencyGroups;
74209         }
74210         function createSystemModuleBody(node, dependencyGroups) {
74211             var statements = [];
74212             startLexicalEnvironment();
74213             var ensureUseStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile));
74214             var statementOffset = ts.addPrologue(statements, node.statements, ensureUseStrict, sourceElementVisitor);
74215             statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
74216                 ts.createVariableDeclaration("__moduleName", undefined, ts.createLogicalAnd(contextObject, ts.createPropertyAccess(contextObject, "id")))
74217             ])));
74218             ts.visitNode(moduleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement);
74219             var executeStatements = ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset);
74220             ts.addRange(statements, hoistedStatements);
74221             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
74222             var exportStarFunction = addExportStarIfNeeded(statements);
74223             var modifiers = node.transformFlags & 524288 ?
74224                 ts.createModifiersFromModifierFlags(256) :
74225                 undefined;
74226             var moduleObject = ts.createObjectLiteral([
74227                 ts.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)),
74228                 ts.createPropertyAssignment("execute", ts.createFunctionExpression(modifiers, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, true)))
74229             ]);
74230             moduleObject.multiLine = true;
74231             statements.push(ts.createReturn(moduleObject));
74232             return ts.createBlock(statements, true);
74233         }
74234         function addExportStarIfNeeded(statements) {
74235             if (!moduleInfo.hasExportStarsToExportValues) {
74236                 return;
74237             }
74238             if (!moduleInfo.exportedNames && moduleInfo.exportSpecifiers.size === 0) {
74239                 var hasExportDeclarationWithExportClause = false;
74240                 for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) {
74241                     var externalImport = _a[_i];
74242                     if (externalImport.kind === 260 && externalImport.exportClause) {
74243                         hasExportDeclarationWithExportClause = true;
74244                         break;
74245                     }
74246                 }
74247                 if (!hasExportDeclarationWithExportClause) {
74248                     var exportStarFunction_1 = createExportStarFunction(undefined);
74249                     statements.push(exportStarFunction_1);
74250                     return exportStarFunction_1.name;
74251                 }
74252             }
74253             var exportedNames = [];
74254             if (moduleInfo.exportedNames) {
74255                 for (var _b = 0, _c = moduleInfo.exportedNames; _b < _c.length; _b++) {
74256                     var exportedLocalName = _c[_b];
74257                     if (exportedLocalName.escapedText === "default") {
74258                         continue;
74259                     }
74260                     exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createTrue()));
74261                 }
74262             }
74263             for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) {
74264                 var externalImport = _e[_d];
74265                 if (externalImport.kind !== 260) {
74266                     continue;
74267                 }
74268                 if (!externalImport.exportClause) {
74269                     continue;
74270                 }
74271                 if (ts.isNamedExports(externalImport.exportClause)) {
74272                     for (var _f = 0, _g = externalImport.exportClause.elements; _f < _g.length; _f++) {
74273                         var element = _g[_f];
74274                         exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(ts.idText(element.name || element.propertyName)), ts.createTrue()));
74275                     }
74276                 }
74277                 else {
74278                     exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(ts.idText(externalImport.exportClause.name)), ts.createTrue()));
74279                 }
74280             }
74281             var exportedNamesStorageRef = ts.createUniqueName("exportedNames");
74282             statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
74283                 ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, true))
74284             ])));
74285             var exportStarFunction = createExportStarFunction(exportedNamesStorageRef);
74286             statements.push(exportStarFunction);
74287             return exportStarFunction.name;
74288         }
74289         function createExportStarFunction(localNames) {
74290             var exportStarFunction = ts.createUniqueName("exportStar");
74291             var m = ts.createIdentifier("m");
74292             var n = ts.createIdentifier("n");
74293             var exports = ts.createIdentifier("exports");
74294             var condition = ts.createStrictInequality(n, ts.createLiteral("default"));
74295             if (localNames) {
74296                 condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createCall(ts.createPropertyAccess(localNames, "hasOwnProperty"), undefined, [n])));
74297             }
74298             return ts.createFunctionDeclaration(undefined, undefined, undefined, exportStarFunction, undefined, [ts.createParameter(undefined, undefined, undefined, m)], undefined, ts.createBlock([
74299                 ts.createVariableStatement(undefined, ts.createVariableDeclarationList([
74300                     ts.createVariableDeclaration(exports, undefined, ts.createObjectLiteral([]))
74301                 ])),
74302                 ts.createForIn(ts.createVariableDeclarationList([
74303                     ts.createVariableDeclaration(n, undefined)
74304                 ]), m, ts.createBlock([
74305                     ts.setEmitFlags(ts.createIf(condition, ts.createExpressionStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1)
74306                 ])),
74307                 ts.createExpressionStatement(ts.createCall(exportFunction, undefined, [exports]))
74308             ], true));
74309         }
74310         function createSettersArray(exportStarFunction, dependencyGroups) {
74311             var setters = [];
74312             for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) {
74313                 var group_2 = dependencyGroups_1[_i];
74314                 var localName = ts.forEach(group_2.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); });
74315                 var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName("");
74316                 var statements = [];
74317                 for (var _a = 0, _b = group_2.externalImports; _a < _b.length; _a++) {
74318                     var entry = _b[_a];
74319                     var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile);
74320                     switch (entry.kind) {
74321                         case 254:
74322                             if (!entry.importClause) {
74323                                 break;
74324                             }
74325                         case 253:
74326                             ts.Debug.assert(importVariableName !== undefined);
74327                             statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName)));
74328                             break;
74329                         case 260:
74330                             ts.Debug.assert(importVariableName !== undefined);
74331                             if (entry.exportClause) {
74332                                 if (ts.isNamedExports(entry.exportClause)) {
74333                                     var properties = [];
74334                                     for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) {
74335                                         var e = _d[_c];
74336                                         properties.push(ts.createPropertyAssignment(ts.createLiteral(ts.idText(e.name)), ts.createElementAccess(parameterName, ts.createLiteral(ts.idText(e.propertyName || e.name)))));
74337                                     }
74338                                     statements.push(ts.createExpressionStatement(ts.createCall(exportFunction, undefined, [ts.createObjectLiteral(properties, true)])));
74339                                 }
74340                                 else {
74341                                     statements.push(ts.createExpressionStatement(ts.createCall(exportFunction, undefined, [
74342                                         ts.createLiteral(ts.idText(entry.exportClause.name)),
74343                                         parameterName
74344                                     ])));
74345                                 }
74346                             }
74347                             else {
74348                                 statements.push(ts.createExpressionStatement(ts.createCall(exportStarFunction, undefined, [parameterName])));
74349                             }
74350                             break;
74351                     }
74352                 }
74353                 setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, ts.createBlock(statements, true)));
74354             }
74355             return ts.createArrayLiteral(setters, true);
74356         }
74357         function sourceElementVisitor(node) {
74358             switch (node.kind) {
74359                 case 254:
74360                     return visitImportDeclaration(node);
74361                 case 253:
74362                     return visitImportEqualsDeclaration(node);
74363                 case 260:
74364                     return visitExportDeclaration(node);
74365                 case 259:
74366                     return visitExportAssignment(node);
74367                 default:
74368                     return nestedElementVisitor(node);
74369             }
74370         }
74371         function visitImportDeclaration(node) {
74372             var statements;
74373             if (node.importClause) {
74374                 hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile));
74375             }
74376             if (hasAssociatedEndOfDeclarationMarker(node)) {
74377                 var id = ts.getOriginalNodeId(node);
74378                 deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node);
74379             }
74380             else {
74381                 statements = appendExportsOfImportDeclaration(statements, node);
74382             }
74383             return ts.singleOrMany(statements);
74384         }
74385         function visitExportDeclaration(node) {
74386             ts.Debug.assertIsDefined(node);
74387             return undefined;
74388         }
74389         function visitImportEqualsDeclaration(node) {
74390             ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer.");
74391             var statements;
74392             hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile));
74393             if (hasAssociatedEndOfDeclarationMarker(node)) {
74394                 var id = ts.getOriginalNodeId(node);
74395                 deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node);
74396             }
74397             else {
74398                 statements = appendExportsOfImportEqualsDeclaration(statements, node);
74399             }
74400             return ts.singleOrMany(statements);
74401         }
74402         function visitExportAssignment(node) {
74403             if (node.isExportEquals) {
74404                 return undefined;
74405             }
74406             var expression = ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression);
74407             var original = node.original;
74408             if (original && hasAssociatedEndOfDeclarationMarker(original)) {
74409                 var id = ts.getOriginalNodeId(node);
74410                 deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), expression, true);
74411             }
74412             else {
74413                 return createExportStatement(ts.createIdentifier("default"), expression, true);
74414             }
74415         }
74416         function visitFunctionDeclaration(node) {
74417             if (ts.hasModifier(node, 1)) {
74418                 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)));
74419             }
74420             else {
74421                 hoistedStatements = ts.append(hoistedStatements, ts.visitEachChild(node, destructuringAndImportCallVisitor, context));
74422             }
74423             if (hasAssociatedEndOfDeclarationMarker(node)) {
74424                 var id = ts.getOriginalNodeId(node);
74425                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
74426             }
74427             else {
74428                 hoistedStatements = appendExportsOfHoistedDeclaration(hoistedStatements, node);
74429             }
74430             return undefined;
74431         }
74432         function visitClassDeclaration(node) {
74433             var statements;
74434             var name = ts.getLocalName(node);
74435             hoistVariableDeclaration(name);
74436             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));
74437             if (hasAssociatedEndOfDeclarationMarker(node)) {
74438                 var id = ts.getOriginalNodeId(node);
74439                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
74440             }
74441             else {
74442                 statements = appendExportsOfHoistedDeclaration(statements, node);
74443             }
74444             return ts.singleOrMany(statements);
74445         }
74446         function visitVariableStatement(node) {
74447             if (!shouldHoistVariableDeclarationList(node.declarationList)) {
74448                 return ts.visitNode(node, destructuringAndImportCallVisitor, ts.isStatement);
74449             }
74450             var expressions;
74451             var isExportedDeclaration = ts.hasModifier(node, 1);
74452             var isMarkedDeclaration = hasAssociatedEndOfDeclarationMarker(node);
74453             for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
74454                 var variable = _a[_i];
74455                 if (variable.initializer) {
74456                     expressions = ts.append(expressions, transformInitializedVariable(variable, isExportedDeclaration && !isMarkedDeclaration));
74457                 }
74458                 else {
74459                     hoistBindingElement(variable);
74460                 }
74461             }
74462             var statements;
74463             if (expressions) {
74464                 statements = ts.append(statements, ts.setTextRange(ts.createExpressionStatement(ts.inlineExpressions(expressions)), node));
74465             }
74466             if (isMarkedDeclaration) {
74467                 var id = ts.getOriginalNodeId(node);
74468                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node, isExportedDeclaration);
74469             }
74470             else {
74471                 statements = appendExportsOfVariableStatement(statements, node, false);
74472             }
74473             return ts.singleOrMany(statements);
74474         }
74475         function hoistBindingElement(node) {
74476             if (ts.isBindingPattern(node.name)) {
74477                 for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) {
74478                     var element = _a[_i];
74479                     if (!ts.isOmittedExpression(element)) {
74480                         hoistBindingElement(element);
74481                     }
74482                 }
74483             }
74484             else {
74485                 hoistVariableDeclaration(ts.getSynthesizedClone(node.name));
74486             }
74487         }
74488         function shouldHoistVariableDeclarationList(node) {
74489             return (ts.getEmitFlags(node) & 2097152) === 0
74490                 && (enclosingBlockScopedContainer.kind === 290
74491                     || (ts.getOriginalNode(node).flags & 3) === 0);
74492         }
74493         function transformInitializedVariable(node, isExportedDeclaration) {
74494             var createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment;
74495             return ts.isBindingPattern(node.name)
74496                 ? ts.flattenDestructuringAssignment(node, destructuringAndImportCallVisitor, context, 0, false, createAssignment)
74497                 : node.initializer ? createAssignment(node.name, ts.visitNode(node.initializer, destructuringAndImportCallVisitor, ts.isExpression)) : node.name;
74498         }
74499         function createExportedVariableAssignment(name, value, location) {
74500             return createVariableAssignment(name, value, location, true);
74501         }
74502         function createNonExportedVariableAssignment(name, value, location) {
74503             return createVariableAssignment(name, value, location, false);
74504         }
74505         function createVariableAssignment(name, value, location, isExportedDeclaration) {
74506             hoistVariableDeclaration(ts.getSynthesizedClone(name));
74507             return isExportedDeclaration
74508                 ? createExportExpression(name, preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location)))
74509                 : preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location));
74510         }
74511         function visitMergeDeclarationMarker(node) {
74512             if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 225) {
74513                 var id = ts.getOriginalNodeId(node);
74514                 var isExportedDeclaration = ts.hasModifier(node.original, 1);
74515                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration);
74516             }
74517             return node;
74518         }
74519         function hasAssociatedEndOfDeclarationMarker(node) {
74520             return (ts.getEmitFlags(node) & 4194304) !== 0;
74521         }
74522         function visitEndOfDeclarationMarker(node) {
74523             var id = ts.getOriginalNodeId(node);
74524             var statements = deferredExports[id];
74525             if (statements) {
74526                 delete deferredExports[id];
74527                 return ts.append(statements, node);
74528             }
74529             else {
74530                 var original = ts.getOriginalNode(node);
74531                 if (ts.isModuleOrEnumDeclaration(original)) {
74532                     return ts.append(appendExportsOfDeclaration(statements, original), node);
74533                 }
74534             }
74535             return node;
74536         }
74537         function appendExportsOfImportDeclaration(statements, decl) {
74538             if (moduleInfo.exportEquals) {
74539                 return statements;
74540             }
74541             var importClause = decl.importClause;
74542             if (!importClause) {
74543                 return statements;
74544             }
74545             if (importClause.name) {
74546                 statements = appendExportsOfDeclaration(statements, importClause);
74547             }
74548             var namedBindings = importClause.namedBindings;
74549             if (namedBindings) {
74550                 switch (namedBindings.kind) {
74551                     case 256:
74552                         statements = appendExportsOfDeclaration(statements, namedBindings);
74553                         break;
74554                     case 257:
74555                         for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) {
74556                             var importBinding = _a[_i];
74557                             statements = appendExportsOfDeclaration(statements, importBinding);
74558                         }
74559                         break;
74560                 }
74561             }
74562             return statements;
74563         }
74564         function appendExportsOfImportEqualsDeclaration(statements, decl) {
74565             if (moduleInfo.exportEquals) {
74566                 return statements;
74567             }
74568             return appendExportsOfDeclaration(statements, decl);
74569         }
74570         function appendExportsOfVariableStatement(statements, node, exportSelf) {
74571             if (moduleInfo.exportEquals) {
74572                 return statements;
74573             }
74574             for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
74575                 var decl = _a[_i];
74576                 if (decl.initializer || exportSelf) {
74577                     statements = appendExportsOfBindingElement(statements, decl, exportSelf);
74578                 }
74579             }
74580             return statements;
74581         }
74582         function appendExportsOfBindingElement(statements, decl, exportSelf) {
74583             if (moduleInfo.exportEquals) {
74584                 return statements;
74585             }
74586             if (ts.isBindingPattern(decl.name)) {
74587                 for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) {
74588                     var element = _a[_i];
74589                     if (!ts.isOmittedExpression(element)) {
74590                         statements = appendExportsOfBindingElement(statements, element, exportSelf);
74591                     }
74592                 }
74593             }
74594             else if (!ts.isGeneratedIdentifier(decl.name)) {
74595                 var excludeName = void 0;
74596                 if (exportSelf) {
74597                     statements = appendExportStatement(statements, decl.name, ts.getLocalName(decl));
74598                     excludeName = ts.idText(decl.name);
74599                 }
74600                 statements = appendExportsOfDeclaration(statements, decl, excludeName);
74601             }
74602             return statements;
74603         }
74604         function appendExportsOfHoistedDeclaration(statements, decl) {
74605             if (moduleInfo.exportEquals) {
74606                 return statements;
74607             }
74608             var excludeName;
74609             if (ts.hasModifier(decl, 1)) {
74610                 var exportName = ts.hasModifier(decl, 512) ? ts.createLiteral("default") : decl.name;
74611                 statements = appendExportStatement(statements, exportName, ts.getLocalName(decl));
74612                 excludeName = ts.getTextOfIdentifierOrLiteral(exportName);
74613             }
74614             if (decl.name) {
74615                 statements = appendExportsOfDeclaration(statements, decl, excludeName);
74616             }
74617             return statements;
74618         }
74619         function appendExportsOfDeclaration(statements, decl, excludeName) {
74620             if (moduleInfo.exportEquals) {
74621                 return statements;
74622             }
74623             var name = ts.getDeclarationName(decl);
74624             var exportSpecifiers = moduleInfo.exportSpecifiers.get(ts.idText(name));
74625             if (exportSpecifiers) {
74626                 for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) {
74627                     var exportSpecifier = exportSpecifiers_2[_i];
74628                     if (exportSpecifier.name.escapedText !== excludeName) {
74629                         statements = appendExportStatement(statements, exportSpecifier.name, name);
74630                     }
74631                 }
74632             }
74633             return statements;
74634         }
74635         function appendExportStatement(statements, exportName, expression, allowComments) {
74636             statements = ts.append(statements, createExportStatement(exportName, expression, allowComments));
74637             return statements;
74638         }
74639         function createExportStatement(name, value, allowComments) {
74640             var statement = ts.createExpressionStatement(createExportExpression(name, value));
74641             ts.startOnNewLine(statement);
74642             if (!allowComments) {
74643                 ts.setEmitFlags(statement, 1536);
74644             }
74645             return statement;
74646         }
74647         function createExportExpression(name, value) {
74648             var exportName = ts.isIdentifier(name) ? ts.createLiteral(name) : name;
74649             ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536);
74650             return ts.setCommentRange(ts.createCall(exportFunction, undefined, [exportName, value]), value);
74651         }
74652         function nestedElementVisitor(node) {
74653             switch (node.kind) {
74654                 case 225:
74655                     return visitVariableStatement(node);
74656                 case 244:
74657                     return visitFunctionDeclaration(node);
74658                 case 245:
74659                     return visitClassDeclaration(node);
74660                 case 230:
74661                     return visitForStatement(node);
74662                 case 231:
74663                     return visitForInStatement(node);
74664                 case 232:
74665                     return visitForOfStatement(node);
74666                 case 228:
74667                     return visitDoStatement(node);
74668                 case 229:
74669                     return visitWhileStatement(node);
74670                 case 238:
74671                     return visitLabeledStatement(node);
74672                 case 236:
74673                     return visitWithStatement(node);
74674                 case 237:
74675                     return visitSwitchStatement(node);
74676                 case 251:
74677                     return visitCaseBlock(node);
74678                 case 277:
74679                     return visitCaseClause(node);
74680                 case 278:
74681                     return visitDefaultClause(node);
74682                 case 240:
74683                     return visitTryStatement(node);
74684                 case 280:
74685                     return visitCatchClause(node);
74686                 case 223:
74687                     return visitBlock(node);
74688                 case 328:
74689                     return visitMergeDeclarationMarker(node);
74690                 case 329:
74691                     return visitEndOfDeclarationMarker(node);
74692                 default:
74693                     return destructuringAndImportCallVisitor(node);
74694             }
74695         }
74696         function visitForStatement(node) {
74697             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
74698             enclosingBlockScopedContainer = node;
74699             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));
74700             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
74701             return node;
74702         }
74703         function visitForInStatement(node) {
74704             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
74705             enclosingBlockScopedContainer = node;
74706             node = ts.updateForIn(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock));
74707             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
74708             return node;
74709         }
74710         function visitForOfStatement(node) {
74711             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
74712             enclosingBlockScopedContainer = node;
74713             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));
74714             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
74715             return node;
74716         }
74717         function shouldHoistForInitializer(node) {
74718             return ts.isVariableDeclarationList(node)
74719                 && shouldHoistVariableDeclarationList(node);
74720         }
74721         function visitForInitializer(node) {
74722             if (shouldHoistForInitializer(node)) {
74723                 var expressions = void 0;
74724                 for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) {
74725                     var variable = _a[_i];
74726                     expressions = ts.append(expressions, transformInitializedVariable(variable, false));
74727                     if (!variable.initializer) {
74728                         hoistBindingElement(variable);
74729                     }
74730                 }
74731                 return expressions ? ts.inlineExpressions(expressions) : ts.createOmittedExpression();
74732             }
74733             else {
74734                 return ts.visitEachChild(node, nestedElementVisitor, context);
74735             }
74736         }
74737         function visitDoStatement(node) {
74738             return ts.updateDo(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression));
74739         }
74740         function visitWhileStatement(node) {
74741             return ts.updateWhile(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock));
74742         }
74743         function visitLabeledStatement(node) {
74744             return ts.updateLabel(node, node.label, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock));
74745         }
74746         function visitWithStatement(node) {
74747             return ts.updateWith(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock));
74748         }
74749         function visitSwitchStatement(node) {
74750             return ts.updateSwitch(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.caseBlock, nestedElementVisitor, ts.isCaseBlock));
74751         }
74752         function visitCaseBlock(node) {
74753             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
74754             enclosingBlockScopedContainer = node;
74755             node = ts.updateCaseBlock(node, ts.visitNodes(node.clauses, nestedElementVisitor, ts.isCaseOrDefaultClause));
74756             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
74757             return node;
74758         }
74759         function visitCaseClause(node) {
74760             return ts.updateCaseClause(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNodes(node.statements, nestedElementVisitor, ts.isStatement));
74761         }
74762         function visitDefaultClause(node) {
74763             return ts.visitEachChild(node, nestedElementVisitor, context);
74764         }
74765         function visitTryStatement(node) {
74766             return ts.visitEachChild(node, nestedElementVisitor, context);
74767         }
74768         function visitCatchClause(node) {
74769             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
74770             enclosingBlockScopedContainer = node;
74771             node = ts.updateCatchClause(node, node.variableDeclaration, ts.visitNode(node.block, nestedElementVisitor, ts.isBlock));
74772             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
74773             return node;
74774         }
74775         function visitBlock(node) {
74776             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
74777             enclosingBlockScopedContainer = node;
74778             node = ts.visitEachChild(node, nestedElementVisitor, context);
74779             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
74780             return node;
74781         }
74782         function destructuringAndImportCallVisitor(node) {
74783             if (ts.isDestructuringAssignment(node)) {
74784                 return visitDestructuringAssignment(node);
74785             }
74786             else if (ts.isImportCall(node)) {
74787                 return visitImportCallExpression(node);
74788             }
74789             else if ((node.transformFlags & 1024) || (node.transformFlags & 2097152)) {
74790                 return ts.visitEachChild(node, destructuringAndImportCallVisitor, context);
74791             }
74792             else {
74793                 return node;
74794             }
74795         }
74796         function visitImportCallExpression(node) {
74797             return ts.createCall(ts.createPropertyAccess(contextObject, ts.createIdentifier("import")), undefined, ts.some(node.arguments) ? [ts.visitNode(node.arguments[0], destructuringAndImportCallVisitor)] : []);
74798         }
74799         function visitDestructuringAssignment(node) {
74800             if (hasExportedReferenceInDestructuringTarget(node.left)) {
74801                 return ts.flattenDestructuringAssignment(node, destructuringAndImportCallVisitor, context, 0, true);
74802             }
74803             return ts.visitEachChild(node, destructuringAndImportCallVisitor, context);
74804         }
74805         function hasExportedReferenceInDestructuringTarget(node) {
74806             if (ts.isAssignmentExpression(node, true)) {
74807                 return hasExportedReferenceInDestructuringTarget(node.left);
74808             }
74809             else if (ts.isSpreadElement(node)) {
74810                 return hasExportedReferenceInDestructuringTarget(node.expression);
74811             }
74812             else if (ts.isObjectLiteralExpression(node)) {
74813                 return ts.some(node.properties, hasExportedReferenceInDestructuringTarget);
74814             }
74815             else if (ts.isArrayLiteralExpression(node)) {
74816                 return ts.some(node.elements, hasExportedReferenceInDestructuringTarget);
74817             }
74818             else if (ts.isShorthandPropertyAssignment(node)) {
74819                 return hasExportedReferenceInDestructuringTarget(node.name);
74820             }
74821             else if (ts.isPropertyAssignment(node)) {
74822                 return hasExportedReferenceInDestructuringTarget(node.initializer);
74823             }
74824             else if (ts.isIdentifier(node)) {
74825                 var container = resolver.getReferencedExportContainer(node);
74826                 return container !== undefined && container.kind === 290;
74827             }
74828             else {
74829                 return false;
74830             }
74831         }
74832         function modifierVisitor(node) {
74833             switch (node.kind) {
74834                 case 89:
74835                 case 84:
74836                     return undefined;
74837             }
74838             return node;
74839         }
74840         function onEmitNode(hint, node, emitCallback) {
74841             if (node.kind === 290) {
74842                 var id = ts.getOriginalNodeId(node);
74843                 currentSourceFile = node;
74844                 moduleInfo = moduleInfoMap[id];
74845                 exportFunction = exportFunctionsMap[id];
74846                 noSubstitution = noSubstitutionMap[id];
74847                 contextObject = contextObjectMap[id];
74848                 if (noSubstitution) {
74849                     delete noSubstitutionMap[id];
74850                 }
74851                 previousOnEmitNode(hint, node, emitCallback);
74852                 currentSourceFile = undefined;
74853                 moduleInfo = undefined;
74854                 exportFunction = undefined;
74855                 contextObject = undefined;
74856                 noSubstitution = undefined;
74857             }
74858             else {
74859                 previousOnEmitNode(hint, node, emitCallback);
74860             }
74861         }
74862         function onSubstituteNode(hint, node) {
74863             node = previousOnSubstituteNode(hint, node);
74864             if (isSubstitutionPrevented(node)) {
74865                 return node;
74866             }
74867             if (hint === 1) {
74868                 return substituteExpression(node);
74869             }
74870             else if (hint === 4) {
74871                 return substituteUnspecified(node);
74872             }
74873             return node;
74874         }
74875         function substituteUnspecified(node) {
74876             switch (node.kind) {
74877                 case 282:
74878                     return substituteShorthandPropertyAssignment(node);
74879             }
74880             return node;
74881         }
74882         function substituteShorthandPropertyAssignment(node) {
74883             var name = node.name;
74884             if (!ts.isGeneratedIdentifier(name) && !ts.isLocalName(name)) {
74885                 var importDeclaration = resolver.getReferencedImportDeclaration(name);
74886                 if (importDeclaration) {
74887                     if (ts.isImportClause(importDeclaration)) {
74888                         return ts.setTextRange(ts.createPropertyAssignment(ts.getSynthesizedClone(name), ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"))), node);
74889                     }
74890                     else if (ts.isImportSpecifier(importDeclaration)) {
74891                         return ts.setTextRange(ts.createPropertyAssignment(ts.getSynthesizedClone(name), ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name))), node);
74892                     }
74893                 }
74894             }
74895             return node;
74896         }
74897         function substituteExpression(node) {
74898             switch (node.kind) {
74899                 case 75:
74900                     return substituteExpressionIdentifier(node);
74901                 case 209:
74902                     return substituteBinaryExpression(node);
74903                 case 207:
74904                 case 208:
74905                     return substituteUnaryExpression(node);
74906                 case 219:
74907                     return substituteMetaProperty(node);
74908             }
74909             return node;
74910         }
74911         function substituteExpressionIdentifier(node) {
74912             if (ts.getEmitFlags(node) & 4096) {
74913                 var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile);
74914                 if (externalHelpersModuleName) {
74915                     return ts.createPropertyAccess(externalHelpersModuleName, node);
74916                 }
74917                 return node;
74918             }
74919             if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) {
74920                 var importDeclaration = resolver.getReferencedImportDeclaration(node);
74921                 if (importDeclaration) {
74922                     if (ts.isImportClause(importDeclaration)) {
74923                         return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default")), node);
74924                     }
74925                     else if (ts.isImportSpecifier(importDeclaration)) {
74926                         return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name)), node);
74927                     }
74928                 }
74929             }
74930             return node;
74931         }
74932         function substituteBinaryExpression(node) {
74933             if (ts.isAssignmentOperator(node.operatorToken.kind)
74934                 && ts.isIdentifier(node.left)
74935                 && !ts.isGeneratedIdentifier(node.left)
74936                 && !ts.isLocalName(node.left)
74937                 && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) {
74938                 var exportedNames = getExports(node.left);
74939                 if (exportedNames) {
74940                     var expression = node;
74941                     for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) {
74942                         var exportName = exportedNames_4[_i];
74943                         expression = createExportExpression(exportName, preventSubstitution(expression));
74944                     }
74945                     return expression;
74946                 }
74947             }
74948             return node;
74949         }
74950         function substituteUnaryExpression(node) {
74951             if ((node.operator === 45 || node.operator === 46)
74952                 && ts.isIdentifier(node.operand)
74953                 && !ts.isGeneratedIdentifier(node.operand)
74954                 && !ts.isLocalName(node.operand)
74955                 && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) {
74956                 var exportedNames = getExports(node.operand);
74957                 if (exportedNames) {
74958                     var expression = node.kind === 208
74959                         ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node)
74960                         : node;
74961                     for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) {
74962                         var exportName = exportedNames_5[_i];
74963                         expression = createExportExpression(exportName, preventSubstitution(expression));
74964                     }
74965                     if (node.kind === 208) {
74966                         expression = node.operator === 45
74967                             ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1))
74968                             : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1));
74969                     }
74970                     return expression;
74971                 }
74972             }
74973             return node;
74974         }
74975         function substituteMetaProperty(node) {
74976             if (ts.isImportMeta(node)) {
74977                 return ts.createPropertyAccess(contextObject, ts.createIdentifier("meta"));
74978             }
74979             return node;
74980         }
74981         function getExports(name) {
74982             var exportedNames;
74983             if (!ts.isGeneratedIdentifier(name)) {
74984                 var valueDeclaration = resolver.getReferencedImportDeclaration(name)
74985                     || resolver.getReferencedValueDeclaration(name);
74986                 if (valueDeclaration) {
74987                     var exportContainer = resolver.getReferencedExportContainer(name, false);
74988                     if (exportContainer && exportContainer.kind === 290) {
74989                         exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration));
74990                     }
74991                     exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]);
74992                 }
74993             }
74994             return exportedNames;
74995         }
74996         function preventSubstitution(node) {
74997             if (noSubstitution === undefined)
74998                 noSubstitution = [];
74999             noSubstitution[ts.getNodeId(node)] = true;
75000             return node;
75001         }
75002         function isSubstitutionPrevented(node) {
75003             return noSubstitution && node.id && noSubstitution[node.id];
75004         }
75005     }
75006     ts.transformSystemModule = transformSystemModule;
75007 })(ts || (ts = {}));
75008 var ts;
75009 (function (ts) {
75010     function transformECMAScriptModule(context) {
75011         var compilerOptions = context.getCompilerOptions();
75012         var previousOnEmitNode = context.onEmitNode;
75013         var previousOnSubstituteNode = context.onSubstituteNode;
75014         context.onEmitNode = onEmitNode;
75015         context.onSubstituteNode = onSubstituteNode;
75016         context.enableEmitNotification(290);
75017         context.enableSubstitution(75);
75018         var helperNameSubstitutions;
75019         return ts.chainBundle(transformSourceFile);
75020         function transformSourceFile(node) {
75021             if (node.isDeclarationFile) {
75022                 return node;
75023             }
75024             if (ts.isExternalModule(node) || compilerOptions.isolatedModules) {
75025                 var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(node, compilerOptions);
75026                 if (externalHelpersImportDeclaration) {
75027                     var statements = [];
75028                     var statementOffset = ts.addPrologue(statements, node.statements);
75029                     ts.append(statements, externalHelpersImportDeclaration);
75030                     ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset));
75031                     return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements));
75032                 }
75033                 else {
75034                     return ts.visitEachChild(node, visitor, context);
75035                 }
75036             }
75037             return node;
75038         }
75039         function visitor(node) {
75040             switch (node.kind) {
75041                 case 253:
75042                     return undefined;
75043                 case 259:
75044                     return visitExportAssignment(node);
75045                 case 260:
75046                     var exportDecl = node;
75047                     return visitExportDeclaration(exportDecl);
75048             }
75049             return node;
75050         }
75051         function visitExportAssignment(node) {
75052             return node.isExportEquals ? undefined : node;
75053         }
75054         function visitExportDeclaration(node) {
75055             if (compilerOptions.module !== undefined && compilerOptions.module > ts.ModuleKind.ES2015) {
75056                 return node;
75057             }
75058             if (!node.exportClause || !ts.isNamespaceExport(node.exportClause) || !node.moduleSpecifier) {
75059                 return node;
75060             }
75061             var oldIdentifier = node.exportClause.name;
75062             var synthName = ts.getGeneratedNameForNode(oldIdentifier);
75063             var importDecl = ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(synthName)), node.moduleSpecifier);
75064             ts.setOriginalNode(importDecl, node.exportClause);
75065             var exportDecl = ts.createExportDeclaration(undefined, undefined, ts.createNamedExports([ts.createExportSpecifier(synthName, oldIdentifier)]));
75066             ts.setOriginalNode(exportDecl, node);
75067             return [importDecl, exportDecl];
75068         }
75069         function onEmitNode(hint, node, emitCallback) {
75070             if (ts.isSourceFile(node)) {
75071                 if ((ts.isExternalModule(node) || compilerOptions.isolatedModules) && compilerOptions.importHelpers) {
75072                     helperNameSubstitutions = ts.createMap();
75073                 }
75074                 previousOnEmitNode(hint, node, emitCallback);
75075                 helperNameSubstitutions = undefined;
75076             }
75077             else {
75078                 previousOnEmitNode(hint, node, emitCallback);
75079             }
75080         }
75081         function onSubstituteNode(hint, node) {
75082             node = previousOnSubstituteNode(hint, node);
75083             if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096) {
75084                 return substituteHelperName(node);
75085             }
75086             return node;
75087         }
75088         function substituteHelperName(node) {
75089             var name = ts.idText(node);
75090             var substitution = helperNameSubstitutions.get(name);
75091             if (!substitution) {
75092                 helperNameSubstitutions.set(name, substitution = ts.createFileLevelUniqueName(name));
75093             }
75094             return substitution;
75095         }
75096     }
75097     ts.transformECMAScriptModule = transformECMAScriptModule;
75098 })(ts || (ts = {}));
75099 var ts;
75100 (function (ts) {
75101     function canProduceDiagnostics(node) {
75102         return ts.isVariableDeclaration(node) ||
75103             ts.isPropertyDeclaration(node) ||
75104             ts.isPropertySignature(node) ||
75105             ts.isBindingElement(node) ||
75106             ts.isSetAccessor(node) ||
75107             ts.isGetAccessor(node) ||
75108             ts.isConstructSignatureDeclaration(node) ||
75109             ts.isCallSignatureDeclaration(node) ||
75110             ts.isMethodDeclaration(node) ||
75111             ts.isMethodSignature(node) ||
75112             ts.isFunctionDeclaration(node) ||
75113             ts.isParameter(node) ||
75114             ts.isTypeParameterDeclaration(node) ||
75115             ts.isExpressionWithTypeArguments(node) ||
75116             ts.isImportEqualsDeclaration(node) ||
75117             ts.isTypeAliasDeclaration(node) ||
75118             ts.isConstructorDeclaration(node) ||
75119             ts.isIndexSignatureDeclaration(node) ||
75120             ts.isPropertyAccessExpression(node);
75121     }
75122     ts.canProduceDiagnostics = canProduceDiagnostics;
75123     function createGetSymbolAccessibilityDiagnosticForNodeName(node) {
75124         if (ts.isSetAccessor(node) || ts.isGetAccessor(node)) {
75125             return getAccessorNameVisibilityError;
75126         }
75127         else if (ts.isMethodSignature(node) || ts.isMethodDeclaration(node)) {
75128             return getMethodNameVisibilityError;
75129         }
75130         else {
75131             return createGetSymbolAccessibilityDiagnosticForNode(node);
75132         }
75133         function getAccessorNameVisibilityError(symbolAccessibilityResult) {
75134             var diagnosticMessage = getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult);
75135             return diagnosticMessage !== undefined ? {
75136                 diagnosticMessage: diagnosticMessage,
75137                 errorNode: node,
75138                 typeName: node.name
75139             } : undefined;
75140         }
75141         function getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult) {
75142             if (ts.hasModifier(node, 32)) {
75143                 return symbolAccessibilityResult.errorModuleName ?
75144                     symbolAccessibilityResult.accessibility === 2 ?
75145                         ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75146                         ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
75147                     ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
75148             }
75149             else if (node.parent.kind === 245) {
75150                 return symbolAccessibilityResult.errorModuleName ?
75151                     symbolAccessibilityResult.accessibility === 2 ?
75152                         ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75153                         ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
75154                     ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1;
75155             }
75156             else {
75157                 return symbolAccessibilityResult.errorModuleName ?
75158                     ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75159                     ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1;
75160             }
75161         }
75162         function getMethodNameVisibilityError(symbolAccessibilityResult) {
75163             var diagnosticMessage = getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult);
75164             return diagnosticMessage !== undefined ? {
75165                 diagnosticMessage: diagnosticMessage,
75166                 errorNode: node,
75167                 typeName: node.name
75168             } : undefined;
75169         }
75170         function getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult) {
75171             if (ts.hasModifier(node, 32)) {
75172                 return symbolAccessibilityResult.errorModuleName ?
75173                     symbolAccessibilityResult.accessibility === 2 ?
75174                         ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75175                         ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
75176                     ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1;
75177             }
75178             else if (node.parent.kind === 245) {
75179                 return symbolAccessibilityResult.errorModuleName ?
75180                     symbolAccessibilityResult.accessibility === 2 ?
75181                         ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75182                         ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
75183                     ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_private_name_1;
75184             }
75185             else {
75186                 return symbolAccessibilityResult.errorModuleName ?
75187                     ts.Diagnostics.Method_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75188                     ts.Diagnostics.Method_0_of_exported_interface_has_or_is_using_private_name_1;
75189             }
75190         }
75191     }
75192     ts.createGetSymbolAccessibilityDiagnosticForNodeName = createGetSymbolAccessibilityDiagnosticForNodeName;
75193     function createGetSymbolAccessibilityDiagnosticForNode(node) {
75194         if (ts.isVariableDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertySignature(node) || ts.isPropertyAccessExpression(node) || ts.isBindingElement(node) || ts.isConstructorDeclaration(node)) {
75195             return getVariableDeclarationTypeVisibilityError;
75196         }
75197         else if (ts.isSetAccessor(node) || ts.isGetAccessor(node)) {
75198             return getAccessorDeclarationTypeVisibilityError;
75199         }
75200         else if (ts.isConstructSignatureDeclaration(node) || ts.isCallSignatureDeclaration(node) || ts.isMethodDeclaration(node) || ts.isMethodSignature(node) || ts.isFunctionDeclaration(node) || ts.isIndexSignatureDeclaration(node)) {
75201             return getReturnTypeVisibilityError;
75202         }
75203         else if (ts.isParameter(node)) {
75204             if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasModifier(node.parent, 8)) {
75205                 return getVariableDeclarationTypeVisibilityError;
75206             }
75207             return getParameterDeclarationTypeVisibilityError;
75208         }
75209         else if (ts.isTypeParameterDeclaration(node)) {
75210             return getTypeParameterConstraintVisibilityError;
75211         }
75212         else if (ts.isExpressionWithTypeArguments(node)) {
75213             return getHeritageClauseVisibilityError;
75214         }
75215         else if (ts.isImportEqualsDeclaration(node)) {
75216             return getImportEntityNameVisibilityError;
75217         }
75218         else if (ts.isTypeAliasDeclaration(node)) {
75219             return getTypeAliasDeclarationVisibilityError;
75220         }
75221         else {
75222             return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]);
75223         }
75224         function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) {
75225             if (node.kind === 242 || node.kind === 191) {
75226                 return symbolAccessibilityResult.errorModuleName ?
75227                     symbolAccessibilityResult.accessibility === 2 ?
75228                         ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75229                         ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 :
75230                     ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1;
75231             }
75232             else if (node.kind === 159 || node.kind === 194 || node.kind === 158 ||
75233                 (node.kind === 156 && ts.hasModifier(node.parent, 8))) {
75234                 if (ts.hasModifier(node, 32)) {
75235                     return symbolAccessibilityResult.errorModuleName ?
75236                         symbolAccessibilityResult.accessibility === 2 ?
75237                             ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75238                             ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
75239                         ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
75240                 }
75241                 else if (node.parent.kind === 245 || node.kind === 156) {
75242                     return symbolAccessibilityResult.errorModuleName ?
75243                         symbolAccessibilityResult.accessibility === 2 ?
75244                             ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75245                             ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
75246                         ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1;
75247                 }
75248                 else {
75249                     return symbolAccessibilityResult.errorModuleName ?
75250                         ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75251                         ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1;
75252                 }
75253             }
75254         }
75255         function getVariableDeclarationTypeVisibilityError(symbolAccessibilityResult) {
75256             var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult);
75257             return diagnosticMessage !== undefined ? {
75258                 diagnosticMessage: diagnosticMessage,
75259                 errorNode: node,
75260                 typeName: node.name
75261             } : undefined;
75262         }
75263         function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) {
75264             var diagnosticMessage;
75265             if (node.kind === 164) {
75266                 if (ts.hasModifier(node, 32)) {
75267                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75268                         ts.Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75269                         ts.Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_private_name_1;
75270                 }
75271                 else {
75272                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75273                         ts.Diagnostics.Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75274                         ts.Diagnostics.Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_private_name_1;
75275                 }
75276             }
75277             else {
75278                 if (ts.hasModifier(node, 32)) {
75279                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75280                         symbolAccessibilityResult.accessibility === 2 ?
75281                             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 :
75282                             ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75283                         ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1;
75284                 }
75285                 else {
75286                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75287                         symbolAccessibilityResult.accessibility === 2 ?
75288                             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 :
75289                             ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75290                         ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1;
75291                 }
75292             }
75293             return {
75294                 diagnosticMessage: diagnosticMessage,
75295                 errorNode: node.name,
75296                 typeName: node.name
75297             };
75298         }
75299         function getReturnTypeVisibilityError(symbolAccessibilityResult) {
75300             var diagnosticMessage;
75301             switch (node.kind) {
75302                 case 166:
75303                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75304                         ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
75305                         ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0;
75306                     break;
75307                 case 165:
75308                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75309                         ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
75310                         ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0;
75311                     break;
75312                 case 167:
75313                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75314                         ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
75315                         ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0;
75316                     break;
75317                 case 161:
75318                 case 160:
75319                     if (ts.hasModifier(node, 32)) {
75320                         diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75321                             symbolAccessibilityResult.accessibility === 2 ?
75322                                 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 :
75323                                 ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
75324                             ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0;
75325                     }
75326                     else if (node.parent.kind === 245) {
75327                         diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75328                             symbolAccessibilityResult.accessibility === 2 ?
75329                                 ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
75330                                 ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
75331                             ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0;
75332                     }
75333                     else {
75334                         diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75335                             ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
75336                             ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0;
75337                     }
75338                     break;
75339                 case 244:
75340                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
75341                         symbolAccessibilityResult.accessibility === 2 ?
75342                             ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
75343                             ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 :
75344                         ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0;
75345                     break;
75346                 default:
75347                     return ts.Debug.fail("This is unknown kind for signature: " + node.kind);
75348             }
75349             return {
75350                 diagnosticMessage: diagnosticMessage,
75351                 errorNode: node.name || node
75352             };
75353         }
75354         function getParameterDeclarationTypeVisibilityError(symbolAccessibilityResult) {
75355             var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult);
75356             return diagnosticMessage !== undefined ? {
75357                 diagnosticMessage: diagnosticMessage,
75358                 errorNode: node,
75359                 typeName: node.name
75360             } : undefined;
75361         }
75362         function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) {
75363             switch (node.parent.kind) {
75364                 case 162:
75365                     return symbolAccessibilityResult.errorModuleName ?
75366                         symbolAccessibilityResult.accessibility === 2 ?
75367                             ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75368                             ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75369                         ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1;
75370                 case 166:
75371                 case 171:
75372                     return symbolAccessibilityResult.errorModuleName ?
75373                         ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75374                         ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
75375                 case 165:
75376                     return symbolAccessibilityResult.errorModuleName ?
75377                         ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75378                         ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
75379                 case 167:
75380                     return symbolAccessibilityResult.errorModuleName ?
75381                         ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75382                         ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1;
75383                 case 161:
75384                 case 160:
75385                     if (ts.hasModifier(node.parent, 32)) {
75386                         return symbolAccessibilityResult.errorModuleName ?
75387                             symbolAccessibilityResult.accessibility === 2 ?
75388                                 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 :
75389                                 ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75390                             ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
75391                     }
75392                     else if (node.parent.parent.kind === 245) {
75393                         return symbolAccessibilityResult.errorModuleName ?
75394                             symbolAccessibilityResult.accessibility === 2 ?
75395                                 ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75396                                 ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
75397                             ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
75398                     }
75399                     else {
75400                         return symbolAccessibilityResult.errorModuleName ?
75401                             ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
75402                             ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
75403                     }
75404                 case 244:
75405                 case 170:
75406                     return symbolAccessibilityResult.errorModuleName ?
75407                         symbolAccessibilityResult.accessibility === 2 ?
75408                             ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75409                             ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 :
75410                         ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1;
75411                 case 164:
75412                 case 163:
75413                     return symbolAccessibilityResult.errorModuleName ?
75414                         symbolAccessibilityResult.accessibility === 2 ?
75415                             ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
75416                             ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 :
75417                         ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1;
75418                 default:
75419                     return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]);
75420             }
75421         }
75422         function getTypeParameterConstraintVisibilityError() {
75423             var diagnosticMessage;
75424             switch (node.parent.kind) {
75425                 case 245:
75426                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1;
75427                     break;
75428                 case 246:
75429                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1;
75430                     break;
75431                 case 186:
75432                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1;
75433                     break;
75434                 case 171:
75435                 case 166:
75436                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
75437                     break;
75438                 case 165:
75439                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
75440                     break;
75441                 case 161:
75442                 case 160:
75443                     if (ts.hasModifier(node.parent, 32)) {
75444                         diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
75445                     }
75446                     else if (node.parent.parent.kind === 245) {
75447                         diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
75448                     }
75449                     else {
75450                         diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
75451                     }
75452                     break;
75453                 case 170:
75454                 case 244:
75455                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1;
75456                     break;
75457                 case 247:
75458                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1;
75459                     break;
75460                 default:
75461                     return ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind);
75462             }
75463             return {
75464                 diagnosticMessage: diagnosticMessage,
75465                 errorNode: node,
75466                 typeName: node.name
75467             };
75468         }
75469         function getHeritageClauseVisibilityError() {
75470             var diagnosticMessage;
75471             if (node.parent.parent.kind === 245) {
75472                 diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 113 ?
75473                     ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 :
75474                     ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1;
75475             }
75476             else {
75477                 diagnosticMessage = ts.Diagnostics.extends_clause_of_exported_interface_0_has_or_is_using_private_name_1;
75478             }
75479             return {
75480                 diagnosticMessage: diagnosticMessage,
75481                 errorNode: node,
75482                 typeName: ts.getNameOfDeclaration(node.parent.parent)
75483             };
75484         }
75485         function getImportEntityNameVisibilityError() {
75486             return {
75487                 diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1,
75488                 errorNode: node,
75489                 typeName: node.name
75490             };
75491         }
75492         function getTypeAliasDeclarationVisibilityError() {
75493             return {
75494                 diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1,
75495                 errorNode: node.type,
75496                 typeName: node.name
75497             };
75498         }
75499     }
75500     ts.createGetSymbolAccessibilityDiagnosticForNode = createGetSymbolAccessibilityDiagnosticForNode;
75501 })(ts || (ts = {}));
75502 var ts;
75503 (function (ts) {
75504     function getDeclarationDiagnostics(host, resolver, file) {
75505         if (file && ts.isJsonSourceFile(file)) {
75506             return [];
75507         }
75508         var compilerOptions = host.getCompilerOptions();
75509         var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : ts.filter(host.getSourceFiles(), ts.isSourceFileNotJson), [transformDeclarations], false);
75510         return result.diagnostics;
75511     }
75512     ts.getDeclarationDiagnostics = getDeclarationDiagnostics;
75513     function hasInternalAnnotation(range, currentSourceFile) {
75514         var comment = currentSourceFile.text.substring(range.pos, range.end);
75515         return ts.stringContains(comment, "@internal");
75516     }
75517     function isInternalDeclaration(node, currentSourceFile) {
75518         var parseTreeNode = ts.getParseTreeNode(node);
75519         if (parseTreeNode && parseTreeNode.kind === 156) {
75520             var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode);
75521             var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined;
75522             var text = currentSourceFile.text;
75523             var commentRanges = previousSibling
75524                 ? ts.concatenate(ts.getTrailingCommentRanges(text, ts.skipTrivia(text, previousSibling.end + 1, false, true)), ts.getLeadingCommentRanges(text, node.pos))
75525                 : ts.getTrailingCommentRanges(text, ts.skipTrivia(text, node.pos, false, true));
75526             return commentRanges && commentRanges.length && hasInternalAnnotation(ts.last(commentRanges), currentSourceFile);
75527         }
75528         var leadingCommentRanges = parseTreeNode && ts.getLeadingCommentRangesOfNode(parseTreeNode, currentSourceFile);
75529         return !!ts.forEach(leadingCommentRanges, function (range) {
75530             return hasInternalAnnotation(range, currentSourceFile);
75531         });
75532     }
75533     ts.isInternalDeclaration = isInternalDeclaration;
75534     var declarationEmitNodeBuilderFlags = 1024 |
75535         2048 |
75536         4096 |
75537         8 |
75538         524288 |
75539         4 |
75540         1;
75541     function transformDeclarations(context) {
75542         var throwDiagnostic = function () { return ts.Debug.fail("Diagnostic emitted without context"); };
75543         var getSymbolAccessibilityDiagnostic = throwDiagnostic;
75544         var needsDeclare = true;
75545         var isBundledEmit = false;
75546         var resultHasExternalModuleIndicator = false;
75547         var needsScopeFixMarker = false;
75548         var resultHasScopeMarker = false;
75549         var enclosingDeclaration;
75550         var necessaryTypeReferences;
75551         var lateMarkedStatements;
75552         var lateStatementReplacementMap;
75553         var suppressNewDiagnosticContexts;
75554         var exportedModulesFromDeclarationEmit;
75555         var host = context.getEmitHost();
75556         var symbolTracker = {
75557             trackSymbol: trackSymbol,
75558             reportInaccessibleThisError: reportInaccessibleThisError,
75559             reportInaccessibleUniqueSymbolError: reportInaccessibleUniqueSymbolError,
75560             reportCyclicStructureError: reportCyclicStructureError,
75561             reportPrivateInBaseOfClassExpression: reportPrivateInBaseOfClassExpression,
75562             reportLikelyUnsafeImportRequiredError: reportLikelyUnsafeImportRequiredError,
75563             moduleResolverHost: host,
75564             trackReferencedAmbientModule: trackReferencedAmbientModule,
75565             trackExternalModuleSymbolOfImportTypeNode: trackExternalModuleSymbolOfImportTypeNode,
75566             reportNonlocalAugmentation: reportNonlocalAugmentation
75567         };
75568         var errorNameNode;
75569         var currentSourceFile;
75570         var refs;
75571         var libs;
75572         var emittedImports;
75573         var resolver = context.getEmitResolver();
75574         var options = context.getCompilerOptions();
75575         var noResolve = options.noResolve, stripInternal = options.stripInternal;
75576         return transformRoot;
75577         function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives) {
75578             if (!typeReferenceDirectives) {
75579                 return;
75580             }
75581             necessaryTypeReferences = necessaryTypeReferences || ts.createMap();
75582             for (var _i = 0, typeReferenceDirectives_2 = typeReferenceDirectives; _i < typeReferenceDirectives_2.length; _i++) {
75583                 var ref = typeReferenceDirectives_2[_i];
75584                 necessaryTypeReferences.set(ref, true);
75585             }
75586         }
75587         function trackReferencedAmbientModule(node, symbol) {
75588             var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863);
75589             if (ts.length(directives)) {
75590                 return recordTypeReferenceDirectivesIfNecessary(directives);
75591             }
75592             var container = ts.getSourceFileOfNode(node);
75593             refs.set("" + ts.getOriginalNodeId(container), container);
75594         }
75595         function handleSymbolAccessibilityError(symbolAccessibilityResult) {
75596             if (symbolAccessibilityResult.accessibility === 0) {
75597                 if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) {
75598                     if (!lateMarkedStatements) {
75599                         lateMarkedStatements = symbolAccessibilityResult.aliasesToMakeVisible;
75600                     }
75601                     else {
75602                         for (var _i = 0, _a = symbolAccessibilityResult.aliasesToMakeVisible; _i < _a.length; _i++) {
75603                             var ref = _a[_i];
75604                             ts.pushIfUnique(lateMarkedStatements, ref);
75605                         }
75606                     }
75607                 }
75608             }
75609             else {
75610                 var errorInfo = getSymbolAccessibilityDiagnostic(symbolAccessibilityResult);
75611                 if (errorInfo) {
75612                     if (errorInfo.typeName) {
75613                         context.addDiagnostic(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getTextOfNode(errorInfo.typeName), symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName));
75614                     }
75615                     else {
75616                         context.addDiagnostic(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName));
75617                     }
75618                 }
75619             }
75620         }
75621         function trackExternalModuleSymbolOfImportTypeNode(symbol) {
75622             if (!isBundledEmit) {
75623                 (exportedModulesFromDeclarationEmit || (exportedModulesFromDeclarationEmit = [])).push(symbol);
75624             }
75625         }
75626         function trackSymbol(symbol, enclosingDeclaration, meaning) {
75627             if (symbol.flags & 262144)
75628                 return;
75629             handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, true));
75630             recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning));
75631         }
75632         function reportPrivateInBaseOfClassExpression(propertyName) {
75633             if (errorNameNode) {
75634                 context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName));
75635             }
75636         }
75637         function reportInaccessibleUniqueSymbolError() {
75638             if (errorNameNode) {
75639                 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"));
75640             }
75641         }
75642         function reportCyclicStructureError() {
75643             if (errorNameNode) {
75644                 context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialized_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode)));
75645             }
75646         }
75647         function reportInaccessibleThisError() {
75648             if (errorNameNode) {
75649                 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"));
75650             }
75651         }
75652         function reportLikelyUnsafeImportRequiredError(specifier) {
75653             if (errorNameNode) {
75654                 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));
75655             }
75656         }
75657         function reportNonlocalAugmentation(containingFile, parentSymbol, symbol) {
75658             var primaryDeclaration = ts.find(parentSymbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === containingFile; });
75659             var augmentingDeclarations = ts.filter(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== containingFile; });
75660             for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) {
75661                 var augmentations = augmentingDeclarations_1[_i];
75662                 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)));
75663             }
75664         }
75665         function transformDeclarationsForJS(sourceFile, bundled) {
75666             var oldDiag = getSymbolAccessibilityDiagnostic;
75667             getSymbolAccessibilityDiagnostic = function (s) { return ({
75668                 diagnosticMessage: s.errorModuleName
75669                     ? ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit
75670                     : ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit,
75671                 errorNode: s.errorNode || sourceFile
75672             }); };
75673             var result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled);
75674             getSymbolAccessibilityDiagnostic = oldDiag;
75675             return result;
75676         }
75677         function transformRoot(node) {
75678             if (node.kind === 290 && node.isDeclarationFile) {
75679                 return node;
75680             }
75681             if (node.kind === 291) {
75682                 isBundledEmit = true;
75683                 refs = ts.createMap();
75684                 libs = ts.createMap();
75685                 var hasNoDefaultLib_1 = false;
75686                 var bundle = ts.createBundle(ts.map(node.sourceFiles, function (sourceFile) {
75687                     if (sourceFile.isDeclarationFile)
75688                         return undefined;
75689                     hasNoDefaultLib_1 = hasNoDefaultLib_1 || sourceFile.hasNoDefaultLib;
75690                     currentSourceFile = sourceFile;
75691                     enclosingDeclaration = sourceFile;
75692                     lateMarkedStatements = undefined;
75693                     suppressNewDiagnosticContexts = false;
75694                     lateStatementReplacementMap = ts.createMap();
75695                     getSymbolAccessibilityDiagnostic = throwDiagnostic;
75696                     needsScopeFixMarker = false;
75697                     resultHasScopeMarker = false;
75698                     collectReferences(sourceFile, refs);
75699                     collectLibs(sourceFile, libs);
75700                     if (ts.isExternalOrCommonJsModule(sourceFile) || ts.isJsonSourceFile(sourceFile)) {
75701                         resultHasExternalModuleIndicator = false;
75702                         needsDeclare = false;
75703                         var statements = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile, true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements);
75704                         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, []);
75705                         return newFile;
75706                     }
75707                     needsDeclare = true;
75708                     var updated = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements);
75709                     return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), true, [], [], false, []);
75710                 }), ts.mapDefined(node.prepends, function (prepend) {
75711                     if (prepend.kind === 293) {
75712                         var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal);
75713                         hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib;
75714                         collectReferences(sourceFile, refs);
75715                         recordTypeReferenceDirectivesIfNecessary(sourceFile.typeReferenceDirectives);
75716                         collectLibs(sourceFile, libs);
75717                         return sourceFile;
75718                     }
75719                     return prepend;
75720                 }));
75721                 bundle.syntheticFileReferences = [];
75722                 bundle.syntheticTypeReferences = getFileReferencesForUsedTypeReferences();
75723                 bundle.syntheticLibReferences = getLibReferences();
75724                 bundle.hasNoDefaultLib = hasNoDefaultLib_1;
75725                 var outputFilePath_1 = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, true).declarationFilePath));
75726                 var referenceVisitor_1 = mapReferencesIntoArray(bundle.syntheticFileReferences, outputFilePath_1);
75727                 refs.forEach(referenceVisitor_1);
75728                 return bundle;
75729             }
75730             needsDeclare = true;
75731             needsScopeFixMarker = false;
75732             resultHasScopeMarker = false;
75733             enclosingDeclaration = node;
75734             currentSourceFile = node;
75735             getSymbolAccessibilityDiagnostic = throwDiagnostic;
75736             isBundledEmit = false;
75737             resultHasExternalModuleIndicator = false;
75738             suppressNewDiagnosticContexts = false;
75739             lateMarkedStatements = undefined;
75740             lateStatementReplacementMap = ts.createMap();
75741             necessaryTypeReferences = undefined;
75742             refs = collectReferences(currentSourceFile, ts.createMap());
75743             libs = collectLibs(currentSourceFile, ts.createMap());
75744             var references = [];
75745             var outputFilePath = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, true).declarationFilePath));
75746             var referenceVisitor = mapReferencesIntoArray(references, outputFilePath);
75747             var combinedStatements;
75748             if (ts.isSourceFileJS(currentSourceFile)) {
75749                 combinedStatements = ts.createNodeArray(transformDeclarationsForJS(node));
75750                 refs.forEach(referenceVisitor);
75751                 emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax);
75752             }
75753             else {
75754                 var statements = ts.visitNodes(node.statements, visitDeclarationStatements);
75755                 combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements);
75756                 refs.forEach(referenceVisitor);
75757                 emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax);
75758                 if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) {
75759                     combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [ts.createEmptyExports()])), combinedStatements);
75760                 }
75761             }
75762             var updated = ts.updateSourceFileNode(node, combinedStatements, true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences());
75763             updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit;
75764             return updated;
75765             function getLibReferences() {
75766                 return ts.map(ts.arrayFrom(libs.keys()), function (lib) { return ({ fileName: lib, pos: -1, end: -1 }); });
75767             }
75768             function getFileReferencesForUsedTypeReferences() {
75769                 return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()), getFileReferenceForTypeName) : [];
75770             }
75771             function getFileReferenceForTypeName(typeName) {
75772                 if (emittedImports) {
75773                     for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
75774                         var importStatement = emittedImports_1[_i];
75775                         if (ts.isImportEqualsDeclaration(importStatement) && ts.isExternalModuleReference(importStatement.moduleReference)) {
75776                             var expr = importStatement.moduleReference.expression;
75777                             if (ts.isStringLiteralLike(expr) && expr.text === typeName) {
75778                                 return undefined;
75779                             }
75780                         }
75781                         else if (ts.isImportDeclaration(importStatement) && ts.isStringLiteral(importStatement.moduleSpecifier) && importStatement.moduleSpecifier.text === typeName) {
75782                             return undefined;
75783                         }
75784                     }
75785                 }
75786                 return { fileName: typeName, pos: -1, end: -1 };
75787             }
75788             function mapReferencesIntoArray(references, outputFilePath) {
75789                 return function (file) {
75790                     var declFileName;
75791                     if (file.isDeclarationFile) {
75792                         declFileName = file.fileName;
75793                     }
75794                     else {
75795                         if (isBundledEmit && ts.contains(node.sourceFiles, file))
75796                             return;
75797                         var paths = ts.getOutputPathsFor(file, host, true);
75798                         declFileName = paths.declarationFilePath || paths.jsFilePath || file.fileName;
75799                     }
75800                     if (declFileName) {
75801                         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);
75802                         if (!ts.pathIsRelative(specifier)) {
75803                             recordTypeReferenceDirectivesIfNecessary([specifier]);
75804                             return;
75805                         }
75806                         var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false);
75807                         if (ts.startsWith(fileName, "./") && ts.hasExtension(fileName)) {
75808                             fileName = fileName.substring(2);
75809                         }
75810                         if (ts.startsWith(fileName, "node_modules/") || ts.pathContainsNodeModules(fileName)) {
75811                             return;
75812                         }
75813                         references.push({ pos: -1, end: -1, fileName: fileName });
75814                     }
75815                 };
75816             }
75817         }
75818         function collectReferences(sourceFile, ret) {
75819             if (noResolve || (!ts.isUnparsedSource(sourceFile) && ts.isSourceFileJS(sourceFile)))
75820                 return ret;
75821             ts.forEach(sourceFile.referencedFiles, function (f) {
75822                 var elem = host.getSourceFileFromReference(sourceFile, f);
75823                 if (elem) {
75824                     ret.set("" + ts.getOriginalNodeId(elem), elem);
75825                 }
75826             });
75827             return ret;
75828         }
75829         function collectLibs(sourceFile, ret) {
75830             ts.forEach(sourceFile.libReferenceDirectives, function (ref) {
75831                 var lib = host.getLibFileFromReference(ref);
75832                 if (lib) {
75833                     ret.set(ts.toFileNameLowerCase(ref.fileName), true);
75834                 }
75835             });
75836             return ret;
75837         }
75838         function filterBindingPatternInitializers(name) {
75839             if (name.kind === 75) {
75840                 return name;
75841             }
75842             else {
75843                 if (name.kind === 190) {
75844                     return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement));
75845                 }
75846                 else {
75847                     return ts.updateObjectBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement));
75848                 }
75849             }
75850             function visitBindingElement(elem) {
75851                 if (elem.kind === 215) {
75852                     return elem;
75853                 }
75854                 return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
75855             }
75856         }
75857         function ensureParameter(p, modifierMask, type) {
75858             var oldDiag;
75859             if (!suppressNewDiagnosticContexts) {
75860                 oldDiag = getSymbolAccessibilityDiagnostic;
75861                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p);
75862             }
75863             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));
75864             if (!suppressNewDiagnosticContexts) {
75865                 getSymbolAccessibilityDiagnostic = oldDiag;
75866             }
75867             return newParam;
75868         }
75869         function shouldPrintWithInitializer(node) {
75870             return canHaveLiteralInitializer(node) && resolver.isLiteralConstDeclaration(ts.getParseTreeNode(node));
75871         }
75872         function ensureNoInitializer(node) {
75873             if (shouldPrintWithInitializer(node)) {
75874                 return resolver.createLiteralConstValue(ts.getParseTreeNode(node), symbolTracker);
75875             }
75876             return undefined;
75877         }
75878         function ensureType(node, type, ignorePrivate) {
75879             if (!ignorePrivate && ts.hasModifier(node, 8)) {
75880                 return;
75881             }
75882             if (shouldPrintWithInitializer(node)) {
75883                 return;
75884             }
75885             var shouldUseResolverType = node.kind === 156 &&
75886                 (resolver.isRequiredInitializedParameter(node) ||
75887                     resolver.isOptionalUninitializedParameterProperty(node));
75888             if (type && !shouldUseResolverType) {
75889                 return ts.visitNode(type, visitDeclarationSubtree);
75890             }
75891             if (!ts.getParseTreeNode(node)) {
75892                 return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(125);
75893             }
75894             if (node.kind === 164) {
75895                 return ts.createKeywordTypeNode(125);
75896             }
75897             errorNameNode = node.name;
75898             var oldDiag;
75899             if (!suppressNewDiagnosticContexts) {
75900                 oldDiag = getSymbolAccessibilityDiagnostic;
75901                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node);
75902             }
75903             if (node.kind === 242 || node.kind === 191) {
75904                 return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker));
75905             }
75906             if (node.kind === 156
75907                 || node.kind === 159
75908                 || node.kind === 158) {
75909                 if (!node.initializer)
75910                     return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType));
75911                 return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker));
75912             }
75913             return cleanup(resolver.createReturnTypeOfSignatureDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker));
75914             function cleanup(returnValue) {
75915                 errorNameNode = undefined;
75916                 if (!suppressNewDiagnosticContexts) {
75917                     getSymbolAccessibilityDiagnostic = oldDiag;
75918                 }
75919                 return returnValue || ts.createKeywordTypeNode(125);
75920             }
75921         }
75922         function isDeclarationAndNotVisible(node) {
75923             node = ts.getParseTreeNode(node);
75924             switch (node.kind) {
75925                 case 244:
75926                 case 249:
75927                 case 246:
75928                 case 245:
75929                 case 247:
75930                 case 248:
75931                     return !resolver.isDeclarationVisible(node);
75932                 case 242:
75933                     return !getBindingNameVisible(node);
75934                 case 253:
75935                 case 254:
75936                 case 260:
75937                 case 259:
75938                     return false;
75939             }
75940             return false;
75941         }
75942         function getBindingNameVisible(elem) {
75943             if (ts.isOmittedExpression(elem)) {
75944                 return false;
75945             }
75946             if (ts.isBindingPattern(elem.name)) {
75947                 return ts.some(elem.name.elements, getBindingNameVisible);
75948             }
75949             else {
75950                 return resolver.isDeclarationVisible(elem);
75951             }
75952         }
75953         function updateParamsList(node, params, modifierMask) {
75954             if (ts.hasModifier(node, 8)) {
75955                 return undefined;
75956             }
75957             var newParams = ts.map(params, function (p) { return ensureParameter(p, modifierMask); });
75958             if (!newParams) {
75959                 return undefined;
75960             }
75961             return ts.createNodeArray(newParams, params.hasTrailingComma);
75962         }
75963         function updateAccessorParamsList(input, isPrivate) {
75964             var newParams;
75965             if (!isPrivate) {
75966                 var thisParameter = ts.getThisParameter(input);
75967                 if (thisParameter) {
75968                     newParams = [ensureParameter(thisParameter)];
75969                 }
75970             }
75971             if (ts.isSetAccessorDeclaration(input)) {
75972                 var newValueParameter = void 0;
75973                 if (!isPrivate) {
75974                     var valueParameter = ts.getSetAccessorValueParameter(input);
75975                     if (valueParameter) {
75976                         var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input));
75977                         newValueParameter = ensureParameter(valueParameter, undefined, accessorType);
75978                     }
75979                 }
75980                 if (!newValueParameter) {
75981                     newValueParameter = ts.createParameter(undefined, undefined, undefined, "value");
75982                 }
75983                 newParams = ts.append(newParams, newValueParameter);
75984             }
75985             return ts.createNodeArray(newParams || ts.emptyArray);
75986         }
75987         function ensureTypeParams(node, params) {
75988             return ts.hasModifier(node, 8) ? undefined : ts.visitNodes(params, visitDeclarationSubtree);
75989         }
75990         function isEnclosingDeclaration(node) {
75991             return ts.isSourceFile(node)
75992                 || ts.isTypeAliasDeclaration(node)
75993                 || ts.isModuleDeclaration(node)
75994                 || ts.isClassDeclaration(node)
75995                 || ts.isInterfaceDeclaration(node)
75996                 || ts.isFunctionLike(node)
75997                 || ts.isIndexSignatureDeclaration(node)
75998                 || ts.isMappedTypeNode(node);
75999         }
76000         function checkEntityNameVisibility(entityName, enclosingDeclaration) {
76001             var visibilityResult = resolver.isEntityNameVisible(entityName, enclosingDeclaration);
76002             handleSymbolAccessibilityError(visibilityResult);
76003             recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName));
76004         }
76005         function preserveJsDoc(updated, original) {
76006             if (ts.hasJSDocNodes(updated) && ts.hasJSDocNodes(original)) {
76007                 updated.jsDoc = original.jsDoc;
76008             }
76009             return ts.setCommentRange(updated, ts.getCommentRange(original));
76010         }
76011         function rewriteModuleSpecifier(parent, input) {
76012             if (!input)
76013                 return undefined;
76014             resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 249 && parent.kind !== 188);
76015             if (ts.isStringLiteralLike(input)) {
76016                 if (isBundledEmit) {
76017                     var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent);
76018                     if (newName) {
76019                         return ts.createLiteral(newName);
76020                     }
76021                 }
76022                 else {
76023                     var symbol = resolver.getSymbolOfExternalModuleSpecifier(input);
76024                     if (symbol) {
76025                         (exportedModulesFromDeclarationEmit || (exportedModulesFromDeclarationEmit = [])).push(symbol);
76026                     }
76027                 }
76028             }
76029             return input;
76030         }
76031         function transformImportEqualsDeclaration(decl) {
76032             if (!resolver.isDeclarationVisible(decl))
76033                 return;
76034             if (decl.moduleReference.kind === 265) {
76035                 var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl);
76036                 return ts.updateImportEqualsDeclaration(decl, undefined, decl.modifiers, decl.name, ts.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier(decl, specifier)));
76037             }
76038             else {
76039                 var oldDiag = getSymbolAccessibilityDiagnostic;
76040                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(decl);
76041                 checkEntityNameVisibility(decl.moduleReference, enclosingDeclaration);
76042                 getSymbolAccessibilityDiagnostic = oldDiag;
76043                 return decl;
76044             }
76045         }
76046         function transformImportDeclaration(decl) {
76047             if (!decl.importClause) {
76048                 return ts.updateImportDeclaration(decl, undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier));
76049             }
76050             var visibleDefaultBinding = decl.importClause && decl.importClause.name && resolver.isDeclarationVisible(decl.importClause) ? decl.importClause.name : undefined;
76051             if (!decl.importClause.namedBindings) {
76052                 return visibleDefaultBinding && ts.updateImportDeclaration(decl, undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, undefined, decl.importClause.isTypeOnly), rewriteModuleSpecifier(decl, decl.moduleSpecifier));
76053             }
76054             if (decl.importClause.namedBindings.kind === 256) {
76055                 var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : undefined;
76056                 return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings, decl.importClause.isTypeOnly), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined;
76057             }
76058             var bindingList = ts.mapDefined(decl.importClause.namedBindings.elements, function (b) { return resolver.isDeclarationVisible(b) ? b : undefined; });
76059             if ((bindingList && bindingList.length) || visibleDefaultBinding) {
76060                 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));
76061             }
76062             if (resolver.isImportRequiredByAugmentation(decl)) {
76063                 return ts.updateImportDeclaration(decl, undefined, decl.modifiers, undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier));
76064             }
76065         }
76066         function transformAndReplaceLatePaintedStatements(statements) {
76067             while (ts.length(lateMarkedStatements)) {
76068                 var i = lateMarkedStatements.shift();
76069                 if (!ts.isLateVisibilityPaintedStatement(i)) {
76070                     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));
76071                 }
76072                 var priorNeedsDeclare = needsDeclare;
76073                 needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit);
76074                 var result = transformTopLevelDeclaration(i);
76075                 needsDeclare = priorNeedsDeclare;
76076                 lateStatementReplacementMap.set("" + ts.getOriginalNodeId(i), result);
76077             }
76078             return ts.visitNodes(statements, visitLateVisibilityMarkedStatements);
76079             function visitLateVisibilityMarkedStatements(statement) {
76080                 if (ts.isLateVisibilityPaintedStatement(statement)) {
76081                     var key = "" + ts.getOriginalNodeId(statement);
76082                     if (lateStatementReplacementMap.has(key)) {
76083                         var result = lateStatementReplacementMap.get(key);
76084                         lateStatementReplacementMap.delete(key);
76085                         if (result) {
76086                             if (ts.isArray(result) ? ts.some(result, ts.needsScopeMarker) : ts.needsScopeMarker(result)) {
76087                                 needsScopeFixMarker = true;
76088                             }
76089                             if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, ts.isExternalModuleIndicator) : ts.isExternalModuleIndicator(result))) {
76090                                 resultHasExternalModuleIndicator = true;
76091                             }
76092                         }
76093                         return result;
76094                     }
76095                 }
76096                 return statement;
76097             }
76098         }
76099         function visitDeclarationSubtree(input) {
76100             if (shouldStripInternal(input))
76101                 return;
76102             if (ts.isDeclaration(input)) {
76103                 if (isDeclarationAndNotVisible(input))
76104                     return;
76105                 if (ts.hasDynamicName(input) && !resolver.isLateBound(ts.getParseTreeNode(input))) {
76106                     return;
76107                 }
76108             }
76109             if (ts.isFunctionLike(input) && resolver.isImplementationOfOverload(input))
76110                 return;
76111             if (ts.isSemicolonClassElement(input))
76112                 return;
76113             var previousEnclosingDeclaration;
76114             if (isEnclosingDeclaration(input)) {
76115                 previousEnclosingDeclaration = enclosingDeclaration;
76116                 enclosingDeclaration = input;
76117             }
76118             var oldDiag = getSymbolAccessibilityDiagnostic;
76119             var canProduceDiagnostic = ts.canProduceDiagnostics(input);
76120             var oldWithinObjectLiteralType = suppressNewDiagnosticContexts;
76121             var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 173 || input.kind === 186) && input.parent.kind !== 247);
76122             if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) {
76123                 if (ts.hasModifier(input, 8)) {
76124                     if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input)
76125                         return;
76126                     return cleanup(ts.createProperty(undefined, ensureModifiers(input), input.name, undefined, undefined, undefined));
76127                 }
76128             }
76129             if (canProduceDiagnostic && !suppressNewDiagnosticContexts) {
76130                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input);
76131             }
76132             if (ts.isTypeQueryNode(input)) {
76133                 checkEntityNameVisibility(input.exprName, enclosingDeclaration);
76134             }
76135             if (shouldEnterSuppressNewDiagnosticsContextContext) {
76136                 suppressNewDiagnosticContexts = true;
76137             }
76138             if (isProcessedComponent(input)) {
76139                 switch (input.kind) {
76140                     case 216: {
76141                         if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) {
76142                             checkEntityNameVisibility(input.expression, enclosingDeclaration);
76143                         }
76144                         var node = ts.visitEachChild(input, visitDeclarationSubtree, context);
76145                         return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression));
76146                     }
76147                     case 169: {
76148                         checkEntityNameVisibility(input.typeName, enclosingDeclaration);
76149                         var node = ts.visitEachChild(input, visitDeclarationSubtree, context);
76150                         return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments)));
76151                     }
76152                     case 166:
76153                         return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)));
76154                     case 162: {
76155                         var ctor = ts.createSignatureDeclaration(162, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters, 0), undefined);
76156                         ctor.modifiers = ts.createNodeArray(ensureModifiers(input));
76157                         return cleanup(ctor);
76158                     }
76159                     case 161: {
76160                         if (ts.isPrivateIdentifier(input.name)) {
76161                             return cleanup(undefined);
76162                         }
76163                         var sig = ts.createSignatureDeclaration(160, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type));
76164                         sig.name = input.name;
76165                         sig.modifiers = ts.createNodeArray(ensureModifiers(input));
76166                         sig.questionToken = input.questionToken;
76167                         return cleanup(sig);
76168                     }
76169                     case 163: {
76170                         if (ts.isPrivateIdentifier(input.name)) {
76171                             return cleanup(undefined);
76172                         }
76173                         var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input));
76174                         return cleanup(ts.updateGetAccessor(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8)), ensureType(input, accessorType), undefined));
76175                     }
76176                     case 164: {
76177                         if (ts.isPrivateIdentifier(input.name)) {
76178                             return cleanup(undefined);
76179                         }
76180                         return cleanup(ts.updateSetAccessor(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8)), undefined));
76181                     }
76182                     case 159:
76183                         if (ts.isPrivateIdentifier(input.name)) {
76184                             return cleanup(undefined);
76185                         }
76186                         return cleanup(ts.updateProperty(input, undefined, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input)));
76187                     case 158:
76188                         if (ts.isPrivateIdentifier(input.name)) {
76189                             return cleanup(undefined);
76190                         }
76191                         return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input)));
76192                     case 160: {
76193                         if (ts.isPrivateIdentifier(input.name)) {
76194                             return cleanup(undefined);
76195                         }
76196                         return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken));
76197                     }
76198                     case 165: {
76199                         return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)));
76200                     }
76201                     case 167: {
76202                         return cleanup(ts.updateIndexSignature(input, undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(125)));
76203                     }
76204                     case 242: {
76205                         if (ts.isBindingPattern(input.name)) {
76206                             return recreateBindingPattern(input.name);
76207                         }
76208                         shouldEnterSuppressNewDiagnosticsContextContext = true;
76209                         suppressNewDiagnosticContexts = true;
76210                         return cleanup(ts.updateTypeScriptVariableDeclaration(input, input.name, undefined, ensureType(input, input.type), ensureNoInitializer(input)));
76211                     }
76212                     case 155: {
76213                         if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) {
76214                             return cleanup(ts.updateTypeParameterDeclaration(input, input.name, undefined, undefined));
76215                         }
76216                         return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context));
76217                     }
76218                     case 180: {
76219                         var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree);
76220                         var extendsType = ts.visitNode(input.extendsType, visitDeclarationSubtree);
76221                         var oldEnclosingDecl = enclosingDeclaration;
76222                         enclosingDeclaration = input.trueType;
76223                         var trueType = ts.visitNode(input.trueType, visitDeclarationSubtree);
76224                         enclosingDeclaration = oldEnclosingDecl;
76225                         var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree);
76226                         return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType));
76227                     }
76228                     case 170: {
76229                         return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree)));
76230                     }
76231                     case 171: {
76232                         return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree)));
76233                     }
76234                     case 188: {
76235                         if (!ts.isLiteralImportTypeNode(input))
76236                             return cleanup(input);
76237                         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));
76238                     }
76239                     default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.SyntaxKind[input.kind]);
76240                 }
76241             }
76242             return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context));
76243             function cleanup(returnValue) {
76244                 if (returnValue && canProduceDiagnostic && ts.hasDynamicName(input)) {
76245                     checkName(input);
76246                 }
76247                 if (isEnclosingDeclaration(input)) {
76248                     enclosingDeclaration = previousEnclosingDeclaration;
76249                 }
76250                 if (canProduceDiagnostic && !suppressNewDiagnosticContexts) {
76251                     getSymbolAccessibilityDiagnostic = oldDiag;
76252                 }
76253                 if (shouldEnterSuppressNewDiagnosticsContextContext) {
76254                     suppressNewDiagnosticContexts = oldWithinObjectLiteralType;
76255                 }
76256                 if (returnValue === input) {
76257                     return returnValue;
76258                 }
76259                 return returnValue && ts.setOriginalNode(preserveJsDoc(returnValue, input), input);
76260             }
76261         }
76262         function isPrivateMethodTypeParameter(node) {
76263             return node.parent.kind === 161 && ts.hasModifier(node.parent, 8);
76264         }
76265         function visitDeclarationStatements(input) {
76266             if (!isPreservedDeclarationStatement(input)) {
76267                 return;
76268             }
76269             if (shouldStripInternal(input))
76270                 return;
76271             switch (input.kind) {
76272                 case 260: {
76273                     if (ts.isSourceFile(input.parent)) {
76274                         resultHasExternalModuleIndicator = true;
76275                     }
76276                     resultHasScopeMarker = true;
76277                     return ts.updateExportDeclaration(input, undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier), input.isTypeOnly);
76278                 }
76279                 case 259: {
76280                     if (ts.isSourceFile(input.parent)) {
76281                         resultHasExternalModuleIndicator = true;
76282                     }
76283                     resultHasScopeMarker = true;
76284                     if (input.expression.kind === 75) {
76285                         return input;
76286                     }
76287                     else {
76288                         var newId = ts.createOptimisticUniqueName("_default");
76289                         getSymbolAccessibilityDiagnostic = function () { return ({
76290                             diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0,
76291                             errorNode: input
76292                         }); };
76293                         var varDecl = ts.createVariableDeclaration(newId, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), undefined);
76294                         var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(130)] : [], ts.createVariableDeclarationList([varDecl], 2));
76295                         return [statement, ts.updateExportAssignment(input, input.decorators, input.modifiers, newId)];
76296                     }
76297                 }
76298             }
76299             var result = transformTopLevelDeclaration(input);
76300             lateStatementReplacementMap.set("" + ts.getOriginalNodeId(input), result);
76301             return input;
76302         }
76303         function stripExportModifiers(statement) {
76304             if (ts.isImportEqualsDeclaration(statement) || ts.hasModifier(statement, 512)) {
76305                 return statement;
76306             }
76307             var clone = ts.getMutableClone(statement);
76308             var modifiers = ts.createModifiersFromModifierFlags(ts.getModifierFlags(statement) & (3071 ^ 1));
76309             clone.modifiers = modifiers.length ? ts.createNodeArray(modifiers) : undefined;
76310             return clone;
76311         }
76312         function transformTopLevelDeclaration(input) {
76313             if (shouldStripInternal(input))
76314                 return;
76315             switch (input.kind) {
76316                 case 253: {
76317                     return transformImportEqualsDeclaration(input);
76318                 }
76319                 case 254: {
76320                     return transformImportDeclaration(input);
76321                 }
76322             }
76323             if (ts.isDeclaration(input) && isDeclarationAndNotVisible(input))
76324                 return;
76325             if (ts.isFunctionLike(input) && resolver.isImplementationOfOverload(input))
76326                 return;
76327             var previousEnclosingDeclaration;
76328             if (isEnclosingDeclaration(input)) {
76329                 previousEnclosingDeclaration = enclosingDeclaration;
76330                 enclosingDeclaration = input;
76331             }
76332             var canProdiceDiagnostic = ts.canProduceDiagnostics(input);
76333             var oldDiag = getSymbolAccessibilityDiagnostic;
76334             if (canProdiceDiagnostic) {
76335                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input);
76336             }
76337             var previousNeedsDeclare = needsDeclare;
76338             switch (input.kind) {
76339                 case 247:
76340                     return cleanup(ts.updateTypeAliasDeclaration(input, undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode)));
76341                 case 246: {
76342                     return cleanup(ts.updateInterfaceDeclaration(input, undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree)));
76343                 }
76344                 case 244: {
76345                     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));
76346                     if (clean && resolver.isExpandoFunctionDeclaration(input)) {
76347                         var props = resolver.getPropertiesOfContainerFunction(input);
76348                         var fakespace_1 = ts.createModuleDeclaration(undefined, undefined, clean.name || ts.createIdentifier("_default"), ts.createModuleBlock([]), 16);
76349                         fakespace_1.flags ^= 8;
76350                         fakespace_1.parent = enclosingDeclaration;
76351                         fakespace_1.locals = ts.createSymbolTable(props);
76352                         fakespace_1.symbol = props[0].parent;
76353                         var declarations = ts.mapDefined(props, function (p) {
76354                             if (!ts.isPropertyAccessExpression(p.valueDeclaration)) {
76355                                 return undefined;
76356                             }
76357                             getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration);
76358                             var type = resolver.createTypeOfDeclaration(p.valueDeclaration, fakespace_1, declarationEmitNodeBuilderFlags, symbolTracker);
76359                             getSymbolAccessibilityDiagnostic = oldDiag;
76360                             var varDecl = ts.createVariableDeclaration(ts.unescapeLeadingUnderscores(p.escapedName), type, undefined);
76361                             return ts.createVariableStatement(undefined, ts.createVariableDeclarationList([varDecl]));
76362                         });
76363                         var namespaceDecl = ts.createModuleDeclaration(undefined, ensureModifiers(input), input.name, ts.createModuleBlock(declarations), 16);
76364                         if (!ts.hasModifier(clean, 512)) {
76365                             return [clean, namespaceDecl];
76366                         }
76367                         var modifiers = ts.createModifiersFromModifierFlags((ts.getModifierFlags(clean) & ~513) | 2);
76368                         var cleanDeclaration = ts.updateFunctionDeclaration(clean, undefined, modifiers, undefined, clean.name, clean.typeParameters, clean.parameters, clean.type, undefined);
76369                         var namespaceDeclaration = ts.updateModuleDeclaration(namespaceDecl, undefined, modifiers, namespaceDecl.name, namespaceDecl.body);
76370                         var exportDefaultDeclaration = ts.createExportAssignment(undefined, undefined, false, namespaceDecl.name);
76371                         if (ts.isSourceFile(input.parent)) {
76372                             resultHasExternalModuleIndicator = true;
76373                         }
76374                         resultHasScopeMarker = true;
76375                         return [cleanDeclaration, namespaceDeclaration, exportDefaultDeclaration];
76376                     }
76377                     else {
76378                         return clean;
76379                     }
76380                 }
76381                 case 249: {
76382                     needsDeclare = false;
76383                     var inner = input.body;
76384                     if (inner && inner.kind === 250) {
76385                         var oldNeedsScopeFix = needsScopeFixMarker;
76386                         var oldHasScopeFix = resultHasScopeMarker;
76387                         resultHasScopeMarker = false;
76388                         needsScopeFixMarker = false;
76389                         var statements = ts.visitNodes(inner.statements, visitDeclarationStatements);
76390                         var lateStatements = transformAndReplaceLatePaintedStatements(statements);
76391                         if (input.flags & 8388608) {
76392                             needsScopeFixMarker = false;
76393                         }
76394                         if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) {
76395                             if (needsScopeFixMarker) {
76396                                 lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [ts.createEmptyExports()]));
76397                             }
76398                             else {
76399                                 lateStatements = ts.visitNodes(lateStatements, stripExportModifiers);
76400                             }
76401                         }
76402                         var body = ts.updateModuleBlock(inner, lateStatements);
76403                         needsDeclare = previousNeedsDeclare;
76404                         needsScopeFixMarker = oldNeedsScopeFix;
76405                         resultHasScopeMarker = oldHasScopeFix;
76406                         var mods = ensureModifiers(input);
76407                         return cleanup(ts.updateModuleDeclaration(input, undefined, mods, ts.isExternalModuleAugmentation(input) ? rewriteModuleSpecifier(input, input.name) : input.name, body));
76408                     }
76409                     else {
76410                         needsDeclare = previousNeedsDeclare;
76411                         var mods = ensureModifiers(input);
76412                         needsDeclare = false;
76413                         ts.visitNode(inner, visitDeclarationStatements);
76414                         var id = "" + ts.getOriginalNodeId(inner);
76415                         var body = lateStatementReplacementMap.get(id);
76416                         lateStatementReplacementMap.delete(id);
76417                         return cleanup(ts.updateModuleDeclaration(input, undefined, mods, input.name, body));
76418                     }
76419                 }
76420                 case 245: {
76421                     var modifiers = ts.createNodeArray(ensureModifiers(input));
76422                     var typeParameters = ensureTypeParams(input, input.typeParameters);
76423                     var ctor = ts.getFirstConstructorWithBody(input);
76424                     var parameterProperties = void 0;
76425                     if (ctor) {
76426                         var oldDiag_1 = getSymbolAccessibilityDiagnostic;
76427                         parameterProperties = ts.compact(ts.flatMap(ctor.parameters, function (param) {
76428                             if (!ts.hasModifier(param, 92) || shouldStripInternal(param))
76429                                 return;
76430                             getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param);
76431                             if (param.name.kind === 75) {
76432                                 return preserveJsDoc(ts.createProperty(undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param);
76433                             }
76434                             else {
76435                                 return walkBindingPattern(param.name);
76436                             }
76437                             function walkBindingPattern(pattern) {
76438                                 var elems;
76439                                 for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
76440                                     var elem = _a[_i];
76441                                     if (ts.isOmittedExpression(elem))
76442                                         continue;
76443                                     if (ts.isBindingPattern(elem.name)) {
76444                                         elems = ts.concatenate(elems, walkBindingPattern(elem.name));
76445                                     }
76446                                     elems = elems || [];
76447                                     elems.push(ts.createProperty(undefined, ensureModifiers(param), elem.name, undefined, ensureType(elem, undefined), undefined));
76448                                 }
76449                                 return elems;
76450                             }
76451                         }));
76452                         getSymbolAccessibilityDiagnostic = oldDiag_1;
76453                     }
76454                     var hasPrivateIdentifier = ts.some(input.members, function (member) { return !!member.name && ts.isPrivateIdentifier(member.name); });
76455                     var privateIdentifier = hasPrivateIdentifier ? [
76456                         ts.createProperty(undefined, undefined, ts.createPrivateIdentifier("#private"), undefined, undefined, undefined)
76457                     ] : undefined;
76458                     var memberNodes = ts.concatenate(ts.concatenate(privateIdentifier, parameterProperties), ts.visitNodes(input.members, visitDeclarationSubtree));
76459                     var members = ts.createNodeArray(memberNodes);
76460                     var extendsClause_1 = ts.getEffectiveBaseTypeNode(input);
76461                     if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 100) {
76462                         var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default";
76463                         var newId_1 = ts.createOptimisticUniqueName(oldId + "_base");
76464                         getSymbolAccessibilityDiagnostic = function () { return ({
76465                             diagnosticMessage: ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1,
76466                             errorNode: extendsClause_1,
76467                             typeName: input.name
76468                         }); };
76469                         var varDecl = ts.createVariableDeclaration(newId_1, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), undefined);
76470                         var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(130)] : [], ts.createVariableDeclarationList([varDecl], 2));
76471                         var heritageClauses = ts.createNodeArray(ts.map(input.heritageClauses, function (clause) {
76472                             if (clause.token === 90) {
76473                                 var oldDiag_2 = getSymbolAccessibilityDiagnostic;
76474                                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]);
76475                                 var newClause = ts.updateHeritageClause(clause, ts.map(clause.types, function (t) { return ts.updateExpressionWithTypeArguments(t, ts.visitNodes(t.typeArguments, visitDeclarationSubtree), newId_1); }));
76476                                 getSymbolAccessibilityDiagnostic = oldDiag_2;
76477                                 return newClause;
76478                             }
76479                             return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 100; })), visitDeclarationSubtree));
76480                         }));
76481                         return [statement, cleanup(ts.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members))];
76482                     }
76483                     else {
76484                         var heritageClauses = transformHeritageClauses(input.heritageClauses);
76485                         return cleanup(ts.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members));
76486                     }
76487                 }
76488                 case 225: {
76489                     return cleanup(transformVariableStatement(input));
76490                 }
76491                 case 248: {
76492                     return cleanup(ts.updateEnumDeclaration(input, undefined, ts.createNodeArray(ensureModifiers(input)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) {
76493                         if (shouldStripInternal(m))
76494                             return;
76495                         var constValue = resolver.getConstantValue(m);
76496                         return preserveJsDoc(ts.updateEnumMember(m, m.name, constValue !== undefined ? ts.createLiteral(constValue) : undefined), m);
76497                     }))));
76498                 }
76499             }
76500             return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.SyntaxKind[input.kind]);
76501             function cleanup(node) {
76502                 if (isEnclosingDeclaration(input)) {
76503                     enclosingDeclaration = previousEnclosingDeclaration;
76504                 }
76505                 if (canProdiceDiagnostic) {
76506                     getSymbolAccessibilityDiagnostic = oldDiag;
76507                 }
76508                 if (input.kind === 249) {
76509                     needsDeclare = previousNeedsDeclare;
76510                 }
76511                 if (node === input) {
76512                     return node;
76513                 }
76514                 return node && ts.setOriginalNode(preserveJsDoc(node, input), input);
76515             }
76516         }
76517         function transformVariableStatement(input) {
76518             if (!ts.forEach(input.declarationList.declarations, getBindingNameVisible))
76519                 return;
76520             var nodes = ts.visitNodes(input.declarationList.declarations, visitDeclarationSubtree);
76521             if (!ts.length(nodes))
76522                 return;
76523             return ts.updateVariableStatement(input, ts.createNodeArray(ensureModifiers(input)), ts.updateVariableDeclarationList(input.declarationList, nodes));
76524         }
76525         function recreateBindingPattern(d) {
76526             return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); }));
76527         }
76528         function recreateBindingElement(e) {
76529             if (e.kind === 215) {
76530                 return;
76531             }
76532             if (e.name) {
76533                 if (!getBindingNameVisible(e))
76534                     return;
76535                 if (ts.isBindingPattern(e.name)) {
76536                     return recreateBindingPattern(e.name);
76537                 }
76538                 else {
76539                     return ts.createVariableDeclaration(e.name, ensureType(e, undefined), undefined);
76540                 }
76541             }
76542         }
76543         function checkName(node) {
76544             var oldDiag;
76545             if (!suppressNewDiagnosticContexts) {
76546                 oldDiag = getSymbolAccessibilityDiagnostic;
76547                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNodeName(node);
76548             }
76549             errorNameNode = node.name;
76550             ts.Debug.assert(resolver.isLateBound(ts.getParseTreeNode(node)));
76551             var decl = node;
76552             var entityName = decl.name.expression;
76553             checkEntityNameVisibility(entityName, enclosingDeclaration);
76554             if (!suppressNewDiagnosticContexts) {
76555                 getSymbolAccessibilityDiagnostic = oldDiag;
76556             }
76557             errorNameNode = undefined;
76558         }
76559         function shouldStripInternal(node) {
76560             return !!stripInternal && !!node && isInternalDeclaration(node, currentSourceFile);
76561         }
76562         function isScopeMarker(node) {
76563             return ts.isExportAssignment(node) || ts.isExportDeclaration(node);
76564         }
76565         function hasScopeMarker(statements) {
76566             return ts.some(statements, isScopeMarker);
76567         }
76568         function ensureModifiers(node) {
76569             var currentFlags = ts.getModifierFlags(node);
76570             var newFlags = ensureModifierFlags(node);
76571             if (currentFlags === newFlags) {
76572                 return node.modifiers;
76573             }
76574             return ts.createModifiersFromModifierFlags(newFlags);
76575         }
76576         function ensureModifierFlags(node) {
76577             var mask = 3071 ^ (4 | 256);
76578             var additions = (needsDeclare && !isAlwaysType(node)) ? 2 : 0;
76579             var parentIsFile = node.parent.kind === 290;
76580             if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) {
76581                 mask ^= 2;
76582                 additions = 0;
76583             }
76584             return maskModifierFlags(node, mask, additions);
76585         }
76586         function getTypeAnnotationFromAllAccessorDeclarations(node, accessors) {
76587             var accessorType = getTypeAnnotationFromAccessor(node);
76588             if (!accessorType && node !== accessors.firstAccessor) {
76589                 accessorType = getTypeAnnotationFromAccessor(accessors.firstAccessor);
76590                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.firstAccessor);
76591             }
76592             if (!accessorType && accessors.secondAccessor && node !== accessors.secondAccessor) {
76593                 accessorType = getTypeAnnotationFromAccessor(accessors.secondAccessor);
76594                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.secondAccessor);
76595             }
76596             return accessorType;
76597         }
76598         function transformHeritageClauses(nodes) {
76599             return ts.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) {
76600                 return ts.isEntityNameExpression(t.expression) || (clause.token === 90 && t.expression.kind === 100);
76601             })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; }));
76602         }
76603     }
76604     ts.transformDeclarations = transformDeclarations;
76605     function isAlwaysType(node) {
76606         if (node.kind === 246) {
76607             return true;
76608         }
76609         return false;
76610     }
76611     function maskModifiers(node, modifierMask, modifierAdditions) {
76612         return ts.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions));
76613     }
76614     function maskModifierFlags(node, modifierMask, modifierAdditions) {
76615         if (modifierMask === void 0) { modifierMask = 3071 ^ 4; }
76616         if (modifierAdditions === void 0) { modifierAdditions = 0; }
76617         var flags = (ts.getModifierFlags(node) & modifierMask) | modifierAdditions;
76618         if (flags & 512 && !(flags & 1)) {
76619             flags ^= 1;
76620         }
76621         if (flags & 512 && flags & 2) {
76622             flags ^= 2;
76623         }
76624         return flags;
76625     }
76626     function getTypeAnnotationFromAccessor(accessor) {
76627         if (accessor) {
76628             return accessor.kind === 163
76629                 ? accessor.type
76630                 : accessor.parameters.length > 0
76631                     ? accessor.parameters[0].type
76632                     : undefined;
76633         }
76634     }
76635     function canHaveLiteralInitializer(node) {
76636         switch (node.kind) {
76637             case 159:
76638             case 158:
76639                 return !ts.hasModifier(node, 8);
76640             case 156:
76641             case 242:
76642                 return true;
76643         }
76644         return false;
76645     }
76646     function isPreservedDeclarationStatement(node) {
76647         switch (node.kind) {
76648             case 244:
76649             case 249:
76650             case 253:
76651             case 246:
76652             case 245:
76653             case 247:
76654             case 248:
76655             case 225:
76656             case 254:
76657             case 260:
76658             case 259:
76659                 return true;
76660         }
76661         return false;
76662     }
76663     function isProcessedComponent(node) {
76664         switch (node.kind) {
76665             case 166:
76666             case 162:
76667             case 161:
76668             case 163:
76669             case 164:
76670             case 159:
76671             case 158:
76672             case 160:
76673             case 165:
76674             case 167:
76675             case 242:
76676             case 155:
76677             case 216:
76678             case 169:
76679             case 180:
76680             case 170:
76681             case 171:
76682             case 188:
76683                 return true;
76684         }
76685         return false;
76686     }
76687 })(ts || (ts = {}));
76688 var ts;
76689 (function (ts) {
76690     function getModuleTransformer(moduleKind) {
76691         switch (moduleKind) {
76692             case ts.ModuleKind.ESNext:
76693             case ts.ModuleKind.ES2020:
76694             case ts.ModuleKind.ES2015:
76695                 return ts.transformECMAScriptModule;
76696             case ts.ModuleKind.System:
76697                 return ts.transformSystemModule;
76698             default:
76699                 return ts.transformModule;
76700         }
76701     }
76702     ts.noTransformers = { scriptTransformers: ts.emptyArray, declarationTransformers: ts.emptyArray };
76703     function getTransformers(compilerOptions, customTransformers, emitOnlyDtsFiles) {
76704         return {
76705             scriptTransformers: getScriptTransformers(compilerOptions, customTransformers, emitOnlyDtsFiles),
76706             declarationTransformers: getDeclarationTransformers(customTransformers),
76707         };
76708     }
76709     ts.getTransformers = getTransformers;
76710     function getScriptTransformers(compilerOptions, customTransformers, emitOnlyDtsFiles) {
76711         if (emitOnlyDtsFiles)
76712             return ts.emptyArray;
76713         var jsx = compilerOptions.jsx;
76714         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
76715         var moduleKind = ts.getEmitModuleKind(compilerOptions);
76716         var transformers = [];
76717         ts.addRange(transformers, customTransformers && ts.map(customTransformers.before, wrapScriptTransformerFactory));
76718         transformers.push(ts.transformTypeScript);
76719         transformers.push(ts.transformClassFields);
76720         if (jsx === 2) {
76721             transformers.push(ts.transformJsx);
76722         }
76723         if (languageVersion < 99) {
76724             transformers.push(ts.transformESNext);
76725         }
76726         if (languageVersion < 7) {
76727             transformers.push(ts.transformES2020);
76728         }
76729         if (languageVersion < 6) {
76730             transformers.push(ts.transformES2019);
76731         }
76732         if (languageVersion < 5) {
76733             transformers.push(ts.transformES2018);
76734         }
76735         if (languageVersion < 4) {
76736             transformers.push(ts.transformES2017);
76737         }
76738         if (languageVersion < 3) {
76739             transformers.push(ts.transformES2016);
76740         }
76741         if (languageVersion < 2) {
76742             transformers.push(ts.transformES2015);
76743             transformers.push(ts.transformGenerators);
76744         }
76745         transformers.push(getModuleTransformer(moduleKind));
76746         if (languageVersion < 1) {
76747             transformers.push(ts.transformES5);
76748         }
76749         ts.addRange(transformers, customTransformers && ts.map(customTransformers.after, wrapScriptTransformerFactory));
76750         return transformers;
76751     }
76752     function getDeclarationTransformers(customTransformers) {
76753         var transformers = [];
76754         transformers.push(ts.transformDeclarations);
76755         ts.addRange(transformers, customTransformers && ts.map(customTransformers.afterDeclarations, wrapDeclarationTransformerFactory));
76756         return transformers;
76757     }
76758     function wrapCustomTransformer(transformer) {
76759         return function (node) { return ts.isBundle(node) ? transformer.transformBundle(node) : transformer.transformSourceFile(node); };
76760     }
76761     function wrapCustomTransformerFactory(transformer, handleDefault) {
76762         return function (context) {
76763             var customTransformer = transformer(context);
76764             return typeof customTransformer === "function"
76765                 ? handleDefault(customTransformer)
76766                 : wrapCustomTransformer(customTransformer);
76767         };
76768     }
76769     function wrapScriptTransformerFactory(transformer) {
76770         return wrapCustomTransformerFactory(transformer, ts.chainBundle);
76771     }
76772     function wrapDeclarationTransformerFactory(transformer) {
76773         return wrapCustomTransformerFactory(transformer, ts.identity);
76774     }
76775     function noEmitSubstitution(_hint, node) {
76776         return node;
76777     }
76778     ts.noEmitSubstitution = noEmitSubstitution;
76779     function noEmitNotification(hint, node, callback) {
76780         callback(hint, node);
76781     }
76782     ts.noEmitNotification = noEmitNotification;
76783     function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) {
76784         var enabledSyntaxKindFeatures = new Array(331);
76785         var lexicalEnvironmentVariableDeclarations;
76786         var lexicalEnvironmentFunctionDeclarations;
76787         var lexicalEnvironmentStatements;
76788         var lexicalEnvironmentFlags = 0;
76789         var lexicalEnvironmentVariableDeclarationsStack = [];
76790         var lexicalEnvironmentFunctionDeclarationsStack = [];
76791         var lexicalEnvironmentStatementsStack = [];
76792         var lexicalEnvironmentFlagsStack = [];
76793         var lexicalEnvironmentStackOffset = 0;
76794         var lexicalEnvironmentSuspended = false;
76795         var emitHelpers;
76796         var onSubstituteNode = noEmitSubstitution;
76797         var onEmitNode = noEmitNotification;
76798         var state = 0;
76799         var diagnostics = [];
76800         var context = {
76801             getCompilerOptions: function () { return options; },
76802             getEmitResolver: function () { return resolver; },
76803             getEmitHost: function () { return host; },
76804             startLexicalEnvironment: startLexicalEnvironment,
76805             suspendLexicalEnvironment: suspendLexicalEnvironment,
76806             resumeLexicalEnvironment: resumeLexicalEnvironment,
76807             endLexicalEnvironment: endLexicalEnvironment,
76808             setLexicalEnvironmentFlags: setLexicalEnvironmentFlags,
76809             getLexicalEnvironmentFlags: getLexicalEnvironmentFlags,
76810             hoistVariableDeclaration: hoistVariableDeclaration,
76811             hoistFunctionDeclaration: hoistFunctionDeclaration,
76812             addInitializationStatement: addInitializationStatement,
76813             requestEmitHelper: requestEmitHelper,
76814             readEmitHelpers: readEmitHelpers,
76815             enableSubstitution: enableSubstitution,
76816             enableEmitNotification: enableEmitNotification,
76817             isSubstitutionEnabled: isSubstitutionEnabled,
76818             isEmitNotificationEnabled: isEmitNotificationEnabled,
76819             get onSubstituteNode() { return onSubstituteNode; },
76820             set onSubstituteNode(value) {
76821                 ts.Debug.assert(state < 1, "Cannot modify transformation hooks after initialization has completed.");
76822                 ts.Debug.assert(value !== undefined, "Value must not be 'undefined'");
76823                 onSubstituteNode = value;
76824             },
76825             get onEmitNode() { return onEmitNode; },
76826             set onEmitNode(value) {
76827                 ts.Debug.assert(state < 1, "Cannot modify transformation hooks after initialization has completed.");
76828                 ts.Debug.assert(value !== undefined, "Value must not be 'undefined'");
76829                 onEmitNode = value;
76830             },
76831             addDiagnostic: function (diag) {
76832                 diagnostics.push(diag);
76833             }
76834         };
76835         for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) {
76836             var node = nodes_4[_i];
76837             ts.disposeEmitNodes(ts.getSourceFileOfNode(ts.getParseTreeNode(node)));
76838         }
76839         ts.performance.mark("beforeTransform");
76840         var transformersWithContext = transformers.map(function (t) { return t(context); });
76841         var transformation = function (node) {
76842             for (var _i = 0, transformersWithContext_1 = transformersWithContext; _i < transformersWithContext_1.length; _i++) {
76843                 var transform = transformersWithContext_1[_i];
76844                 node = transform(node);
76845             }
76846             return node;
76847         };
76848         state = 1;
76849         var transformed = ts.map(nodes, allowDtsFiles ? transformation : transformRoot);
76850         state = 2;
76851         ts.performance.mark("afterTransform");
76852         ts.performance.measure("transformTime", "beforeTransform", "afterTransform");
76853         return {
76854             transformed: transformed,
76855             substituteNode: substituteNode,
76856             emitNodeWithNotification: emitNodeWithNotification,
76857             isEmitNotificationEnabled: isEmitNotificationEnabled,
76858             dispose: dispose,
76859             diagnostics: diagnostics
76860         };
76861         function transformRoot(node) {
76862             return node && (!ts.isSourceFile(node) || !node.isDeclarationFile) ? transformation(node) : node;
76863         }
76864         function enableSubstitution(kind) {
76865             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
76866             enabledSyntaxKindFeatures[kind] |= 1;
76867         }
76868         function isSubstitutionEnabled(node) {
76869             return (enabledSyntaxKindFeatures[node.kind] & 1) !== 0
76870                 && (ts.getEmitFlags(node) & 4) === 0;
76871         }
76872         function substituteNode(hint, node) {
76873             ts.Debug.assert(state < 3, "Cannot substitute a node after the result is disposed.");
76874             return node && isSubstitutionEnabled(node) && onSubstituteNode(hint, node) || node;
76875         }
76876         function enableEmitNotification(kind) {
76877             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
76878             enabledSyntaxKindFeatures[kind] |= 2;
76879         }
76880         function isEmitNotificationEnabled(node) {
76881             return (enabledSyntaxKindFeatures[node.kind] & 2) !== 0
76882                 || (ts.getEmitFlags(node) & 2) !== 0;
76883         }
76884         function emitNodeWithNotification(hint, node, emitCallback) {
76885             ts.Debug.assert(state < 3, "Cannot invoke TransformationResult callbacks after the result is disposed.");
76886             if (node) {
76887                 if (isEmitNotificationEnabled(node)) {
76888                     onEmitNode(hint, node, emitCallback);
76889                 }
76890                 else {
76891                     emitCallback(hint, node);
76892                 }
76893             }
76894         }
76895         function hoistVariableDeclaration(name) {
76896             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76897             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76898             var decl = ts.setEmitFlags(ts.createVariableDeclaration(name), 64);
76899             if (!lexicalEnvironmentVariableDeclarations) {
76900                 lexicalEnvironmentVariableDeclarations = [decl];
76901             }
76902             else {
76903                 lexicalEnvironmentVariableDeclarations.push(decl);
76904             }
76905             if (lexicalEnvironmentFlags & 1) {
76906                 lexicalEnvironmentFlags |= 2;
76907             }
76908         }
76909         function hoistFunctionDeclaration(func) {
76910             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76911             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76912             ts.setEmitFlags(func, 1048576);
76913             if (!lexicalEnvironmentFunctionDeclarations) {
76914                 lexicalEnvironmentFunctionDeclarations = [func];
76915             }
76916             else {
76917                 lexicalEnvironmentFunctionDeclarations.push(func);
76918             }
76919         }
76920         function addInitializationStatement(node) {
76921             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76922             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76923             ts.setEmitFlags(node, 1048576);
76924             if (!lexicalEnvironmentStatements) {
76925                 lexicalEnvironmentStatements = [node];
76926             }
76927             else {
76928                 lexicalEnvironmentStatements.push(node);
76929             }
76930         }
76931         function startLexicalEnvironment() {
76932             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76933             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76934             ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended.");
76935             lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentVariableDeclarations;
76936             lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFunctionDeclarations;
76937             lexicalEnvironmentStatementsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentStatements;
76938             lexicalEnvironmentFlagsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFlags;
76939             lexicalEnvironmentStackOffset++;
76940             lexicalEnvironmentVariableDeclarations = undefined;
76941             lexicalEnvironmentFunctionDeclarations = undefined;
76942             lexicalEnvironmentStatements = undefined;
76943             lexicalEnvironmentFlags = 0;
76944         }
76945         function suspendLexicalEnvironment() {
76946             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76947             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76948             ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended.");
76949             lexicalEnvironmentSuspended = true;
76950         }
76951         function resumeLexicalEnvironment() {
76952             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76953             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76954             ts.Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended.");
76955             lexicalEnvironmentSuspended = false;
76956         }
76957         function endLexicalEnvironment() {
76958             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
76959             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
76960             ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended.");
76961             var statements;
76962             if (lexicalEnvironmentVariableDeclarations ||
76963                 lexicalEnvironmentFunctionDeclarations ||
76964                 lexicalEnvironmentStatements) {
76965                 if (lexicalEnvironmentFunctionDeclarations) {
76966                     statements = __spreadArrays(lexicalEnvironmentFunctionDeclarations);
76967                 }
76968                 if (lexicalEnvironmentVariableDeclarations) {
76969                     var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList(lexicalEnvironmentVariableDeclarations));
76970                     ts.setEmitFlags(statement, 1048576);
76971                     if (!statements) {
76972                         statements = [statement];
76973                     }
76974                     else {
76975                         statements.push(statement);
76976                     }
76977                 }
76978                 if (lexicalEnvironmentStatements) {
76979                     if (!statements) {
76980                         statements = __spreadArrays(lexicalEnvironmentStatements);
76981                     }
76982                     else {
76983                         statements = __spreadArrays(statements, lexicalEnvironmentStatements);
76984                     }
76985                 }
76986             }
76987             lexicalEnvironmentStackOffset--;
76988             lexicalEnvironmentVariableDeclarations = lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset];
76989             lexicalEnvironmentFunctionDeclarations = lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset];
76990             lexicalEnvironmentStatements = lexicalEnvironmentStatementsStack[lexicalEnvironmentStackOffset];
76991             lexicalEnvironmentFlags = lexicalEnvironmentFlagsStack[lexicalEnvironmentStackOffset];
76992             if (lexicalEnvironmentStackOffset === 0) {
76993                 lexicalEnvironmentVariableDeclarationsStack = [];
76994                 lexicalEnvironmentFunctionDeclarationsStack = [];
76995                 lexicalEnvironmentStatementsStack = [];
76996                 lexicalEnvironmentFlagsStack = [];
76997             }
76998             return statements;
76999         }
77000         function setLexicalEnvironmentFlags(flags, value) {
77001             lexicalEnvironmentFlags = value ?
77002                 lexicalEnvironmentFlags | flags :
77003                 lexicalEnvironmentFlags & ~flags;
77004         }
77005         function getLexicalEnvironmentFlags() {
77006             return lexicalEnvironmentFlags;
77007         }
77008         function requestEmitHelper(helper) {
77009             ts.Debug.assert(state > 0, "Cannot modify the transformation context during initialization.");
77010             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
77011             ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper.");
77012             if (helper.dependencies) {
77013                 for (var _i = 0, _a = helper.dependencies; _i < _a.length; _i++) {
77014                     var h = _a[_i];
77015                     requestEmitHelper(h);
77016                 }
77017             }
77018             emitHelpers = ts.append(emitHelpers, helper);
77019         }
77020         function readEmitHelpers() {
77021             ts.Debug.assert(state > 0, "Cannot modify the transformation context during initialization.");
77022             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
77023             var helpers = emitHelpers;
77024             emitHelpers = undefined;
77025             return helpers;
77026         }
77027         function dispose() {
77028             if (state < 3) {
77029                 for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) {
77030                     var node = nodes_5[_i];
77031                     ts.disposeEmitNodes(ts.getSourceFileOfNode(ts.getParseTreeNode(node)));
77032                 }
77033                 lexicalEnvironmentVariableDeclarations = undefined;
77034                 lexicalEnvironmentVariableDeclarationsStack = undefined;
77035                 lexicalEnvironmentFunctionDeclarations = undefined;
77036                 lexicalEnvironmentFunctionDeclarationsStack = undefined;
77037                 onSubstituteNode = undefined;
77038                 onEmitNode = undefined;
77039                 emitHelpers = undefined;
77040                 state = 3;
77041             }
77042         }
77043     }
77044     ts.transformNodes = transformNodes;
77045 })(ts || (ts = {}));
77046 var ts;
77047 (function (ts) {
77048     var brackets = createBracketsMap();
77049     var syntheticParent = { pos: -1, end: -1 };
77050     function isBuildInfoFile(file) {
77051         return ts.fileExtensionIs(file, ".tsbuildinfo");
77052     }
77053     ts.isBuildInfoFile = isBuildInfoFile;
77054     function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) {
77055         if (forceDtsEmit === void 0) { forceDtsEmit = false; }
77056         var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile, forceDtsEmit);
77057         var options = host.getCompilerOptions();
77058         if (options.outFile || options.out) {
77059             var prepends = host.getPrependNodes();
77060             if (sourceFiles.length || prepends.length) {
77061                 var bundle = ts.createBundle(sourceFiles, prepends);
77062                 var result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle);
77063                 if (result) {
77064                     return result;
77065                 }
77066             }
77067         }
77068         else {
77069             if (!onlyBuildInfo) {
77070                 for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) {
77071                     var sourceFile = sourceFiles_1[_a];
77072                     var result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile);
77073                     if (result) {
77074                         return result;
77075                     }
77076                 }
77077             }
77078             if (includeBuildInfo) {
77079                 var buildInfoPath = getTsBuildInfoEmitOutputFilePath(host.getCompilerOptions());
77080                 if (buildInfoPath)
77081                     return action({ buildInfoPath: buildInfoPath }, undefined);
77082             }
77083         }
77084     }
77085     ts.forEachEmittedFile = forEachEmittedFile;
77086     function getTsBuildInfoEmitOutputFilePath(options) {
77087         var configFile = options.configFilePath;
77088         if (!ts.isIncrementalCompilation(options))
77089             return undefined;
77090         if (options.tsBuildInfoFile)
77091             return options.tsBuildInfoFile;
77092         var outPath = options.outFile || options.out;
77093         var buildInfoExtensionLess;
77094         if (outPath) {
77095             buildInfoExtensionLess = ts.removeFileExtension(outPath);
77096         }
77097         else {
77098             if (!configFile)
77099                 return undefined;
77100             var configFileExtensionLess = ts.removeFileExtension(configFile);
77101             buildInfoExtensionLess = options.outDir ?
77102                 options.rootDir ?
77103                     ts.resolvePath(options.outDir, ts.getRelativePathFromDirectory(options.rootDir, configFileExtensionLess, true)) :
77104                     ts.combinePaths(options.outDir, ts.getBaseFileName(configFileExtensionLess)) :
77105                 configFileExtensionLess;
77106         }
77107         return buildInfoExtensionLess + ".tsbuildinfo";
77108     }
77109     ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath;
77110     function getOutputPathsForBundle(options, forceDtsPaths) {
77111         var outPath = options.outFile || options.out;
77112         var jsFilePath = options.emitDeclarationOnly ? undefined : outPath;
77113         var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options);
77114         var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" : undefined;
77115         var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined;
77116         var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options);
77117         return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath };
77118     }
77119     ts.getOutputPathsForBundle = getOutputPathsForBundle;
77120     function getOutputPathsFor(sourceFile, host, forceDtsPaths) {
77121         var options = host.getCompilerOptions();
77122         if (sourceFile.kind === 291) {
77123             return getOutputPathsForBundle(options, forceDtsPaths);
77124         }
77125         else {
77126             var ownOutputFilePath = ts.getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile, options));
77127             var isJsonFile = ts.isJsonSourceFile(sourceFile);
77128             var isJsonEmittedToSameLocation = isJsonFile &&
77129                 ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0;
77130             var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath;
77131             var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options);
77132             var declarationFilePath = (forceDtsPaths || (ts.getEmitDeclarations(options) && !isJsonFile)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined;
77133             var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined;
77134             return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined };
77135         }
77136     }
77137     ts.getOutputPathsFor = getOutputPathsFor;
77138     function getSourceMapFilePath(jsFilePath, options) {
77139         return (options.sourceMap && !options.inlineSourceMap) ? jsFilePath + ".map" : undefined;
77140     }
77141     function getOutputExtension(sourceFile, options) {
77142         if (ts.isJsonSourceFile(sourceFile)) {
77143             return ".json";
77144         }
77145         if (options.jsx === 1) {
77146             if (ts.isSourceFileJS(sourceFile)) {
77147                 if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) {
77148                     return ".jsx";
77149                 }
77150             }
77151             else if (sourceFile.languageVariant === 1) {
77152                 return ".jsx";
77153             }
77154         }
77155         return ".js";
77156     }
77157     ts.getOutputExtension = getOutputExtension;
77158     function rootDirOfOptions(configFile) {
77159         return configFile.options.rootDir || ts.getDirectoryPath(ts.Debug.checkDefined(configFile.options.configFilePath));
77160     }
77161     function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir) {
77162         return outputDir ?
77163             ts.resolvePath(outputDir, ts.getRelativePathFromDirectory(rootDirOfOptions(configFile), inputFileName, ignoreCase)) :
77164             inputFileName;
77165     }
77166     function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) {
77167         ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts") && !ts.fileExtensionIs(inputFileName, ".json"));
77168         return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts");
77169     }
77170     ts.getOutputDeclarationFileName = getOutputDeclarationFileName;
77171     function getOutputJSFileName(inputFileName, configFile, ignoreCase) {
77172         if (configFile.options.emitDeclarationOnly)
77173             return undefined;
77174         var isJsonFile = ts.fileExtensionIs(inputFileName, ".json");
77175         var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir), isJsonFile ?
77176             ".json" :
77177             ts.fileExtensionIs(inputFileName, ".tsx") && configFile.options.jsx === 1 ?
77178                 ".jsx" :
77179                 ".js");
77180         return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 ?
77181             outputFileName :
77182             undefined;
77183     }
77184     function createAddOutput() {
77185         var outputs;
77186         return { addOutput: addOutput, getOutputs: getOutputs };
77187         function addOutput(path) {
77188             if (path) {
77189                 (outputs || (outputs = [])).push(path);
77190             }
77191         }
77192         function getOutputs() {
77193             return outputs || ts.emptyArray;
77194         }
77195     }
77196     function getSingleOutputFileNames(configFile, addOutput) {
77197         var _a = getOutputPathsForBundle(configFile.options, false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
77198         addOutput(jsFilePath);
77199         addOutput(sourceMapFilePath);
77200         addOutput(declarationFilePath);
77201         addOutput(declarationMapPath);
77202         addOutput(buildInfoPath);
77203     }
77204     function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput) {
77205         if (ts.fileExtensionIs(inputFileName, ".d.ts"))
77206             return;
77207         var js = getOutputJSFileName(inputFileName, configFile, ignoreCase);
77208         addOutput(js);
77209         if (ts.fileExtensionIs(inputFileName, ".json"))
77210             return;
77211         if (js && configFile.options.sourceMap) {
77212             addOutput(js + ".map");
77213         }
77214         if (ts.getEmitDeclarations(configFile.options)) {
77215             var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase);
77216             addOutput(dts);
77217             if (configFile.options.declarationMap) {
77218                 addOutput(dts + ".map");
77219             }
77220         }
77221     }
77222     function getAllProjectOutputs(configFile, ignoreCase) {
77223         var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs;
77224         if (configFile.options.outFile || configFile.options.out) {
77225             getSingleOutputFileNames(configFile, addOutput);
77226         }
77227         else {
77228             for (var _b = 0, _c = configFile.fileNames; _b < _c.length; _b++) {
77229                 var inputFileName = _c[_b];
77230                 getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput);
77231             }
77232             addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options));
77233         }
77234         return getOutputs();
77235     }
77236     ts.getAllProjectOutputs = getAllProjectOutputs;
77237     function getOutputFileNames(commandLine, inputFileName, ignoreCase) {
77238         inputFileName = ts.normalizePath(inputFileName);
77239         ts.Debug.assert(ts.contains(commandLine.fileNames, inputFileName), "Expected fileName to be present in command line");
77240         var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs;
77241         if (commandLine.options.outFile || commandLine.options.out) {
77242             getSingleOutputFileNames(commandLine, addOutput);
77243         }
77244         else {
77245             getOwnOutputFileNames(commandLine, inputFileName, ignoreCase, addOutput);
77246         }
77247         return getOutputs();
77248     }
77249     ts.getOutputFileNames = getOutputFileNames;
77250     function getFirstProjectOutput(configFile, ignoreCase) {
77251         if (configFile.options.outFile || configFile.options.out) {
77252             var jsFilePath = getOutputPathsForBundle(configFile.options, false).jsFilePath;
77253             return ts.Debug.checkDefined(jsFilePath, "project " + configFile.options.configFilePath + " expected to have at least one output");
77254         }
77255         for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) {
77256             var inputFileName = _b[_a];
77257             if (ts.fileExtensionIs(inputFileName, ".d.ts"))
77258                 continue;
77259             var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase);
77260             if (jsFilePath)
77261                 return jsFilePath;
77262             if (ts.fileExtensionIs(inputFileName, ".json"))
77263                 continue;
77264             if (ts.getEmitDeclarations(configFile.options)) {
77265                 return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase);
77266             }
77267         }
77268         var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options);
77269         if (buildInfoPath)
77270             return buildInfoPath;
77271         return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output");
77272     }
77273     ts.getFirstProjectOutput = getFirstProjectOutput;
77274     function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) {
77275         var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers;
77276         var compilerOptions = host.getCompilerOptions();
77277         var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined;
77278         var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined;
77279         var emitterDiagnostics = ts.createDiagnosticCollection();
77280         var newLine = ts.getNewLineCharacter(compilerOptions, function () { return host.getNewLine(); });
77281         var writer = ts.createTextWriter(newLine);
77282         var _b = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _b.enter, exit = _b.exit;
77283         var bundleBuildInfo;
77284         var emitSkipped = false;
77285         var exportedModulesFromDeclarationEmit;
77286         enter();
77287         forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit), forceDtsEmit, onlyBuildInfo, !targetSourceFile);
77288         exit();
77289         return {
77290             emitSkipped: emitSkipped,
77291             diagnostics: emitterDiagnostics.getDiagnostics(),
77292             emittedFiles: emittedFilesList,
77293             sourceMaps: sourceMapDataList,
77294             exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit
77295         };
77296         function emitSourceFileOrBundle(_a, sourceFileOrBundle) {
77297             var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
77298             var buildInfoDirectory;
77299             if (buildInfoPath && sourceFileOrBundle && ts.isBundle(sourceFileOrBundle)) {
77300                 buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
77301                 bundleBuildInfo = {
77302                     commonSourceDirectory: relativeToBuildInfo(host.getCommonSourceDirectory()),
77303                     sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); })
77304                 };
77305             }
77306             emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo);
77307             emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo);
77308             emitBuildInfo(bundleBuildInfo, buildInfoPath);
77309             if (!emitSkipped && emittedFilesList) {
77310                 if (!emitOnlyDtsFiles) {
77311                     if (jsFilePath) {
77312                         emittedFilesList.push(jsFilePath);
77313                     }
77314                     if (sourceMapFilePath) {
77315                         emittedFilesList.push(sourceMapFilePath);
77316                     }
77317                     if (buildInfoPath) {
77318                         emittedFilesList.push(buildInfoPath);
77319                     }
77320                 }
77321                 if (declarationFilePath) {
77322                     emittedFilesList.push(declarationFilePath);
77323                 }
77324                 if (declarationMapPath) {
77325                     emittedFilesList.push(declarationMapPath);
77326                 }
77327             }
77328             function relativeToBuildInfo(path) {
77329                 return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, host.getCanonicalFileName));
77330             }
77331         }
77332         function emitBuildInfo(bundle, buildInfoPath) {
77333             if (!buildInfoPath || targetSourceFile || emitSkipped)
77334                 return;
77335             var program = host.getProgramBuildInfo();
77336             if (host.isEmitBlocked(buildInfoPath) || compilerOptions.noEmit) {
77337                 emitSkipped = true;
77338                 return;
77339             }
77340             var version = ts.version;
77341             ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText({ bundle: bundle, program: program, version: version }), false);
77342         }
77343         function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo) {
77344             if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) {
77345                 return;
77346             }
77347             if ((jsFilePath && host.isEmitBlocked(jsFilePath)) || compilerOptions.noEmit) {
77348                 emitSkipped = true;
77349                 return;
77350             }
77351             var transform = ts.transformNodes(resolver, host, compilerOptions, [sourceFileOrBundle], scriptTransformers, false);
77352             var printerOptions = {
77353                 removeComments: compilerOptions.removeComments,
77354                 newLine: compilerOptions.newLine,
77355                 noEmitHelpers: compilerOptions.noEmitHelpers,
77356                 module: compilerOptions.module,
77357                 target: compilerOptions.target,
77358                 sourceMap: compilerOptions.sourceMap,
77359                 inlineSourceMap: compilerOptions.inlineSourceMap,
77360                 inlineSources: compilerOptions.inlineSources,
77361                 extendedDiagnostics: compilerOptions.extendedDiagnostics,
77362                 writeBundleFileInfo: !!bundleBuildInfo,
77363                 relativeToBuildInfo: relativeToBuildInfo
77364             };
77365             var printer = createPrinter(printerOptions, {
77366                 hasGlobalName: resolver.hasGlobalName,
77367                 onEmitNode: transform.emitNodeWithNotification,
77368                 isEmitNotificationEnabled: transform.isEmitNotificationEnabled,
77369                 substituteNode: transform.substituteNode,
77370             });
77371             ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform");
77372             printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions);
77373             transform.dispose();
77374             if (bundleBuildInfo)
77375                 bundleBuildInfo.js = printer.bundleFileInfo;
77376         }
77377         function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo) {
77378             if (!sourceFileOrBundle)
77379                 return;
77380             if (!declarationFilePath) {
77381                 if (emitOnlyDtsFiles || compilerOptions.emitDeclarationOnly)
77382                     emitSkipped = true;
77383                 return;
77384             }
77385             var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles;
77386             var filesForEmit = forceDtsEmit ? sourceFiles : ts.filter(sourceFiles, ts.isSourceFileNotJson);
77387             var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(filesForEmit, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : filesForEmit;
77388             if (emitOnlyDtsFiles && !ts.getEmitDeclarations(compilerOptions)) {
77389                 filesForEmit.forEach(collectLinkedAliases);
77390             }
77391             var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, declarationTransformers, false);
77392             if (ts.length(declarationTransform.diagnostics)) {
77393                 for (var _a = 0, _b = declarationTransform.diagnostics; _a < _b.length; _a++) {
77394                     var diagnostic = _b[_a];
77395                     emitterDiagnostics.add(diagnostic);
77396                 }
77397             }
77398             var printerOptions = {
77399                 removeComments: compilerOptions.removeComments,
77400                 newLine: compilerOptions.newLine,
77401                 noEmitHelpers: true,
77402                 module: compilerOptions.module,
77403                 target: compilerOptions.target,
77404                 sourceMap: compilerOptions.sourceMap,
77405                 inlineSourceMap: compilerOptions.inlineSourceMap,
77406                 extendedDiagnostics: compilerOptions.extendedDiagnostics,
77407                 onlyPrintJsDocStyle: true,
77408                 writeBundleFileInfo: !!bundleBuildInfo,
77409                 recordInternalSection: !!bundleBuildInfo,
77410                 relativeToBuildInfo: relativeToBuildInfo
77411             };
77412             var declarationPrinter = createPrinter(printerOptions, {
77413                 hasGlobalName: resolver.hasGlobalName,
77414                 onEmitNode: declarationTransform.emitNodeWithNotification,
77415                 isEmitNotificationEnabled: declarationTransform.isEmitNotificationEnabled,
77416                 substituteNode: declarationTransform.substituteNode,
77417             });
77418             var declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit;
77419             emitSkipped = emitSkipped || declBlocked;
77420             if (!declBlocked || forceDtsEmit) {
77421                 ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform");
77422                 printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, {
77423                     sourceMap: compilerOptions.declarationMap,
77424                     sourceRoot: compilerOptions.sourceRoot,
77425                     mapRoot: compilerOptions.mapRoot,
77426                     extendedDiagnostics: compilerOptions.extendedDiagnostics,
77427                 });
77428                 if (forceDtsEmit && declarationTransform.transformed[0].kind === 290) {
77429                     var sourceFile = declarationTransform.transformed[0];
77430                     exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit;
77431                 }
77432             }
77433             declarationTransform.dispose();
77434             if (bundleBuildInfo)
77435                 bundleBuildInfo.dts = declarationPrinter.bundleFileInfo;
77436         }
77437         function collectLinkedAliases(node) {
77438             if (ts.isExportAssignment(node)) {
77439                 if (node.expression.kind === 75) {
77440                     resolver.collectLinkedAliases(node.expression, true);
77441                 }
77442                 return;
77443             }
77444             else if (ts.isExportSpecifier(node)) {
77445                 resolver.collectLinkedAliases(node.propertyName || node.name, true);
77446                 return;
77447             }
77448             ts.forEachChild(node, collectLinkedAliases);
77449         }
77450         function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) {
77451             var bundle = sourceFileOrBundle.kind === 291 ? sourceFileOrBundle : undefined;
77452             var sourceFile = sourceFileOrBundle.kind === 290 ? sourceFileOrBundle : undefined;
77453             var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile];
77454             var sourceMapGenerator;
77455             if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) {
77456                 sourceMapGenerator = ts.createSourceMapGenerator(host, ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)), getSourceRoot(mapOptions), getSourceMapDirectory(mapOptions, jsFilePath, sourceFile), mapOptions);
77457             }
77458             if (bundle) {
77459                 printer.writeBundle(bundle, writer, sourceMapGenerator);
77460             }
77461             else {
77462                 printer.writeFile(sourceFile, writer, sourceMapGenerator);
77463             }
77464             if (sourceMapGenerator) {
77465                 if (sourceMapDataList) {
77466                     sourceMapDataList.push({
77467                         inputSourceFileNames: sourceMapGenerator.getSources(),
77468                         sourceMap: sourceMapGenerator.toJSON()
77469                     });
77470                 }
77471                 var sourceMappingURL = getSourceMappingURL(mapOptions, sourceMapGenerator, jsFilePath, sourceMapFilePath, sourceFile);
77472                 if (sourceMappingURL) {
77473                     if (!writer.isAtStartOfLine())
77474                         writer.rawWrite(newLine);
77475                     writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL);
77476                 }
77477                 if (sourceMapFilePath) {
77478                     var sourceMap = sourceMapGenerator.toString();
77479                     ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, false, sourceFiles);
77480                 }
77481             }
77482             else {
77483                 writer.writeLine();
77484             }
77485             ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles);
77486             writer.clear();
77487         }
77488         function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) {
77489             return (mapOptions.sourceMap || mapOptions.inlineSourceMap)
77490                 && (sourceFileOrBundle.kind !== 290 || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json"));
77491         }
77492         function getSourceRoot(mapOptions) {
77493             var sourceRoot = ts.normalizeSlashes(mapOptions.sourceRoot || "");
77494             return sourceRoot ? ts.ensureTrailingDirectorySeparator(sourceRoot) : sourceRoot;
77495         }
77496         function getSourceMapDirectory(mapOptions, filePath, sourceFile) {
77497             if (mapOptions.sourceRoot)
77498                 return host.getCommonSourceDirectory();
77499             if (mapOptions.mapRoot) {
77500                 var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot);
77501                 if (sourceFile) {
77502                     sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir));
77503                 }
77504                 if (ts.getRootLength(sourceMapDir) === 0) {
77505                     sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir);
77506                 }
77507                 return sourceMapDir;
77508             }
77509             return ts.getDirectoryPath(ts.normalizePath(filePath));
77510         }
77511         function getSourceMappingURL(mapOptions, sourceMapGenerator, filePath, sourceMapFilePath, sourceFile) {
77512             if (mapOptions.inlineSourceMap) {
77513                 var sourceMapText = sourceMapGenerator.toString();
77514                 var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText);
77515                 return "data:application/json;base64," + base64SourceMapText;
77516             }
77517             var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.checkDefined(sourceMapFilePath)));
77518             if (mapOptions.mapRoot) {
77519                 var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot);
77520                 if (sourceFile) {
77521                     sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir));
77522                 }
77523                 if (ts.getRootLength(sourceMapDir) === 0) {
77524                     sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir);
77525                     return ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(filePath)), ts.combinePaths(sourceMapDir, sourceMapFile), host.getCurrentDirectory(), host.getCanonicalFileName, true);
77526                 }
77527                 else {
77528                     return ts.combinePaths(sourceMapDir, sourceMapFile);
77529                 }
77530             }
77531             return sourceMapFile;
77532         }
77533     }
77534     ts.emitFiles = emitFiles;
77535     function getBuildInfoText(buildInfo) {
77536         return JSON.stringify(buildInfo, undefined, 2);
77537     }
77538     ts.getBuildInfoText = getBuildInfoText;
77539     function getBuildInfo(buildInfoText) {
77540         return JSON.parse(buildInfoText);
77541     }
77542     ts.getBuildInfo = getBuildInfo;
77543     ts.notImplementedResolver = {
77544         hasGlobalName: ts.notImplemented,
77545         getReferencedExportContainer: ts.notImplemented,
77546         getReferencedImportDeclaration: ts.notImplemented,
77547         getReferencedDeclarationWithCollidingName: ts.notImplemented,
77548         isDeclarationWithCollidingName: ts.notImplemented,
77549         isValueAliasDeclaration: ts.notImplemented,
77550         isReferencedAliasDeclaration: ts.notImplemented,
77551         isTopLevelValueImportEqualsWithEntityName: ts.notImplemented,
77552         getNodeCheckFlags: ts.notImplemented,
77553         isDeclarationVisible: ts.notImplemented,
77554         isLateBound: function (_node) { return false; },
77555         collectLinkedAliases: ts.notImplemented,
77556         isImplementationOfOverload: ts.notImplemented,
77557         isRequiredInitializedParameter: ts.notImplemented,
77558         isOptionalUninitializedParameterProperty: ts.notImplemented,
77559         isExpandoFunctionDeclaration: ts.notImplemented,
77560         getPropertiesOfContainerFunction: ts.notImplemented,
77561         createTypeOfDeclaration: ts.notImplemented,
77562         createReturnTypeOfSignatureDeclaration: ts.notImplemented,
77563         createTypeOfExpression: ts.notImplemented,
77564         createLiteralConstValue: ts.notImplemented,
77565         isSymbolAccessible: ts.notImplemented,
77566         isEntityNameVisible: ts.notImplemented,
77567         getConstantValue: ts.notImplemented,
77568         getReferencedValueDeclaration: ts.notImplemented,
77569         getTypeReferenceSerializationKind: ts.notImplemented,
77570         isOptionalParameter: ts.notImplemented,
77571         moduleExportsSomeValue: ts.notImplemented,
77572         isArgumentsLocalBinding: ts.notImplemented,
77573         getExternalModuleFileFromDeclaration: ts.notImplemented,
77574         getTypeReferenceDirectivesForEntityName: ts.notImplemented,
77575         getTypeReferenceDirectivesForSymbol: ts.notImplemented,
77576         isLiteralConstDeclaration: ts.notImplemented,
77577         getJsxFactoryEntity: ts.notImplemented,
77578         getAllAccessorDeclarations: ts.notImplemented,
77579         getSymbolOfExternalModuleSpecifier: ts.notImplemented,
77580         isBindingCapturedByNode: ts.notImplemented,
77581         getDeclarationStatementsForSourceFile: ts.notImplemented,
77582         isImportRequiredByAugmentation: ts.notImplemented,
77583     };
77584     function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) {
77585         var sourceFiles = bundle.sourceFiles.map(function (fileName) {
77586             var sourceFile = ts.createNode(290, 0, 0);
77587             sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames());
77588             sourceFile.text = "";
77589             sourceFile.statements = ts.createNodeArray();
77590             return sourceFile;
77591         });
77592         var jsBundle = ts.Debug.checkDefined(bundle.js);
77593         ts.forEach(jsBundle.sources && jsBundle.sources.prologues, function (prologueInfo) {
77594             var sourceFile = sourceFiles[prologueInfo.file];
77595             sourceFile.text = prologueInfo.text;
77596             sourceFile.end = prologueInfo.text.length;
77597             sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) {
77598                 var statement = ts.createNode(226, directive.pos, directive.end);
77599                 statement.expression = ts.createNode(10, directive.expression.pos, directive.expression.end);
77600                 statement.expression.text = directive.expression.text;
77601                 return statement;
77602             }));
77603         });
77604         return sourceFiles;
77605     }
77606     function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
77607         var _a = getOutputPathsForBundle(config.options, false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
77608         var buildInfoText = host.readFile(ts.Debug.checkDefined(buildInfoPath));
77609         if (!buildInfoText)
77610             return buildInfoPath;
77611         var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
77612         if (!jsFileText)
77613             return jsFilePath;
77614         var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
77615         if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
77616             return sourceMapFilePath || "inline sourcemap decoding";
77617         var declarationText = declarationFilePath && host.readFile(declarationFilePath);
77618         if (declarationFilePath && !declarationText)
77619             return declarationFilePath;
77620         var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
77621         if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
77622             return declarationMapPath || "inline sourcemap decoding";
77623         var buildInfo = getBuildInfo(buildInfoText);
77624         if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts))
77625             return buildInfoPath;
77626         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
77627         var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo, true);
77628         var outputFiles = [];
77629         var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); });
77630         var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host);
77631         var emitHost = {
77632             getPrependNodes: ts.memoize(function () { return __spreadArrays(prependNodes, [ownPrependInput]); }),
77633             getCanonicalFileName: host.getCanonicalFileName,
77634             getCommonSourceDirectory: function () { return ts.getNormalizedAbsolutePath(buildInfo.bundle.commonSourceDirectory, buildInfoDirectory); },
77635             getCompilerOptions: function () { return config.options; },
77636             getCurrentDirectory: function () { return host.getCurrentDirectory(); },
77637             getNewLine: function () { return host.getNewLine(); },
77638             getSourceFile: ts.returnUndefined,
77639             getSourceFileByPath: ts.returnUndefined,
77640             getSourceFiles: function () { return sourceFilesForJsEmit; },
77641             getLibFileFromReference: ts.notImplemented,
77642             isSourceFileFromExternalLibrary: ts.returnFalse,
77643             getResolvedProjectReferenceToRedirect: ts.returnUndefined,
77644             getProjectReferenceRedirect: ts.returnUndefined,
77645             isSourceOfProjectReferenceRedirect: ts.returnFalse,
77646             writeFile: function (name, text, writeByteOrderMark) {
77647                 switch (name) {
77648                     case jsFilePath:
77649                         if (jsFileText === text)
77650                             return;
77651                         break;
77652                     case sourceMapFilePath:
77653                         if (sourceMapText === text)
77654                             return;
77655                         break;
77656                     case buildInfoPath:
77657                         var newBuildInfo = getBuildInfo(text);
77658                         newBuildInfo.program = buildInfo.program;
77659                         var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
77660                         newBuildInfo.bundle.js.sources = js.sources;
77661                         if (dts) {
77662                             newBuildInfo.bundle.dts.sources = dts.sources;
77663                         }
77664                         newBuildInfo.bundle.sourceFiles = sourceFiles;
77665                         outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark });
77666                         return;
77667                     case declarationFilePath:
77668                         if (declarationText === text)
77669                             return;
77670                         break;
77671                     case declarationMapPath:
77672                         if (declarationMapText === text)
77673                             return;
77674                         break;
77675                     default:
77676                         ts.Debug.fail("Unexpected path: " + name);
77677                 }
77678                 outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark });
77679             },
77680             isEmitBlocked: ts.returnFalse,
77681             readFile: function (f) { return host.readFile(f); },
77682             fileExists: function (f) { return host.fileExists(f); },
77683             useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
77684             getProgramBuildInfo: ts.returnUndefined,
77685             getSourceFileFromReference: ts.returnUndefined,
77686             redirectTargetsMap: ts.createMultiMap()
77687         };
77688         emitFiles(ts.notImplementedResolver, emitHost, undefined, ts.getTransformers(config.options, customTransformers));
77689         return outputFiles;
77690     }
77691     ts.emitUsingBuildInfo = emitUsingBuildInfo;
77692     function createPrinter(printerOptions, handlers) {
77693         if (printerOptions === void 0) { printerOptions = {}; }
77694         if (handlers === void 0) { handlers = {}; }
77695         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;
77696         var extendedDiagnostics = !!printerOptions.extendedDiagnostics;
77697         var newLine = ts.getNewLineCharacter(printerOptions);
77698         var moduleKind = ts.getEmitModuleKind(printerOptions);
77699         var bundledHelpers = ts.createMap();
77700         var currentSourceFile;
77701         var nodeIdToGeneratedName;
77702         var autoGeneratedIdToGeneratedName;
77703         var generatedNames;
77704         var tempFlagsStack;
77705         var tempFlags;
77706         var reservedNamesStack;
77707         var reservedNames;
77708         var preserveSourceNewlines = printerOptions.preserveSourceNewlines;
77709         var writer;
77710         var ownWriter;
77711         var write = writeBase;
77712         var isOwnFileEmit;
77713         var bundleFileInfo = printerOptions.writeBundleFileInfo ? { sections: [] } : undefined;
77714         var relativeToBuildInfo = bundleFileInfo ? ts.Debug.checkDefined(printerOptions.relativeToBuildInfo) : undefined;
77715         var recordInternalSection = printerOptions.recordInternalSection;
77716         var sourceFileTextPos = 0;
77717         var sourceFileTextKind = "text";
77718         var sourceMapsDisabled = true;
77719         var sourceMapGenerator;
77720         var sourceMapSource;
77721         var sourceMapSourceIndex = -1;
77722         var containerPos = -1;
77723         var containerEnd = -1;
77724         var declarationListContainerEnd = -1;
77725         var currentLineMap;
77726         var detachedCommentsInfo;
77727         var hasWrittenComment = false;
77728         var commentsDisabled = !!printerOptions.removeComments;
77729         var lastNode;
77730         var lastSubstitution;
77731         var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit;
77732         reset();
77733         return {
77734             printNode: printNode,
77735             printList: printList,
77736             printFile: printFile,
77737             printBundle: printBundle,
77738             writeNode: writeNode,
77739             writeList: writeList,
77740             writeFile: writeFile,
77741             writeBundle: writeBundle,
77742             bundleFileInfo: bundleFileInfo
77743         };
77744         function printNode(hint, node, sourceFile) {
77745             switch (hint) {
77746                 case 0:
77747                     ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node.");
77748                     break;
77749                 case 2:
77750                     ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node.");
77751                     break;
77752                 case 1:
77753                     ts.Debug.assert(ts.isExpression(node), "Expected an Expression node.");
77754                     break;
77755             }
77756             switch (node.kind) {
77757                 case 290: return printFile(node);
77758                 case 291: return printBundle(node);
77759                 case 292: return printUnparsedSource(node);
77760             }
77761             writeNode(hint, node, sourceFile, beginPrint());
77762             return endPrint();
77763         }
77764         function printList(format, nodes, sourceFile) {
77765             writeList(format, nodes, sourceFile, beginPrint());
77766             return endPrint();
77767         }
77768         function printBundle(bundle) {
77769             writeBundle(bundle, beginPrint(), undefined);
77770             return endPrint();
77771         }
77772         function printFile(sourceFile) {
77773             writeFile(sourceFile, beginPrint(), undefined);
77774             return endPrint();
77775         }
77776         function printUnparsedSource(unparsed) {
77777             writeUnparsedSource(unparsed, beginPrint());
77778             return endPrint();
77779         }
77780         function writeNode(hint, node, sourceFile, output) {
77781             var previousWriter = writer;
77782             setWriter(output, undefined);
77783             print(hint, node, sourceFile);
77784             reset();
77785             writer = previousWriter;
77786         }
77787         function writeList(format, nodes, sourceFile, output) {
77788             var previousWriter = writer;
77789             setWriter(output, undefined);
77790             if (sourceFile) {
77791                 setSourceFile(sourceFile);
77792             }
77793             emitList(syntheticParent, nodes, format);
77794             reset();
77795             writer = previousWriter;
77796         }
77797         function getTextPosWithWriteLine() {
77798             return writer.getTextPosWithWriteLine ? writer.getTextPosWithWriteLine() : writer.getTextPos();
77799         }
77800         function updateOrPushBundleFileTextLike(pos, end, kind) {
77801             var last = ts.lastOrUndefined(bundleFileInfo.sections);
77802             if (last && last.kind === kind) {
77803                 last.end = end;
77804             }
77805             else {
77806                 bundleFileInfo.sections.push({ pos: pos, end: end, kind: kind });
77807             }
77808         }
77809         function recordBundleFileInternalSectionStart(node) {
77810             if (recordInternalSection &&
77811                 bundleFileInfo &&
77812                 currentSourceFile &&
77813                 (ts.isDeclaration(node) || ts.isVariableStatement(node)) &&
77814                 ts.isInternalDeclaration(node, currentSourceFile) &&
77815                 sourceFileTextKind !== "internal") {
77816                 var prevSourceFileTextKind = sourceFileTextKind;
77817                 recordBundleFileTextLikeSection(writer.getTextPos());
77818                 sourceFileTextPos = getTextPosWithWriteLine();
77819                 sourceFileTextKind = "internal";
77820                 return prevSourceFileTextKind;
77821             }
77822             return undefined;
77823         }
77824         function recordBundleFileInternalSectionEnd(prevSourceFileTextKind) {
77825             if (prevSourceFileTextKind) {
77826                 recordBundleFileTextLikeSection(writer.getTextPos());
77827                 sourceFileTextPos = getTextPosWithWriteLine();
77828                 sourceFileTextKind = prevSourceFileTextKind;
77829             }
77830         }
77831         function recordBundleFileTextLikeSection(end) {
77832             if (sourceFileTextPos < end) {
77833                 updateOrPushBundleFileTextLike(sourceFileTextPos, end, sourceFileTextKind);
77834                 return true;
77835             }
77836             return false;
77837         }
77838         function writeBundle(bundle, output, sourceMapGenerator) {
77839             var _a;
77840             isOwnFileEmit = false;
77841             var previousWriter = writer;
77842             setWriter(output, sourceMapGenerator);
77843             emitShebangIfNeeded(bundle);
77844             emitPrologueDirectivesIfNeeded(bundle);
77845             emitHelpers(bundle);
77846             emitSyntheticTripleSlashReferencesIfNeeded(bundle);
77847             for (var _b = 0, _c = bundle.prepends; _b < _c.length; _b++) {
77848                 var prepend = _c[_b];
77849                 writeLine();
77850                 var pos = writer.getTextPos();
77851                 var savedSections = bundleFileInfo && bundleFileInfo.sections;
77852                 if (savedSections)
77853                     bundleFileInfo.sections = [];
77854                 print(4, prepend, undefined);
77855                 if (bundleFileInfo) {
77856                     var newSections = bundleFileInfo.sections;
77857                     bundleFileInfo.sections = savedSections;
77858                     if (prepend.oldFileOfCurrentEmit)
77859                         (_a = bundleFileInfo.sections).push.apply(_a, newSections);
77860                     else {
77861                         newSections.forEach(function (section) { return ts.Debug.assert(ts.isBundleFileTextLike(section)); });
77862                         bundleFileInfo.sections.push({
77863                             pos: pos,
77864                             end: writer.getTextPos(),
77865                             kind: "prepend",
77866                             data: relativeToBuildInfo(prepend.fileName),
77867                             texts: newSections
77868                         });
77869                     }
77870                 }
77871             }
77872             sourceFileTextPos = getTextPosWithWriteLine();
77873             for (var _d = 0, _e = bundle.sourceFiles; _d < _e.length; _d++) {
77874                 var sourceFile = _e[_d];
77875                 print(0, sourceFile, sourceFile);
77876             }
77877             if (bundleFileInfo && bundle.sourceFiles.length) {
77878                 var end = writer.getTextPos();
77879                 if (recordBundleFileTextLikeSection(end)) {
77880                     var prologues = getPrologueDirectivesFromBundledSourceFiles(bundle);
77881                     if (prologues) {
77882                         if (!bundleFileInfo.sources)
77883                             bundleFileInfo.sources = {};
77884                         bundleFileInfo.sources.prologues = prologues;
77885                     }
77886                     var helpers = getHelpersFromBundledSourceFiles(bundle);
77887                     if (helpers) {
77888                         if (!bundleFileInfo.sources)
77889                             bundleFileInfo.sources = {};
77890                         bundleFileInfo.sources.helpers = helpers;
77891                     }
77892                 }
77893             }
77894             reset();
77895             writer = previousWriter;
77896         }
77897         function writeUnparsedSource(unparsed, output) {
77898             var previousWriter = writer;
77899             setWriter(output, undefined);
77900             print(4, unparsed, undefined);
77901             reset();
77902             writer = previousWriter;
77903         }
77904         function writeFile(sourceFile, output, sourceMapGenerator) {
77905             isOwnFileEmit = true;
77906             var previousWriter = writer;
77907             setWriter(output, sourceMapGenerator);
77908             emitShebangIfNeeded(sourceFile);
77909             emitPrologueDirectivesIfNeeded(sourceFile);
77910             print(0, sourceFile, sourceFile);
77911             reset();
77912             writer = previousWriter;
77913         }
77914         function beginPrint() {
77915             return ownWriter || (ownWriter = ts.createTextWriter(newLine));
77916         }
77917         function endPrint() {
77918             var text = ownWriter.getText();
77919             ownWriter.clear();
77920             return text;
77921         }
77922         function print(hint, node, sourceFile) {
77923             if (sourceFile) {
77924                 setSourceFile(sourceFile);
77925             }
77926             pipelineEmit(hint, node);
77927         }
77928         function setSourceFile(sourceFile) {
77929             currentSourceFile = sourceFile;
77930             currentLineMap = undefined;
77931             detachedCommentsInfo = undefined;
77932             if (sourceFile) {
77933                 setSourceMapSource(sourceFile);
77934             }
77935         }
77936         function setWriter(_writer, _sourceMapGenerator) {
77937             if (_writer && printerOptions.omitTrailingSemicolon) {
77938                 _writer = ts.getTrailingSemicolonDeferringWriter(_writer);
77939             }
77940             writer = _writer;
77941             sourceMapGenerator = _sourceMapGenerator;
77942             sourceMapsDisabled = !writer || !sourceMapGenerator;
77943         }
77944         function reset() {
77945             nodeIdToGeneratedName = [];
77946             autoGeneratedIdToGeneratedName = [];
77947             generatedNames = ts.createMap();
77948             tempFlagsStack = [];
77949             tempFlags = 0;
77950             reservedNamesStack = [];
77951             currentSourceFile = undefined;
77952             currentLineMap = undefined;
77953             detachedCommentsInfo = undefined;
77954             lastNode = undefined;
77955             lastSubstitution = undefined;
77956             setWriter(undefined, undefined);
77957         }
77958         function getCurrentLineMap() {
77959             return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile));
77960         }
77961         function emit(node) {
77962             if (node === undefined)
77963                 return;
77964             var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node);
77965             var substitute = pipelineEmit(4, node);
77966             recordBundleFileInternalSectionEnd(prevSourceFileTextKind);
77967             return substitute;
77968         }
77969         function emitIdentifierName(node) {
77970             if (node === undefined)
77971                 return;
77972             return pipelineEmit(2, node);
77973         }
77974         function emitExpression(node) {
77975             if (node === undefined)
77976                 return;
77977             return pipelineEmit(1, node);
77978         }
77979         function emitJsxAttributeValue(node) {
77980             return pipelineEmit(ts.isStringLiteral(node) ? 6 : 4, node);
77981         }
77982         function pipelineEmit(emitHint, node) {
77983             var savedLastNode = lastNode;
77984             var savedLastSubstitution = lastSubstitution;
77985             var savedPreserveSourceNewlines = preserveSourceNewlines;
77986             lastNode = node;
77987             lastSubstitution = undefined;
77988             if (preserveSourceNewlines && !!(ts.getEmitFlags(node) & 134217728)) {
77989                 preserveSourceNewlines = false;
77990             }
77991             var pipelinePhase = getPipelinePhase(0, emitHint, node);
77992             pipelinePhase(emitHint, node);
77993             ts.Debug.assert(lastNode === node);
77994             var substitute = lastSubstitution;
77995             lastNode = savedLastNode;
77996             lastSubstitution = savedLastSubstitution;
77997             preserveSourceNewlines = savedPreserveSourceNewlines;
77998             return substitute || node;
77999         }
78000         function getPipelinePhase(phase, emitHint, node) {
78001             switch (phase) {
78002                 case 0:
78003                     if (onEmitNode !== ts.noEmitNotification && (!isEmitNotificationEnabled || isEmitNotificationEnabled(node))) {
78004                         return pipelineEmitWithNotification;
78005                     }
78006                 case 1:
78007                     if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node)) !== node) {
78008                         return pipelineEmitWithSubstitution;
78009                     }
78010                 case 2:
78011                     if (!commentsDisabled && node.kind !== 290) {
78012                         return pipelineEmitWithComments;
78013                     }
78014                 case 3:
78015                     if (!sourceMapsDisabled && node.kind !== 290 && !ts.isInJsonFile(node)) {
78016                         return pipelineEmitWithSourceMap;
78017                     }
78018                 case 4:
78019                     return pipelineEmitWithHint;
78020                 default:
78021                     return ts.Debug.assertNever(phase);
78022             }
78023         }
78024         function getNextPipelinePhase(currentPhase, emitHint, node) {
78025             return getPipelinePhase(currentPhase + 1, emitHint, node);
78026         }
78027         function pipelineEmitWithNotification(hint, node) {
78028             ts.Debug.assert(lastNode === node);
78029             var pipelinePhase = getNextPipelinePhase(0, hint, node);
78030             onEmitNode(hint, node, pipelinePhase);
78031             ts.Debug.assert(lastNode === node);
78032         }
78033         function pipelineEmitWithHint(hint, node) {
78034             ts.Debug.assert(lastNode === node || lastSubstitution === node);
78035             if (hint === 0)
78036                 return emitSourceFile(ts.cast(node, ts.isSourceFile));
78037             if (hint === 2)
78038                 return emitIdentifier(ts.cast(node, ts.isIdentifier));
78039             if (hint === 6)
78040                 return emitLiteral(ts.cast(node, ts.isStringLiteral), true);
78041             if (hint === 3)
78042                 return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration));
78043             if (hint === 5) {
78044                 ts.Debug.assertNode(node, ts.isEmptyStatement);
78045                 return emitEmptyStatement(true);
78046             }
78047             if (hint === 4) {
78048                 if (ts.isKeyword(node.kind))
78049                     return writeTokenNode(node, writeKeyword);
78050                 switch (node.kind) {
78051                     case 15:
78052                     case 16:
78053                     case 17:
78054                         return emitLiteral(node, false);
78055                     case 292:
78056                     case 286:
78057                         return emitUnparsedSourceOrPrepend(node);
78058                     case 285:
78059                         return writeUnparsedNode(node);
78060                     case 287:
78061                     case 288:
78062                         return emitUnparsedTextLike(node);
78063                     case 289:
78064                         return emitUnparsedSyntheticReference(node);
78065                     case 75:
78066                         return emitIdentifier(node);
78067                     case 76:
78068                         return emitPrivateIdentifier(node);
78069                     case 153:
78070                         return emitQualifiedName(node);
78071                     case 154:
78072                         return emitComputedPropertyName(node);
78073                     case 155:
78074                         return emitTypeParameter(node);
78075                     case 156:
78076                         return emitParameter(node);
78077                     case 157:
78078                         return emitDecorator(node);
78079                     case 158:
78080                         return emitPropertySignature(node);
78081                     case 159:
78082                         return emitPropertyDeclaration(node);
78083                     case 160:
78084                         return emitMethodSignature(node);
78085                     case 161:
78086                         return emitMethodDeclaration(node);
78087                     case 162:
78088                         return emitConstructor(node);
78089                     case 163:
78090                     case 164:
78091                         return emitAccessorDeclaration(node);
78092                     case 165:
78093                         return emitCallSignature(node);
78094                     case 166:
78095                         return emitConstructSignature(node);
78096                     case 167:
78097                         return emitIndexSignature(node);
78098                     case 168:
78099                         return emitTypePredicate(node);
78100                     case 169:
78101                         return emitTypeReference(node);
78102                     case 170:
78103                         return emitFunctionType(node);
78104                     case 300:
78105                         return emitJSDocFunctionType(node);
78106                     case 171:
78107                         return emitConstructorType(node);
78108                     case 172:
78109                         return emitTypeQuery(node);
78110                     case 173:
78111                         return emitTypeLiteral(node);
78112                     case 174:
78113                         return emitArrayType(node);
78114                     case 175:
78115                         return emitTupleType(node);
78116                     case 176:
78117                         return emitOptionalType(node);
78118                     case 178:
78119                         return emitUnionType(node);
78120                     case 179:
78121                         return emitIntersectionType(node);
78122                     case 180:
78123                         return emitConditionalType(node);
78124                     case 181:
78125                         return emitInferType(node);
78126                     case 182:
78127                         return emitParenthesizedType(node);
78128                     case 216:
78129                         return emitExpressionWithTypeArguments(node);
78130                     case 183:
78131                         return emitThisType();
78132                     case 184:
78133                         return emitTypeOperator(node);
78134                     case 185:
78135                         return emitIndexedAccessType(node);
78136                     case 186:
78137                         return emitMappedType(node);
78138                     case 187:
78139                         return emitLiteralType(node);
78140                     case 188:
78141                         return emitImportTypeNode(node);
78142                     case 295:
78143                         writePunctuation("*");
78144                         return;
78145                     case 296:
78146                         writePunctuation("?");
78147                         return;
78148                     case 297:
78149                         return emitJSDocNullableType(node);
78150                     case 298:
78151                         return emitJSDocNonNullableType(node);
78152                     case 299:
78153                         return emitJSDocOptionalType(node);
78154                     case 177:
78155                     case 301:
78156                         return emitRestOrJSDocVariadicType(node);
78157                     case 189:
78158                         return emitObjectBindingPattern(node);
78159                     case 190:
78160                         return emitArrayBindingPattern(node);
78161                     case 191:
78162                         return emitBindingElement(node);
78163                     case 221:
78164                         return emitTemplateSpan(node);
78165                     case 222:
78166                         return emitSemicolonClassElement();
78167                     case 223:
78168                         return emitBlock(node);
78169                     case 225:
78170                         return emitVariableStatement(node);
78171                     case 224:
78172                         return emitEmptyStatement(false);
78173                     case 226:
78174                         return emitExpressionStatement(node);
78175                     case 227:
78176                         return emitIfStatement(node);
78177                     case 228:
78178                         return emitDoStatement(node);
78179                     case 229:
78180                         return emitWhileStatement(node);
78181                     case 230:
78182                         return emitForStatement(node);
78183                     case 231:
78184                         return emitForInStatement(node);
78185                     case 232:
78186                         return emitForOfStatement(node);
78187                     case 233:
78188                         return emitContinueStatement(node);
78189                     case 234:
78190                         return emitBreakStatement(node);
78191                     case 235:
78192                         return emitReturnStatement(node);
78193                     case 236:
78194                         return emitWithStatement(node);
78195                     case 237:
78196                         return emitSwitchStatement(node);
78197                     case 238:
78198                         return emitLabeledStatement(node);
78199                     case 239:
78200                         return emitThrowStatement(node);
78201                     case 240:
78202                         return emitTryStatement(node);
78203                     case 241:
78204                         return emitDebuggerStatement(node);
78205                     case 242:
78206                         return emitVariableDeclaration(node);
78207                     case 243:
78208                         return emitVariableDeclarationList(node);
78209                     case 244:
78210                         return emitFunctionDeclaration(node);
78211                     case 245:
78212                         return emitClassDeclaration(node);
78213                     case 246:
78214                         return emitInterfaceDeclaration(node);
78215                     case 247:
78216                         return emitTypeAliasDeclaration(node);
78217                     case 248:
78218                         return emitEnumDeclaration(node);
78219                     case 249:
78220                         return emitModuleDeclaration(node);
78221                     case 250:
78222                         return emitModuleBlock(node);
78223                     case 251:
78224                         return emitCaseBlock(node);
78225                     case 252:
78226                         return emitNamespaceExportDeclaration(node);
78227                     case 253:
78228                         return emitImportEqualsDeclaration(node);
78229                     case 254:
78230                         return emitImportDeclaration(node);
78231                     case 255:
78232                         return emitImportClause(node);
78233                     case 256:
78234                         return emitNamespaceImport(node);
78235                     case 262:
78236                         return emitNamespaceExport(node);
78237                     case 257:
78238                         return emitNamedImports(node);
78239                     case 258:
78240                         return emitImportSpecifier(node);
78241                     case 259:
78242                         return emitExportAssignment(node);
78243                     case 260:
78244                         return emitExportDeclaration(node);
78245                     case 261:
78246                         return emitNamedExports(node);
78247                     case 263:
78248                         return emitExportSpecifier(node);
78249                     case 264:
78250                         return;
78251                     case 265:
78252                         return emitExternalModuleReference(node);
78253                     case 11:
78254                         return emitJsxText(node);
78255                     case 268:
78256                     case 271:
78257                         return emitJsxOpeningElementOrFragment(node);
78258                     case 269:
78259                     case 272:
78260                         return emitJsxClosingElementOrFragment(node);
78261                     case 273:
78262                         return emitJsxAttribute(node);
78263                     case 274:
78264                         return emitJsxAttributes(node);
78265                     case 275:
78266                         return emitJsxSpreadAttribute(node);
78267                     case 276:
78268                         return emitJsxExpression(node);
78269                     case 277:
78270                         return emitCaseClause(node);
78271                     case 278:
78272                         return emitDefaultClause(node);
78273                     case 279:
78274                         return emitHeritageClause(node);
78275                     case 280:
78276                         return emitCatchClause(node);
78277                     case 281:
78278                         return emitPropertyAssignment(node);
78279                     case 282:
78280                         return emitShorthandPropertyAssignment(node);
78281                     case 283:
78282                         return emitSpreadAssignment(node);
78283                     case 284:
78284                         return emitEnumMember(node);
78285                     case 317:
78286                     case 323:
78287                         return emitJSDocPropertyLikeTag(node);
78288                     case 318:
78289                     case 320:
78290                     case 319:
78291                     case 316:
78292                         return emitJSDocSimpleTypedTag(node);
78293                     case 308:
78294                     case 307:
78295                         return emitJSDocHeritageTag(node);
78296                     case 321:
78297                         return emitJSDocTemplateTag(node);
78298                     case 322:
78299                         return emitJSDocTypedefTag(node);
78300                     case 315:
78301                         return emitJSDocCallbackTag(node);
78302                     case 305:
78303                         return emitJSDocSignature(node);
78304                     case 304:
78305                         return emitJSDocTypeLiteral(node);
78306                     case 310:
78307                     case 306:
78308                         return emitJSDocSimpleTag(node);
78309                     case 303:
78310                         return emitJSDoc(node);
78311                 }
78312                 if (ts.isExpression(node)) {
78313                     hint = 1;
78314                     if (substituteNode !== ts.noEmitSubstitution) {
78315                         lastSubstitution = node = substituteNode(hint, node);
78316                     }
78317                 }
78318                 else if (ts.isToken(node)) {
78319                     return writeTokenNode(node, writePunctuation);
78320                 }
78321             }
78322             if (hint === 1) {
78323                 switch (node.kind) {
78324                     case 8:
78325                     case 9:
78326                         return emitNumericOrBigIntLiteral(node);
78327                     case 10:
78328                     case 13:
78329                     case 14:
78330                         return emitLiteral(node, false);
78331                     case 75:
78332                         return emitIdentifier(node);
78333                     case 91:
78334                     case 100:
78335                     case 102:
78336                     case 106:
78337                     case 104:
78338                     case 96:
78339                         writeTokenNode(node, writeKeyword);
78340                         return;
78341                     case 192:
78342                         return emitArrayLiteralExpression(node);
78343                     case 193:
78344                         return emitObjectLiteralExpression(node);
78345                     case 194:
78346                         return emitPropertyAccessExpression(node);
78347                     case 195:
78348                         return emitElementAccessExpression(node);
78349                     case 196:
78350                         return emitCallExpression(node);
78351                     case 197:
78352                         return emitNewExpression(node);
78353                     case 198:
78354                         return emitTaggedTemplateExpression(node);
78355                     case 199:
78356                         return emitTypeAssertionExpression(node);
78357                     case 200:
78358                         return emitParenthesizedExpression(node);
78359                     case 201:
78360                         return emitFunctionExpression(node);
78361                     case 202:
78362                         return emitArrowFunction(node);
78363                     case 203:
78364                         return emitDeleteExpression(node);
78365                     case 204:
78366                         return emitTypeOfExpression(node);
78367                     case 205:
78368                         return emitVoidExpression(node);
78369                     case 206:
78370                         return emitAwaitExpression(node);
78371                     case 207:
78372                         return emitPrefixUnaryExpression(node);
78373                     case 208:
78374                         return emitPostfixUnaryExpression(node);
78375                     case 209:
78376                         return emitBinaryExpression(node);
78377                     case 210:
78378                         return emitConditionalExpression(node);
78379                     case 211:
78380                         return emitTemplateExpression(node);
78381                     case 212:
78382                         return emitYieldExpression(node);
78383                     case 213:
78384                         return emitSpreadExpression(node);
78385                     case 214:
78386                         return emitClassExpression(node);
78387                     case 215:
78388                         return;
78389                     case 217:
78390                         return emitAsExpression(node);
78391                     case 218:
78392                         return emitNonNullExpression(node);
78393                     case 219:
78394                         return emitMetaProperty(node);
78395                     case 266:
78396                         return emitJsxElement(node);
78397                     case 267:
78398                         return emitJsxSelfClosingElement(node);
78399                     case 270:
78400                         return emitJsxFragment(node);
78401                     case 326:
78402                         return emitPartiallyEmittedExpression(node);
78403                     case 327:
78404                         return emitCommaList(node);
78405                 }
78406             }
78407         }
78408         function emitMappedTypeParameter(node) {
78409             emit(node.name);
78410             writeSpace();
78411             writeKeyword("in");
78412             writeSpace();
78413             emit(node.constraint);
78414         }
78415         function pipelineEmitWithSubstitution(hint, node) {
78416             ts.Debug.assert(lastNode === node || lastSubstitution === node);
78417             var pipelinePhase = getNextPipelinePhase(1, hint, node);
78418             pipelinePhase(hint, lastSubstitution);
78419             ts.Debug.assert(lastNode === node || lastSubstitution === node);
78420         }
78421         function getHelpersFromBundledSourceFiles(bundle) {
78422             var result;
78423             if (moduleKind === ts.ModuleKind.None || printerOptions.noEmitHelpers) {
78424                 return undefined;
78425             }
78426             var bundledHelpers = ts.createMap();
78427             for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) {
78428                 var sourceFile = _b[_a];
78429                 var shouldSkip = ts.getExternalHelpersModuleName(sourceFile) !== undefined;
78430                 var helpers = getSortedEmitHelpers(sourceFile);
78431                 if (!helpers)
78432                     continue;
78433                 for (var _c = 0, helpers_4 = helpers; _c < helpers_4.length; _c++) {
78434                     var helper = helpers_4[_c];
78435                     if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) {
78436                         bundledHelpers.set(helper.name, true);
78437                         (result || (result = [])).push(helper.name);
78438                     }
78439                 }
78440             }
78441             return result;
78442         }
78443         function emitHelpers(node) {
78444             var helpersEmitted = false;
78445             var bundle = node.kind === 291 ? node : undefined;
78446             if (bundle && moduleKind === ts.ModuleKind.None) {
78447                 return;
78448             }
78449             var numPrepends = bundle ? bundle.prepends.length : 0;
78450             var numNodes = bundle ? bundle.sourceFiles.length + numPrepends : 1;
78451             for (var i = 0; i < numNodes; i++) {
78452                 var currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node;
78453                 var sourceFile = ts.isSourceFile(currentNode) ? currentNode : ts.isUnparsedSource(currentNode) ? undefined : currentSourceFile;
78454                 var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.hasRecordedExternalHelpers(sourceFile));
78455                 var shouldBundle = (ts.isSourceFile(currentNode) || ts.isUnparsedSource(currentNode)) && !isOwnFileEmit;
78456                 var helpers = ts.isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode);
78457                 if (helpers) {
78458                     for (var _a = 0, helpers_5 = helpers; _a < helpers_5.length; _a++) {
78459                         var helper = helpers_5[_a];
78460                         if (!helper.scoped) {
78461                             if (shouldSkip)
78462                                 continue;
78463                             if (shouldBundle) {
78464                                 if (bundledHelpers.get(helper.name)) {
78465                                     continue;
78466                                 }
78467                                 bundledHelpers.set(helper.name, true);
78468                             }
78469                         }
78470                         else if (bundle) {
78471                             continue;
78472                         }
78473                         var pos = getTextPosWithWriteLine();
78474                         if (typeof helper.text === "string") {
78475                             writeLines(helper.text);
78476                         }
78477                         else {
78478                             writeLines(helper.text(makeFileLevelOptimisticUniqueName));
78479                         }
78480                         if (bundleFileInfo)
78481                             bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers", data: helper.name });
78482                         helpersEmitted = true;
78483                     }
78484                 }
78485             }
78486             return helpersEmitted;
78487         }
78488         function getSortedEmitHelpers(node) {
78489             var helpers = ts.getEmitHelpers(node);
78490             return helpers && ts.stableSort(helpers, ts.compareEmitHelpers);
78491         }
78492         function emitNumericOrBigIntLiteral(node) {
78493             emitLiteral(node, false);
78494         }
78495         function emitLiteral(node, jsxAttributeEscape) {
78496             var text = getLiteralTextOfNode(node, printerOptions.neverAsciiEscape, jsxAttributeEscape);
78497             if ((printerOptions.sourceMap || printerOptions.inlineSourceMap)
78498                 && (node.kind === 10 || ts.isTemplateLiteralKind(node.kind))) {
78499                 writeLiteral(text);
78500             }
78501             else {
78502                 writeStringLiteral(text);
78503             }
78504         }
78505         function emitUnparsedSourceOrPrepend(unparsed) {
78506             for (var _a = 0, _b = unparsed.texts; _a < _b.length; _a++) {
78507                 var text = _b[_a];
78508                 writeLine();
78509                 emit(text);
78510             }
78511         }
78512         function writeUnparsedNode(unparsed) {
78513             writer.rawWrite(unparsed.parent.text.substring(unparsed.pos, unparsed.end));
78514         }
78515         function emitUnparsedTextLike(unparsed) {
78516             var pos = getTextPosWithWriteLine();
78517             writeUnparsedNode(unparsed);
78518             if (bundleFileInfo) {
78519                 updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 287 ?
78520                     "text" :
78521                     "internal");
78522             }
78523         }
78524         function emitUnparsedSyntheticReference(unparsed) {
78525             var pos = getTextPosWithWriteLine();
78526             writeUnparsedNode(unparsed);
78527             if (bundleFileInfo) {
78528                 var section = ts.clone(unparsed.section);
78529                 section.pos = pos;
78530                 section.end = writer.getTextPos();
78531                 bundleFileInfo.sections.push(section);
78532             }
78533         }
78534         function emitIdentifier(node) {
78535             var writeText = node.symbol ? writeSymbol : write;
78536             writeText(getTextOfNode(node, false), node.symbol);
78537             emitList(node, node.typeArguments, 53776);
78538         }
78539         function emitPrivateIdentifier(node) {
78540             var writeText = node.symbol ? writeSymbol : write;
78541             writeText(getTextOfNode(node, false), node.symbol);
78542         }
78543         function emitQualifiedName(node) {
78544             emitEntityName(node.left);
78545             writePunctuation(".");
78546             emit(node.right);
78547         }
78548         function emitEntityName(node) {
78549             if (node.kind === 75) {
78550                 emitExpression(node);
78551             }
78552             else {
78553                 emit(node);
78554             }
78555         }
78556         function emitComputedPropertyName(node) {
78557             writePunctuation("[");
78558             emitExpression(node.expression);
78559             writePunctuation("]");
78560         }
78561         function emitTypeParameter(node) {
78562             emit(node.name);
78563             if (node.constraint) {
78564                 writeSpace();
78565                 writeKeyword("extends");
78566                 writeSpace();
78567                 emit(node.constraint);
78568             }
78569             if (node.default) {
78570                 writeSpace();
78571                 writeOperator("=");
78572                 writeSpace();
78573                 emit(node.default);
78574             }
78575         }
78576         function emitParameter(node) {
78577             emitDecorators(node, node.decorators);
78578             emitModifiers(node, node.modifiers);
78579             emit(node.dotDotDotToken);
78580             emitNodeWithWriter(node.name, writeParameter);
78581             emit(node.questionToken);
78582             if (node.parent && node.parent.kind === 300 && !node.name) {
78583                 emit(node.type);
78584             }
78585             else {
78586                 emitTypeAnnotation(node.type);
78587             }
78588             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);
78589         }
78590         function emitDecorator(decorator) {
78591             writePunctuation("@");
78592             emitExpression(decorator.expression);
78593         }
78594         function emitPropertySignature(node) {
78595             emitDecorators(node, node.decorators);
78596             emitModifiers(node, node.modifiers);
78597             emitNodeWithWriter(node.name, writeProperty);
78598             emit(node.questionToken);
78599             emitTypeAnnotation(node.type);
78600             writeTrailingSemicolon();
78601         }
78602         function emitPropertyDeclaration(node) {
78603             emitDecorators(node, node.decorators);
78604             emitModifiers(node, node.modifiers);
78605             emit(node.name);
78606             emit(node.questionToken);
78607             emit(node.exclamationToken);
78608             emitTypeAnnotation(node.type);
78609             emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name.end, node);
78610             writeTrailingSemicolon();
78611         }
78612         function emitMethodSignature(node) {
78613             pushNameGenerationScope(node);
78614             emitDecorators(node, node.decorators);
78615             emitModifiers(node, node.modifiers);
78616             emit(node.name);
78617             emit(node.questionToken);
78618             emitTypeParameters(node, node.typeParameters);
78619             emitParameters(node, node.parameters);
78620             emitTypeAnnotation(node.type);
78621             writeTrailingSemicolon();
78622             popNameGenerationScope(node);
78623         }
78624         function emitMethodDeclaration(node) {
78625             emitDecorators(node, node.decorators);
78626             emitModifiers(node, node.modifiers);
78627             emit(node.asteriskToken);
78628             emit(node.name);
78629             emit(node.questionToken);
78630             emitSignatureAndBody(node, emitSignatureHead);
78631         }
78632         function emitConstructor(node) {
78633             emitModifiers(node, node.modifiers);
78634             writeKeyword("constructor");
78635             emitSignatureAndBody(node, emitSignatureHead);
78636         }
78637         function emitAccessorDeclaration(node) {
78638             emitDecorators(node, node.decorators);
78639             emitModifiers(node, node.modifiers);
78640             writeKeyword(node.kind === 163 ? "get" : "set");
78641             writeSpace();
78642             emit(node.name);
78643             emitSignatureAndBody(node, emitSignatureHead);
78644         }
78645         function emitCallSignature(node) {
78646             pushNameGenerationScope(node);
78647             emitDecorators(node, node.decorators);
78648             emitModifiers(node, node.modifiers);
78649             emitTypeParameters(node, node.typeParameters);
78650             emitParameters(node, node.parameters);
78651             emitTypeAnnotation(node.type);
78652             writeTrailingSemicolon();
78653             popNameGenerationScope(node);
78654         }
78655         function emitConstructSignature(node) {
78656             pushNameGenerationScope(node);
78657             emitDecorators(node, node.decorators);
78658             emitModifiers(node, node.modifiers);
78659             writeKeyword("new");
78660             writeSpace();
78661             emitTypeParameters(node, node.typeParameters);
78662             emitParameters(node, node.parameters);
78663             emitTypeAnnotation(node.type);
78664             writeTrailingSemicolon();
78665             popNameGenerationScope(node);
78666         }
78667         function emitIndexSignature(node) {
78668             emitDecorators(node, node.decorators);
78669             emitModifiers(node, node.modifiers);
78670             emitParametersForIndexSignature(node, node.parameters);
78671             emitTypeAnnotation(node.type);
78672             writeTrailingSemicolon();
78673         }
78674         function emitSemicolonClassElement() {
78675             writeTrailingSemicolon();
78676         }
78677         function emitTypePredicate(node) {
78678             if (node.assertsModifier) {
78679                 emit(node.assertsModifier);
78680                 writeSpace();
78681             }
78682             emit(node.parameterName);
78683             if (node.type) {
78684                 writeSpace();
78685                 writeKeyword("is");
78686                 writeSpace();
78687                 emit(node.type);
78688             }
78689         }
78690         function emitTypeReference(node) {
78691             emit(node.typeName);
78692             emitTypeArguments(node, node.typeArguments);
78693         }
78694         function emitFunctionType(node) {
78695             pushNameGenerationScope(node);
78696             emitTypeParameters(node, node.typeParameters);
78697             emitParametersForArrow(node, node.parameters);
78698             writeSpace();
78699             writePunctuation("=>");
78700             writeSpace();
78701             emit(node.type);
78702             popNameGenerationScope(node);
78703         }
78704         function emitJSDocFunctionType(node) {
78705             writeKeyword("function");
78706             emitParameters(node, node.parameters);
78707             writePunctuation(":");
78708             emit(node.type);
78709         }
78710         function emitJSDocNullableType(node) {
78711             writePunctuation("?");
78712             emit(node.type);
78713         }
78714         function emitJSDocNonNullableType(node) {
78715             writePunctuation("!");
78716             emit(node.type);
78717         }
78718         function emitJSDocOptionalType(node) {
78719             emit(node.type);
78720             writePunctuation("=");
78721         }
78722         function emitConstructorType(node) {
78723             pushNameGenerationScope(node);
78724             writeKeyword("new");
78725             writeSpace();
78726             emitTypeParameters(node, node.typeParameters);
78727             emitParameters(node, node.parameters);
78728             writeSpace();
78729             writePunctuation("=>");
78730             writeSpace();
78731             emit(node.type);
78732             popNameGenerationScope(node);
78733         }
78734         function emitTypeQuery(node) {
78735             writeKeyword("typeof");
78736             writeSpace();
78737             emit(node.exprName);
78738         }
78739         function emitTypeLiteral(node) {
78740             writePunctuation("{");
78741             var flags = ts.getEmitFlags(node) & 1 ? 768 : 32897;
78742             emitList(node, node.members, flags | 524288);
78743             writePunctuation("}");
78744         }
78745         function emitArrayType(node) {
78746             emit(node.elementType);
78747             writePunctuation("[");
78748             writePunctuation("]");
78749         }
78750         function emitRestOrJSDocVariadicType(node) {
78751             writePunctuation("...");
78752             emit(node.type);
78753         }
78754         function emitTupleType(node) {
78755             writePunctuation("[");
78756             emitList(node, node.elementTypes, 528);
78757             writePunctuation("]");
78758         }
78759         function emitOptionalType(node) {
78760             emit(node.type);
78761             writePunctuation("?");
78762         }
78763         function emitUnionType(node) {
78764             emitList(node, node.types, 516);
78765         }
78766         function emitIntersectionType(node) {
78767             emitList(node, node.types, 520);
78768         }
78769         function emitConditionalType(node) {
78770             emit(node.checkType);
78771             writeSpace();
78772             writeKeyword("extends");
78773             writeSpace();
78774             emit(node.extendsType);
78775             writeSpace();
78776             writePunctuation("?");
78777             writeSpace();
78778             emit(node.trueType);
78779             writeSpace();
78780             writePunctuation(":");
78781             writeSpace();
78782             emit(node.falseType);
78783         }
78784         function emitInferType(node) {
78785             writeKeyword("infer");
78786             writeSpace();
78787             emit(node.typeParameter);
78788         }
78789         function emitParenthesizedType(node) {
78790             writePunctuation("(");
78791             emit(node.type);
78792             writePunctuation(")");
78793         }
78794         function emitThisType() {
78795             writeKeyword("this");
78796         }
78797         function emitTypeOperator(node) {
78798             writeTokenText(node.operator, writeKeyword);
78799             writeSpace();
78800             emit(node.type);
78801         }
78802         function emitIndexedAccessType(node) {
78803             emit(node.objectType);
78804             writePunctuation("[");
78805             emit(node.indexType);
78806             writePunctuation("]");
78807         }
78808         function emitMappedType(node) {
78809             var emitFlags = ts.getEmitFlags(node);
78810             writePunctuation("{");
78811             if (emitFlags & 1) {
78812                 writeSpace();
78813             }
78814             else {
78815                 writeLine();
78816                 increaseIndent();
78817             }
78818             if (node.readonlyToken) {
78819                 emit(node.readonlyToken);
78820                 if (node.readonlyToken.kind !== 138) {
78821                     writeKeyword("readonly");
78822                 }
78823                 writeSpace();
78824             }
78825             writePunctuation("[");
78826             pipelineEmit(3, node.typeParameter);
78827             writePunctuation("]");
78828             if (node.questionToken) {
78829                 emit(node.questionToken);
78830                 if (node.questionToken.kind !== 57) {
78831                     writePunctuation("?");
78832                 }
78833             }
78834             writePunctuation(":");
78835             writeSpace();
78836             emit(node.type);
78837             writeTrailingSemicolon();
78838             if (emitFlags & 1) {
78839                 writeSpace();
78840             }
78841             else {
78842                 writeLine();
78843                 decreaseIndent();
78844             }
78845             writePunctuation("}");
78846         }
78847         function emitLiteralType(node) {
78848             emitExpression(node.literal);
78849         }
78850         function emitImportTypeNode(node) {
78851             if (node.isTypeOf) {
78852                 writeKeyword("typeof");
78853                 writeSpace();
78854             }
78855             writeKeyword("import");
78856             writePunctuation("(");
78857             emit(node.argument);
78858             writePunctuation(")");
78859             if (node.qualifier) {
78860                 writePunctuation(".");
78861                 emit(node.qualifier);
78862             }
78863             emitTypeArguments(node, node.typeArguments);
78864         }
78865         function emitObjectBindingPattern(node) {
78866             writePunctuation("{");
78867             emitList(node, node.elements, 525136);
78868             writePunctuation("}");
78869         }
78870         function emitArrayBindingPattern(node) {
78871             writePunctuation("[");
78872             emitList(node, node.elements, 524880);
78873             writePunctuation("]");
78874         }
78875         function emitBindingElement(node) {
78876             emit(node.dotDotDotToken);
78877             if (node.propertyName) {
78878                 emit(node.propertyName);
78879                 writePunctuation(":");
78880                 writeSpace();
78881             }
78882             emit(node.name);
78883             emitInitializer(node.initializer, node.name.end, node);
78884         }
78885         function emitArrayLiteralExpression(node) {
78886             var elements = node.elements;
78887             var preferNewLine = node.multiLine ? 65536 : 0;
78888             emitExpressionList(node, elements, 8914 | preferNewLine);
78889         }
78890         function emitObjectLiteralExpression(node) {
78891             ts.forEach(node.properties, generateMemberNames);
78892             var indentedFlag = ts.getEmitFlags(node) & 65536;
78893             if (indentedFlag) {
78894                 increaseIndent();
78895             }
78896             var preferNewLine = node.multiLine ? 65536 : 0;
78897             var allowTrailingComma = currentSourceFile.languageVersion >= 1 && !ts.isJsonSourceFile(currentSourceFile) ? 64 : 0;
78898             emitList(node, node.properties, 526226 | allowTrailingComma | preferNewLine);
78899             if (indentedFlag) {
78900                 decreaseIndent();
78901             }
78902         }
78903         function emitPropertyAccessExpression(node) {
78904             var expression = ts.cast(emitExpression(node.expression), ts.isExpression);
78905             var token = node.questionDotToken || ts.createNode(24, node.expression.end, node.name.pos);
78906             var linesBeforeDot = getLinesBetweenNodes(node, node.expression, token);
78907             var linesAfterDot = getLinesBetweenNodes(node, token, node.name);
78908             writeLinesAndIndent(linesBeforeDot, false);
78909             var shouldEmitDotDot = token.kind !== 28 &&
78910                 mayNeedDotDotForPropertyAccess(expression) &&
78911                 !writer.hasTrailingComment() &&
78912                 !writer.hasTrailingWhitespace();
78913             if (shouldEmitDotDot) {
78914                 writePunctuation(".");
78915             }
78916             if (node.questionDotToken) {
78917                 emit(token);
78918             }
78919             else {
78920                 emitTokenWithComment(token.kind, node.expression.end, writePunctuation, node);
78921             }
78922             writeLinesAndIndent(linesAfterDot, false);
78923             emit(node.name);
78924             decreaseIndentIf(linesBeforeDot, linesAfterDot);
78925         }
78926         function mayNeedDotDotForPropertyAccess(expression) {
78927             expression = ts.skipPartiallyEmittedExpressions(expression);
78928             if (ts.isNumericLiteral(expression)) {
78929                 var text = getLiteralTextOfNode(expression, true, false);
78930                 return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24));
78931             }
78932             else if (ts.isAccessExpression(expression)) {
78933                 var constantValue = ts.getConstantValue(expression);
78934                 return typeof constantValue === "number" && isFinite(constantValue)
78935                     && Math.floor(constantValue) === constantValue;
78936             }
78937         }
78938         function emitElementAccessExpression(node) {
78939             emitExpression(node.expression);
78940             emit(node.questionDotToken);
78941             emitTokenWithComment(22, node.expression.end, writePunctuation, node);
78942             emitExpression(node.argumentExpression);
78943             emitTokenWithComment(23, node.argumentExpression.end, writePunctuation, node);
78944         }
78945         function emitCallExpression(node) {
78946             emitExpression(node.expression);
78947             emit(node.questionDotToken);
78948             emitTypeArguments(node, node.typeArguments);
78949             emitExpressionList(node, node.arguments, 2576);
78950         }
78951         function emitNewExpression(node) {
78952             emitTokenWithComment(99, node.pos, writeKeyword, node);
78953             writeSpace();
78954             emitExpression(node.expression);
78955             emitTypeArguments(node, node.typeArguments);
78956             emitExpressionList(node, node.arguments, 18960);
78957         }
78958         function emitTaggedTemplateExpression(node) {
78959             emitExpression(node.tag);
78960             emitTypeArguments(node, node.typeArguments);
78961             writeSpace();
78962             emitExpression(node.template);
78963         }
78964         function emitTypeAssertionExpression(node) {
78965             writePunctuation("<");
78966             emit(node.type);
78967             writePunctuation(">");
78968             emitExpression(node.expression);
78969         }
78970         function emitParenthesizedExpression(node) {
78971             var openParenPos = emitTokenWithComment(20, node.pos, writePunctuation, node);
78972             var indented = writeLineSeparatorsAndIndentBefore(node.expression, node);
78973             emitExpression(node.expression);
78974             writeLineSeparatorsAfter(node.expression, node);
78975             decreaseIndentIf(indented);
78976             emitTokenWithComment(21, node.expression ? node.expression.end : openParenPos, writePunctuation, node);
78977         }
78978         function emitFunctionExpression(node) {
78979             generateNameIfNeeded(node.name);
78980             emitFunctionDeclarationOrExpression(node);
78981         }
78982         function emitArrowFunction(node) {
78983             emitDecorators(node, node.decorators);
78984             emitModifiers(node, node.modifiers);
78985             emitSignatureAndBody(node, emitArrowFunctionHead);
78986         }
78987         function emitArrowFunctionHead(node) {
78988             emitTypeParameters(node, node.typeParameters);
78989             emitParametersForArrow(node, node.parameters);
78990             emitTypeAnnotation(node.type);
78991             writeSpace();
78992             emit(node.equalsGreaterThanToken);
78993         }
78994         function emitDeleteExpression(node) {
78995             emitTokenWithComment(85, node.pos, writeKeyword, node);
78996             writeSpace();
78997             emitExpression(node.expression);
78998         }
78999         function emitTypeOfExpression(node) {
79000             emitTokenWithComment(108, node.pos, writeKeyword, node);
79001             writeSpace();
79002             emitExpression(node.expression);
79003         }
79004         function emitVoidExpression(node) {
79005             emitTokenWithComment(110, node.pos, writeKeyword, node);
79006             writeSpace();
79007             emitExpression(node.expression);
79008         }
79009         function emitAwaitExpression(node) {
79010             emitTokenWithComment(127, node.pos, writeKeyword, node);
79011             writeSpace();
79012             emitExpression(node.expression);
79013         }
79014         function emitPrefixUnaryExpression(node) {
79015             writeTokenText(node.operator, writeOperator);
79016             if (shouldEmitWhitespaceBeforeOperand(node)) {
79017                 writeSpace();
79018             }
79019             emitExpression(node.operand);
79020         }
79021         function shouldEmitWhitespaceBeforeOperand(node) {
79022             var operand = node.operand;
79023             return operand.kind === 207
79024                 && ((node.operator === 39 && (operand.operator === 39 || operand.operator === 45))
79025                     || (node.operator === 40 && (operand.operator === 40 || operand.operator === 46)));
79026         }
79027         function emitPostfixUnaryExpression(node) {
79028             emitExpression(node.operand);
79029             writeTokenText(node.operator, writeOperator);
79030         }
79031         function emitBinaryExpression(node) {
79032             var nodeStack = [node];
79033             var stateStack = [0];
79034             var stackIndex = 0;
79035             while (stackIndex >= 0) {
79036                 node = nodeStack[stackIndex];
79037                 switch (stateStack[stackIndex]) {
79038                     case 0: {
79039                         maybePipelineEmitExpression(node.left);
79040                         break;
79041                     }
79042                     case 1: {
79043                         var isCommaOperator = node.operatorToken.kind !== 27;
79044                         var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken);
79045                         var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right);
79046                         writeLinesAndIndent(linesBeforeOperator, isCommaOperator);
79047                         emitLeadingCommentsOfPosition(node.operatorToken.pos);
79048                         writeTokenNode(node.operatorToken, node.operatorToken.kind === 97 ? writeKeyword : writeOperator);
79049                         emitTrailingCommentsOfPosition(node.operatorToken.end, true);
79050                         writeLinesAndIndent(linesAfterOperator, true);
79051                         maybePipelineEmitExpression(node.right);
79052                         break;
79053                     }
79054                     case 2: {
79055                         var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken);
79056                         var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right);
79057                         decreaseIndentIf(linesBeforeOperator, linesAfterOperator);
79058                         stackIndex--;
79059                         break;
79060                     }
79061                     default: return ts.Debug.fail("Invalid state " + stateStack[stackIndex] + " for emitBinaryExpressionWorker");
79062                 }
79063             }
79064             function maybePipelineEmitExpression(next) {
79065                 stateStack[stackIndex]++;
79066                 var savedLastNode = lastNode;
79067                 var savedLastSubstitution = lastSubstitution;
79068                 lastNode = next;
79069                 lastSubstitution = undefined;
79070                 var pipelinePhase = getPipelinePhase(0, 1, next);
79071                 if (pipelinePhase === pipelineEmitWithHint && ts.isBinaryExpression(next)) {
79072                     stackIndex++;
79073                     stateStack[stackIndex] = 0;
79074                     nodeStack[stackIndex] = next;
79075                 }
79076                 else {
79077                     pipelinePhase(1, next);
79078                 }
79079                 ts.Debug.assert(lastNode === next);
79080                 lastNode = savedLastNode;
79081                 lastSubstitution = savedLastSubstitution;
79082             }
79083         }
79084         function emitConditionalExpression(node) {
79085             var linesBeforeQuestion = getLinesBetweenNodes(node, node.condition, node.questionToken);
79086             var linesAfterQuestion = getLinesBetweenNodes(node, node.questionToken, node.whenTrue);
79087             var linesBeforeColon = getLinesBetweenNodes(node, node.whenTrue, node.colonToken);
79088             var linesAfterColon = getLinesBetweenNodes(node, node.colonToken, node.whenFalse);
79089             emitExpression(node.condition);
79090             writeLinesAndIndent(linesBeforeQuestion, true);
79091             emit(node.questionToken);
79092             writeLinesAndIndent(linesAfterQuestion, true);
79093             emitExpression(node.whenTrue);
79094             decreaseIndentIf(linesBeforeQuestion, linesAfterQuestion);
79095             writeLinesAndIndent(linesBeforeColon, true);
79096             emit(node.colonToken);
79097             writeLinesAndIndent(linesAfterColon, true);
79098             emitExpression(node.whenFalse);
79099             decreaseIndentIf(linesBeforeColon, linesAfterColon);
79100         }
79101         function emitTemplateExpression(node) {
79102             emit(node.head);
79103             emitList(node, node.templateSpans, 262144);
79104         }
79105         function emitYieldExpression(node) {
79106             emitTokenWithComment(121, node.pos, writeKeyword, node);
79107             emit(node.asteriskToken);
79108             emitExpressionWithLeadingSpace(node.expression);
79109         }
79110         function emitSpreadExpression(node) {
79111             emitTokenWithComment(25, node.pos, writePunctuation, node);
79112             emitExpression(node.expression);
79113         }
79114         function emitClassExpression(node) {
79115             generateNameIfNeeded(node.name);
79116             emitClassDeclarationOrExpression(node);
79117         }
79118         function emitExpressionWithTypeArguments(node) {
79119             emitExpression(node.expression);
79120             emitTypeArguments(node, node.typeArguments);
79121         }
79122         function emitAsExpression(node) {
79123             emitExpression(node.expression);
79124             if (node.type) {
79125                 writeSpace();
79126                 writeKeyword("as");
79127                 writeSpace();
79128                 emit(node.type);
79129             }
79130         }
79131         function emitNonNullExpression(node) {
79132             emitExpression(node.expression);
79133             writeOperator("!");
79134         }
79135         function emitMetaProperty(node) {
79136             writeToken(node.keywordToken, node.pos, writePunctuation);
79137             writePunctuation(".");
79138             emit(node.name);
79139         }
79140         function emitTemplateSpan(node) {
79141             emitExpression(node.expression);
79142             emit(node.literal);
79143         }
79144         function emitBlock(node) {
79145             emitBlockStatements(node, !node.multiLine && isEmptyBlock(node));
79146         }
79147         function emitBlockStatements(node, forceSingleLine) {
79148             emitTokenWithComment(18, node.pos, writePunctuation, node);
79149             var format = forceSingleLine || ts.getEmitFlags(node) & 1 ? 768 : 129;
79150             emitList(node, node.statements, format);
79151             emitTokenWithComment(19, node.statements.end, writePunctuation, node, !!(format & 1));
79152         }
79153         function emitVariableStatement(node) {
79154             emitModifiers(node, node.modifiers);
79155             emit(node.declarationList);
79156             writeTrailingSemicolon();
79157         }
79158         function emitEmptyStatement(isEmbeddedStatement) {
79159             if (isEmbeddedStatement) {
79160                 writePunctuation(";");
79161             }
79162             else {
79163                 writeTrailingSemicolon();
79164             }
79165         }
79166         function emitExpressionStatement(node) {
79167             emitExpression(node.expression);
79168             if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
79169                 writeTrailingSemicolon();
79170             }
79171         }
79172         function emitIfStatement(node) {
79173             var openParenPos = emitTokenWithComment(95, node.pos, writeKeyword, node);
79174             writeSpace();
79175             emitTokenWithComment(20, openParenPos, writePunctuation, node);
79176             emitExpression(node.expression);
79177             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
79178             emitEmbeddedStatement(node, node.thenStatement);
79179             if (node.elseStatement) {
79180                 writeLineOrSpace(node);
79181                 emitTokenWithComment(87, node.thenStatement.end, writeKeyword, node);
79182                 if (node.elseStatement.kind === 227) {
79183                     writeSpace();
79184                     emit(node.elseStatement);
79185                 }
79186                 else {
79187                     emitEmbeddedStatement(node, node.elseStatement);
79188                 }
79189             }
79190         }
79191         function emitWhileClause(node, startPos) {
79192             var openParenPos = emitTokenWithComment(111, startPos, writeKeyword, node);
79193             writeSpace();
79194             emitTokenWithComment(20, openParenPos, writePunctuation, node);
79195             emitExpression(node.expression);
79196             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
79197         }
79198         function emitDoStatement(node) {
79199             emitTokenWithComment(86, node.pos, writeKeyword, node);
79200             emitEmbeddedStatement(node, node.statement);
79201             if (ts.isBlock(node.statement)) {
79202                 writeSpace();
79203             }
79204             else {
79205                 writeLineOrSpace(node);
79206             }
79207             emitWhileClause(node, node.statement.end);
79208             writeTrailingSemicolon();
79209         }
79210         function emitWhileStatement(node) {
79211             emitWhileClause(node, node.pos);
79212             emitEmbeddedStatement(node, node.statement);
79213         }
79214         function emitForStatement(node) {
79215             var openParenPos = emitTokenWithComment(93, node.pos, writeKeyword, node);
79216             writeSpace();
79217             var pos = emitTokenWithComment(20, openParenPos, writePunctuation, node);
79218             emitForBinding(node.initializer);
79219             pos = emitTokenWithComment(26, node.initializer ? node.initializer.end : pos, writePunctuation, node);
79220             emitExpressionWithLeadingSpace(node.condition);
79221             pos = emitTokenWithComment(26, node.condition ? node.condition.end : pos, writePunctuation, node);
79222             emitExpressionWithLeadingSpace(node.incrementor);
79223             emitTokenWithComment(21, node.incrementor ? node.incrementor.end : pos, writePunctuation, node);
79224             emitEmbeddedStatement(node, node.statement);
79225         }
79226         function emitForInStatement(node) {
79227             var openParenPos = emitTokenWithComment(93, node.pos, writeKeyword, node);
79228             writeSpace();
79229             emitTokenWithComment(20, openParenPos, writePunctuation, node);
79230             emitForBinding(node.initializer);
79231             writeSpace();
79232             emitTokenWithComment(97, node.initializer.end, writeKeyword, node);
79233             writeSpace();
79234             emitExpression(node.expression);
79235             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
79236             emitEmbeddedStatement(node, node.statement);
79237         }
79238         function emitForOfStatement(node) {
79239             var openParenPos = emitTokenWithComment(93, node.pos, writeKeyword, node);
79240             writeSpace();
79241             emitWithTrailingSpace(node.awaitModifier);
79242             emitTokenWithComment(20, openParenPos, writePunctuation, node);
79243             emitForBinding(node.initializer);
79244             writeSpace();
79245             emitTokenWithComment(152, node.initializer.end, writeKeyword, node);
79246             writeSpace();
79247             emitExpression(node.expression);
79248             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
79249             emitEmbeddedStatement(node, node.statement);
79250         }
79251         function emitForBinding(node) {
79252             if (node !== undefined) {
79253                 if (node.kind === 243) {
79254                     emit(node);
79255                 }
79256                 else {
79257                     emitExpression(node);
79258                 }
79259             }
79260         }
79261         function emitContinueStatement(node) {
79262             emitTokenWithComment(82, node.pos, writeKeyword, node);
79263             emitWithLeadingSpace(node.label);
79264             writeTrailingSemicolon();
79265         }
79266         function emitBreakStatement(node) {
79267             emitTokenWithComment(77, node.pos, writeKeyword, node);
79268             emitWithLeadingSpace(node.label);
79269             writeTrailingSemicolon();
79270         }
79271         function emitTokenWithComment(token, pos, writer, contextNode, indentLeading) {
79272             var node = ts.getParseTreeNode(contextNode);
79273             var isSimilarNode = node && node.kind === contextNode.kind;
79274             var startPos = pos;
79275             if (isSimilarNode && currentSourceFile) {
79276                 pos = ts.skipTrivia(currentSourceFile.text, pos);
79277             }
79278             if (emitLeadingCommentsOfPosition && isSimilarNode && contextNode.pos !== startPos) {
79279                 var needsIndent = indentLeading && currentSourceFile && !ts.positionsAreOnSameLine(startPos, pos, currentSourceFile);
79280                 if (needsIndent) {
79281                     increaseIndent();
79282                 }
79283                 emitLeadingCommentsOfPosition(startPos);
79284                 if (needsIndent) {
79285                     decreaseIndent();
79286                 }
79287             }
79288             pos = writeTokenText(token, writer, pos);
79289             if (emitTrailingCommentsOfPosition && isSimilarNode && contextNode.end !== pos) {
79290                 emitTrailingCommentsOfPosition(pos, true);
79291             }
79292             return pos;
79293         }
79294         function emitReturnStatement(node) {
79295             emitTokenWithComment(101, node.pos, writeKeyword, node);
79296             emitExpressionWithLeadingSpace(node.expression);
79297             writeTrailingSemicolon();
79298         }
79299         function emitWithStatement(node) {
79300             var openParenPos = emitTokenWithComment(112, node.pos, writeKeyword, node);
79301             writeSpace();
79302             emitTokenWithComment(20, openParenPos, writePunctuation, node);
79303             emitExpression(node.expression);
79304             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
79305             emitEmbeddedStatement(node, node.statement);
79306         }
79307         function emitSwitchStatement(node) {
79308             var openParenPos = emitTokenWithComment(103, node.pos, writeKeyword, node);
79309             writeSpace();
79310             emitTokenWithComment(20, openParenPos, writePunctuation, node);
79311             emitExpression(node.expression);
79312             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
79313             writeSpace();
79314             emit(node.caseBlock);
79315         }
79316         function emitLabeledStatement(node) {
79317             emit(node.label);
79318             emitTokenWithComment(58, node.label.end, writePunctuation, node);
79319             writeSpace();
79320             emit(node.statement);
79321         }
79322         function emitThrowStatement(node) {
79323             emitTokenWithComment(105, node.pos, writeKeyword, node);
79324             emitExpressionWithLeadingSpace(node.expression);
79325             writeTrailingSemicolon();
79326         }
79327         function emitTryStatement(node) {
79328             emitTokenWithComment(107, node.pos, writeKeyword, node);
79329             writeSpace();
79330             emit(node.tryBlock);
79331             if (node.catchClause) {
79332                 writeLineOrSpace(node);
79333                 emit(node.catchClause);
79334             }
79335             if (node.finallyBlock) {
79336                 writeLineOrSpace(node);
79337                 emitTokenWithComment(92, (node.catchClause || node.tryBlock).end, writeKeyword, node);
79338                 writeSpace();
79339                 emit(node.finallyBlock);
79340             }
79341         }
79342         function emitDebuggerStatement(node) {
79343             writeToken(83, node.pos, writeKeyword);
79344             writeTrailingSemicolon();
79345         }
79346         function emitVariableDeclaration(node) {
79347             emit(node.name);
79348             emit(node.exclamationToken);
79349             emitTypeAnnotation(node.type);
79350             emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node);
79351         }
79352         function emitVariableDeclarationList(node) {
79353             writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var");
79354             writeSpace();
79355             emitList(node, node.declarations, 528);
79356         }
79357         function emitFunctionDeclaration(node) {
79358             emitFunctionDeclarationOrExpression(node);
79359         }
79360         function emitFunctionDeclarationOrExpression(node) {
79361             emitDecorators(node, node.decorators);
79362             emitModifiers(node, node.modifiers);
79363             writeKeyword("function");
79364             emit(node.asteriskToken);
79365             writeSpace();
79366             emitIdentifierName(node.name);
79367             emitSignatureAndBody(node, emitSignatureHead);
79368         }
79369         function emitBlockCallback(_hint, body) {
79370             emitBlockFunctionBody(body);
79371         }
79372         function emitSignatureAndBody(node, emitSignatureHead) {
79373             var body = node.body;
79374             if (body) {
79375                 if (ts.isBlock(body)) {
79376                     var indentedFlag = ts.getEmitFlags(node) & 65536;
79377                     if (indentedFlag) {
79378                         increaseIndent();
79379                     }
79380                     pushNameGenerationScope(node);
79381                     ts.forEach(node.parameters, generateNames);
79382                     generateNames(node.body);
79383                     emitSignatureHead(node);
79384                     if (onEmitNode) {
79385                         onEmitNode(4, body, emitBlockCallback);
79386                     }
79387                     else {
79388                         emitBlockFunctionBody(body);
79389                     }
79390                     popNameGenerationScope(node);
79391                     if (indentedFlag) {
79392                         decreaseIndent();
79393                     }
79394                 }
79395                 else {
79396                     emitSignatureHead(node);
79397                     writeSpace();
79398                     emitExpression(body);
79399                 }
79400             }
79401             else {
79402                 emitSignatureHead(node);
79403                 writeTrailingSemicolon();
79404             }
79405         }
79406         function emitSignatureHead(node) {
79407             emitTypeParameters(node, node.typeParameters);
79408             emitParameters(node, node.parameters);
79409             emitTypeAnnotation(node.type);
79410         }
79411         function shouldEmitBlockFunctionBodyOnSingleLine(body) {
79412             if (ts.getEmitFlags(body) & 1) {
79413                 return true;
79414             }
79415             if (body.multiLine) {
79416                 return false;
79417             }
79418             if (!ts.nodeIsSynthesized(body) && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
79419                 return false;
79420             }
79421             if (getLeadingLineTerminatorCount(body, body.statements, 2)
79422                 || getClosingLineTerminatorCount(body, body.statements, 2)) {
79423                 return false;
79424             }
79425             var previousStatement;
79426             for (var _a = 0, _b = body.statements; _a < _b.length; _a++) {
79427                 var statement = _b[_a];
79428                 if (getSeparatingLineTerminatorCount(previousStatement, statement, 2) > 0) {
79429                     return false;
79430                 }
79431                 previousStatement = statement;
79432             }
79433             return true;
79434         }
79435         function emitBlockFunctionBody(body) {
79436             writeSpace();
79437             writePunctuation("{");
79438             increaseIndent();
79439             var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body)
79440                 ? emitBlockFunctionBodyOnSingleLine
79441                 : emitBlockFunctionBodyWorker;
79442             if (emitBodyWithDetachedComments) {
79443                 emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
79444             }
79445             else {
79446                 emitBlockFunctionBody(body);
79447             }
79448             decreaseIndent();
79449             writeToken(19, body.statements.end, writePunctuation, body);
79450         }
79451         function emitBlockFunctionBodyOnSingleLine(body) {
79452             emitBlockFunctionBodyWorker(body, true);
79453         }
79454         function emitBlockFunctionBodyWorker(body, emitBlockFunctionBodyOnSingleLine) {
79455             var statementOffset = emitPrologueDirectives(body.statements);
79456             var pos = writer.getTextPos();
79457             emitHelpers(body);
79458             if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) {
79459                 decreaseIndent();
79460                 emitList(body, body.statements, 768);
79461                 increaseIndent();
79462             }
79463             else {
79464                 emitList(body, body.statements, 1, statementOffset);
79465             }
79466         }
79467         function emitClassDeclaration(node) {
79468             emitClassDeclarationOrExpression(node);
79469         }
79470         function emitClassDeclarationOrExpression(node) {
79471             ts.forEach(node.members, generateMemberNames);
79472             emitDecorators(node, node.decorators);
79473             emitModifiers(node, node.modifiers);
79474             writeKeyword("class");
79475             if (node.name) {
79476                 writeSpace();
79477                 emitIdentifierName(node.name);
79478             }
79479             var indentedFlag = ts.getEmitFlags(node) & 65536;
79480             if (indentedFlag) {
79481                 increaseIndent();
79482             }
79483             emitTypeParameters(node, node.typeParameters);
79484             emitList(node, node.heritageClauses, 0);
79485             writeSpace();
79486             writePunctuation("{");
79487             emitList(node, node.members, 129);
79488             writePunctuation("}");
79489             if (indentedFlag) {
79490                 decreaseIndent();
79491             }
79492         }
79493         function emitInterfaceDeclaration(node) {
79494             emitDecorators(node, node.decorators);
79495             emitModifiers(node, node.modifiers);
79496             writeKeyword("interface");
79497             writeSpace();
79498             emit(node.name);
79499             emitTypeParameters(node, node.typeParameters);
79500             emitList(node, node.heritageClauses, 512);
79501             writeSpace();
79502             writePunctuation("{");
79503             emitList(node, node.members, 129);
79504             writePunctuation("}");
79505         }
79506         function emitTypeAliasDeclaration(node) {
79507             emitDecorators(node, node.decorators);
79508             emitModifiers(node, node.modifiers);
79509             writeKeyword("type");
79510             writeSpace();
79511             emit(node.name);
79512             emitTypeParameters(node, node.typeParameters);
79513             writeSpace();
79514             writePunctuation("=");
79515             writeSpace();
79516             emit(node.type);
79517             writeTrailingSemicolon();
79518         }
79519         function emitEnumDeclaration(node) {
79520             emitModifiers(node, node.modifiers);
79521             writeKeyword("enum");
79522             writeSpace();
79523             emit(node.name);
79524             writeSpace();
79525             writePunctuation("{");
79526             emitList(node, node.members, 145);
79527             writePunctuation("}");
79528         }
79529         function emitModuleDeclaration(node) {
79530             emitModifiers(node, node.modifiers);
79531             if (~node.flags & 1024) {
79532                 writeKeyword(node.flags & 16 ? "namespace" : "module");
79533                 writeSpace();
79534             }
79535             emit(node.name);
79536             var body = node.body;
79537             if (!body)
79538                 return writeTrailingSemicolon();
79539             while (body.kind === 249) {
79540                 writePunctuation(".");
79541                 emit(body.name);
79542                 body = body.body;
79543             }
79544             writeSpace();
79545             emit(body);
79546         }
79547         function emitModuleBlock(node) {
79548             pushNameGenerationScope(node);
79549             ts.forEach(node.statements, generateNames);
79550             emitBlockStatements(node, isEmptyBlock(node));
79551             popNameGenerationScope(node);
79552         }
79553         function emitCaseBlock(node) {
79554             emitTokenWithComment(18, node.pos, writePunctuation, node);
79555             emitList(node, node.clauses, 129);
79556             emitTokenWithComment(19, node.clauses.end, writePunctuation, node, true);
79557         }
79558         function emitImportEqualsDeclaration(node) {
79559             emitModifiers(node, node.modifiers);
79560             emitTokenWithComment(96, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node);
79561             writeSpace();
79562             emit(node.name);
79563             writeSpace();
79564             emitTokenWithComment(62, node.name.end, writePunctuation, node);
79565             writeSpace();
79566             emitModuleReference(node.moduleReference);
79567             writeTrailingSemicolon();
79568         }
79569         function emitModuleReference(node) {
79570             if (node.kind === 75) {
79571                 emitExpression(node);
79572             }
79573             else {
79574                 emit(node);
79575             }
79576         }
79577         function emitImportDeclaration(node) {
79578             emitModifiers(node, node.modifiers);
79579             emitTokenWithComment(96, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node);
79580             writeSpace();
79581             if (node.importClause) {
79582                 emit(node.importClause);
79583                 writeSpace();
79584                 emitTokenWithComment(149, node.importClause.end, writeKeyword, node);
79585                 writeSpace();
79586             }
79587             emitExpression(node.moduleSpecifier);
79588             writeTrailingSemicolon();
79589         }
79590         function emitImportClause(node) {
79591             if (node.isTypeOnly) {
79592                 emitTokenWithComment(145, node.pos, writeKeyword, node);
79593                 writeSpace();
79594             }
79595             emit(node.name);
79596             if (node.name && node.namedBindings) {
79597                 emitTokenWithComment(27, node.name.end, writePunctuation, node);
79598                 writeSpace();
79599             }
79600             emit(node.namedBindings);
79601         }
79602         function emitNamespaceImport(node) {
79603             var asPos = emitTokenWithComment(41, node.pos, writePunctuation, node);
79604             writeSpace();
79605             emitTokenWithComment(123, asPos, writeKeyword, node);
79606             writeSpace();
79607             emit(node.name);
79608         }
79609         function emitNamedImports(node) {
79610             emitNamedImportsOrExports(node);
79611         }
79612         function emitImportSpecifier(node) {
79613             emitImportOrExportSpecifier(node);
79614         }
79615         function emitExportAssignment(node) {
79616             var nextPos = emitTokenWithComment(89, node.pos, writeKeyword, node);
79617             writeSpace();
79618             if (node.isExportEquals) {
79619                 emitTokenWithComment(62, nextPos, writeOperator, node);
79620             }
79621             else {
79622                 emitTokenWithComment(84, nextPos, writeKeyword, node);
79623             }
79624             writeSpace();
79625             emitExpression(node.expression);
79626             writeTrailingSemicolon();
79627         }
79628         function emitExportDeclaration(node) {
79629             var nextPos = emitTokenWithComment(89, node.pos, writeKeyword, node);
79630             writeSpace();
79631             if (node.isTypeOnly) {
79632                 nextPos = emitTokenWithComment(145, nextPos, writeKeyword, node);
79633                 writeSpace();
79634             }
79635             if (node.exportClause) {
79636                 emit(node.exportClause);
79637             }
79638             else {
79639                 nextPos = emitTokenWithComment(41, nextPos, writePunctuation, node);
79640             }
79641             if (node.moduleSpecifier) {
79642                 writeSpace();
79643                 var fromPos = node.exportClause ? node.exportClause.end : nextPos;
79644                 emitTokenWithComment(149, fromPos, writeKeyword, node);
79645                 writeSpace();
79646                 emitExpression(node.moduleSpecifier);
79647             }
79648             writeTrailingSemicolon();
79649         }
79650         function emitNamespaceExportDeclaration(node) {
79651             var nextPos = emitTokenWithComment(89, node.pos, writeKeyword, node);
79652             writeSpace();
79653             nextPos = emitTokenWithComment(123, nextPos, writeKeyword, node);
79654             writeSpace();
79655             nextPos = emitTokenWithComment(136, nextPos, writeKeyword, node);
79656             writeSpace();
79657             emit(node.name);
79658             writeTrailingSemicolon();
79659         }
79660         function emitNamespaceExport(node) {
79661             var asPos = emitTokenWithComment(41, node.pos, writePunctuation, node);
79662             writeSpace();
79663             emitTokenWithComment(123, asPos, writeKeyword, node);
79664             writeSpace();
79665             emit(node.name);
79666         }
79667         function emitNamedExports(node) {
79668             emitNamedImportsOrExports(node);
79669         }
79670         function emitExportSpecifier(node) {
79671             emitImportOrExportSpecifier(node);
79672         }
79673         function emitNamedImportsOrExports(node) {
79674             writePunctuation("{");
79675             emitList(node, node.elements, 525136);
79676             writePunctuation("}");
79677         }
79678         function emitImportOrExportSpecifier(node) {
79679             if (node.propertyName) {
79680                 emit(node.propertyName);
79681                 writeSpace();
79682                 emitTokenWithComment(123, node.propertyName.end, writeKeyword, node);
79683                 writeSpace();
79684             }
79685             emit(node.name);
79686         }
79687         function emitExternalModuleReference(node) {
79688             writeKeyword("require");
79689             writePunctuation("(");
79690             emitExpression(node.expression);
79691             writePunctuation(")");
79692         }
79693         function emitJsxElement(node) {
79694             emit(node.openingElement);
79695             emitList(node, node.children, 262144);
79696             emit(node.closingElement);
79697         }
79698         function emitJsxSelfClosingElement(node) {
79699             writePunctuation("<");
79700             emitJsxTagName(node.tagName);
79701             emitTypeArguments(node, node.typeArguments);
79702             writeSpace();
79703             emit(node.attributes);
79704             writePunctuation("/>");
79705         }
79706         function emitJsxFragment(node) {
79707             emit(node.openingFragment);
79708             emitList(node, node.children, 262144);
79709             emit(node.closingFragment);
79710         }
79711         function emitJsxOpeningElementOrFragment(node) {
79712             writePunctuation("<");
79713             if (ts.isJsxOpeningElement(node)) {
79714                 var indented = writeLineSeparatorsAndIndentBefore(node.tagName, node);
79715                 emitJsxTagName(node.tagName);
79716                 emitTypeArguments(node, node.typeArguments);
79717                 if (node.attributes.properties && node.attributes.properties.length > 0) {
79718                     writeSpace();
79719                 }
79720                 emit(node.attributes);
79721                 writeLineSeparatorsAfter(node.attributes, node);
79722                 decreaseIndentIf(indented);
79723             }
79724             writePunctuation(">");
79725         }
79726         function emitJsxText(node) {
79727             writer.writeLiteral(node.text);
79728         }
79729         function emitJsxClosingElementOrFragment(node) {
79730             writePunctuation("</");
79731             if (ts.isJsxClosingElement(node)) {
79732                 emitJsxTagName(node.tagName);
79733             }
79734             writePunctuation(">");
79735         }
79736         function emitJsxAttributes(node) {
79737             emitList(node, node.properties, 262656);
79738         }
79739         function emitJsxAttribute(node) {
79740             emit(node.name);
79741             emitNodeWithPrefix("=", writePunctuation, node.initializer, emitJsxAttributeValue);
79742         }
79743         function emitJsxSpreadAttribute(node) {
79744             writePunctuation("{...");
79745             emitExpression(node.expression);
79746             writePunctuation("}");
79747         }
79748         function emitJsxExpression(node) {
79749             if (node.expression) {
79750                 writePunctuation("{");
79751                 emit(node.dotDotDotToken);
79752                 emitExpression(node.expression);
79753                 writePunctuation("}");
79754             }
79755         }
79756         function emitJsxTagName(node) {
79757             if (node.kind === 75) {
79758                 emitExpression(node);
79759             }
79760             else {
79761                 emit(node);
79762             }
79763         }
79764         function emitCaseClause(node) {
79765             emitTokenWithComment(78, node.pos, writeKeyword, node);
79766             writeSpace();
79767             emitExpression(node.expression);
79768             emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end);
79769         }
79770         function emitDefaultClause(node) {
79771             var pos = emitTokenWithComment(84, node.pos, writeKeyword, node);
79772             emitCaseOrDefaultClauseRest(node, node.statements, pos);
79773         }
79774         function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) {
79775             var emitAsSingleStatement = statements.length === 1 &&
79776                 (ts.nodeIsSynthesized(parentNode) ||
79777                     ts.nodeIsSynthesized(statements[0]) ||
79778                     ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile));
79779             var format = 163969;
79780             if (emitAsSingleStatement) {
79781                 writeToken(58, colonPos, writePunctuation, parentNode);
79782                 writeSpace();
79783                 format &= ~(1 | 128);
79784             }
79785             else {
79786                 emitTokenWithComment(58, colonPos, writePunctuation, parentNode);
79787             }
79788             emitList(parentNode, statements, format);
79789         }
79790         function emitHeritageClause(node) {
79791             writeSpace();
79792             writeTokenText(node.token, writeKeyword);
79793             writeSpace();
79794             emitList(node, node.types, 528);
79795         }
79796         function emitCatchClause(node) {
79797             var openParenPos = emitTokenWithComment(79, node.pos, writeKeyword, node);
79798             writeSpace();
79799             if (node.variableDeclaration) {
79800                 emitTokenWithComment(20, openParenPos, writePunctuation, node);
79801                 emit(node.variableDeclaration);
79802                 emitTokenWithComment(21, node.variableDeclaration.end, writePunctuation, node);
79803                 writeSpace();
79804             }
79805             emit(node.block);
79806         }
79807         function emitPropertyAssignment(node) {
79808             emit(node.name);
79809             writePunctuation(":");
79810             writeSpace();
79811             var initializer = node.initializer;
79812             if (emitTrailingCommentsOfPosition && (ts.getEmitFlags(initializer) & 512) === 0) {
79813                 var commentRange = ts.getCommentRange(initializer);
79814                 emitTrailingCommentsOfPosition(commentRange.pos);
79815             }
79816             emitExpression(initializer);
79817         }
79818         function emitShorthandPropertyAssignment(node) {
79819             emit(node.name);
79820             if (node.objectAssignmentInitializer) {
79821                 writeSpace();
79822                 writePunctuation("=");
79823                 writeSpace();
79824                 emitExpression(node.objectAssignmentInitializer);
79825             }
79826         }
79827         function emitSpreadAssignment(node) {
79828             if (node.expression) {
79829                 emitTokenWithComment(25, node.pos, writePunctuation, node);
79830                 emitExpression(node.expression);
79831             }
79832         }
79833         function emitEnumMember(node) {
79834             emit(node.name);
79835             emitInitializer(node.initializer, node.name.end, node);
79836         }
79837         function emitJSDoc(node) {
79838             write("/**");
79839             if (node.comment) {
79840                 var lines = node.comment.split(/\r\n?|\n/g);
79841                 for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) {
79842                     var line = lines_2[_a];
79843                     writeLine();
79844                     writeSpace();
79845                     writePunctuation("*");
79846                     writeSpace();
79847                     write(line);
79848                 }
79849             }
79850             if (node.tags) {
79851                 if (node.tags.length === 1 && node.tags[0].kind === 320 && !node.comment) {
79852                     writeSpace();
79853                     emit(node.tags[0]);
79854                 }
79855                 else {
79856                     emitList(node, node.tags, 33);
79857                 }
79858             }
79859             writeSpace();
79860             write("*/");
79861         }
79862         function emitJSDocSimpleTypedTag(tag) {
79863             emitJSDocTagName(tag.tagName);
79864             emitJSDocTypeExpression(tag.typeExpression);
79865             emitJSDocComment(tag.comment);
79866         }
79867         function emitJSDocHeritageTag(tag) {
79868             emitJSDocTagName(tag.tagName);
79869             writeSpace();
79870             writePunctuation("{");
79871             emit(tag.class);
79872             writePunctuation("}");
79873             emitJSDocComment(tag.comment);
79874         }
79875         function emitJSDocTemplateTag(tag) {
79876             emitJSDocTagName(tag.tagName);
79877             emitJSDocTypeExpression(tag.constraint);
79878             writeSpace();
79879             emitList(tag, tag.typeParameters, 528);
79880             emitJSDocComment(tag.comment);
79881         }
79882         function emitJSDocTypedefTag(tag) {
79883             emitJSDocTagName(tag.tagName);
79884             if (tag.typeExpression) {
79885                 if (tag.typeExpression.kind === 294) {
79886                     emitJSDocTypeExpression(tag.typeExpression);
79887                 }
79888                 else {
79889                     writeSpace();
79890                     writePunctuation("{");
79891                     write("Object");
79892                     if (tag.typeExpression.isArrayType) {
79893                         writePunctuation("[");
79894                         writePunctuation("]");
79895                     }
79896                     writePunctuation("}");
79897                 }
79898             }
79899             if (tag.fullName) {
79900                 writeSpace();
79901                 emit(tag.fullName);
79902             }
79903             emitJSDocComment(tag.comment);
79904             if (tag.typeExpression && tag.typeExpression.kind === 304) {
79905                 emitJSDocTypeLiteral(tag.typeExpression);
79906             }
79907         }
79908         function emitJSDocCallbackTag(tag) {
79909             emitJSDocTagName(tag.tagName);
79910             if (tag.name) {
79911                 writeSpace();
79912                 emit(tag.name);
79913             }
79914             emitJSDocComment(tag.comment);
79915             emitJSDocSignature(tag.typeExpression);
79916         }
79917         function emitJSDocSimpleTag(tag) {
79918             emitJSDocTagName(tag.tagName);
79919             emitJSDocComment(tag.comment);
79920         }
79921         function emitJSDocTypeLiteral(lit) {
79922             emitList(lit, ts.createNodeArray(lit.jsDocPropertyTags), 33);
79923         }
79924         function emitJSDocSignature(sig) {
79925             if (sig.typeParameters) {
79926                 emitList(sig, ts.createNodeArray(sig.typeParameters), 33);
79927             }
79928             if (sig.parameters) {
79929                 emitList(sig, ts.createNodeArray(sig.parameters), 33);
79930             }
79931             if (sig.type) {
79932                 writeLine();
79933                 writeSpace();
79934                 writePunctuation("*");
79935                 writeSpace();
79936                 emit(sig.type);
79937             }
79938         }
79939         function emitJSDocPropertyLikeTag(param) {
79940             emitJSDocTagName(param.tagName);
79941             emitJSDocTypeExpression(param.typeExpression);
79942             writeSpace();
79943             if (param.isBracketed) {
79944                 writePunctuation("[");
79945             }
79946             emit(param.name);
79947             if (param.isBracketed) {
79948                 writePunctuation("]");
79949             }
79950             emitJSDocComment(param.comment);
79951         }
79952         function emitJSDocTagName(tagName) {
79953             writePunctuation("@");
79954             emit(tagName);
79955         }
79956         function emitJSDocComment(comment) {
79957             if (comment) {
79958                 writeSpace();
79959                 write(comment);
79960             }
79961         }
79962         function emitJSDocTypeExpression(typeExpression) {
79963             if (typeExpression) {
79964                 writeSpace();
79965                 writePunctuation("{");
79966                 emit(typeExpression.type);
79967                 writePunctuation("}");
79968             }
79969         }
79970         function emitSourceFile(node) {
79971             writeLine();
79972             var statements = node.statements;
79973             if (emitBodyWithDetachedComments) {
79974                 var shouldEmitDetachedComment = statements.length === 0 ||
79975                     !ts.isPrologueDirective(statements[0]) ||
79976                     ts.nodeIsSynthesized(statements[0]);
79977                 if (shouldEmitDetachedComment) {
79978                     emitBodyWithDetachedComments(node, statements, emitSourceFileWorker);
79979                     return;
79980                 }
79981             }
79982             emitSourceFileWorker(node);
79983         }
79984         function emitSyntheticTripleSlashReferencesIfNeeded(node) {
79985             emitTripleSlashDirectives(!!node.hasNoDefaultLib, node.syntheticFileReferences || [], node.syntheticTypeReferences || [], node.syntheticLibReferences || []);
79986             for (var _a = 0, _b = node.prepends; _a < _b.length; _a++) {
79987                 var prepend = _b[_a];
79988                 if (ts.isUnparsedSource(prepend) && prepend.syntheticReferences) {
79989                     for (var _c = 0, _d = prepend.syntheticReferences; _c < _d.length; _c++) {
79990                         var ref = _d[_c];
79991                         emit(ref);
79992                         writeLine();
79993                     }
79994                 }
79995             }
79996         }
79997         function emitTripleSlashDirectivesIfNeeded(node) {
79998             if (node.isDeclarationFile)
79999                 emitTripleSlashDirectives(node.hasNoDefaultLib, node.referencedFiles, node.typeReferenceDirectives, node.libReferenceDirectives);
80000         }
80001         function emitTripleSlashDirectives(hasNoDefaultLib, files, types, libs) {
80002             if (hasNoDefaultLib) {
80003                 var pos = writer.getTextPos();
80004                 writeComment("/// <reference no-default-lib=\"true\"/>");
80005                 if (bundleFileInfo)
80006                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" });
80007                 writeLine();
80008             }
80009             if (currentSourceFile && currentSourceFile.moduleName) {
80010                 writeComment("/// <amd-module name=\"" + currentSourceFile.moduleName + "\" />");
80011                 writeLine();
80012             }
80013             if (currentSourceFile && currentSourceFile.amdDependencies) {
80014                 for (var _a = 0, _b = currentSourceFile.amdDependencies; _a < _b.length; _a++) {
80015                     var dep = _b[_a];
80016                     if (dep.name) {
80017                         writeComment("/// <amd-dependency name=\"" + dep.name + "\" path=\"" + dep.path + "\" />");
80018                     }
80019                     else {
80020                         writeComment("/// <amd-dependency path=\"" + dep.path + "\" />");
80021                     }
80022                     writeLine();
80023                 }
80024             }
80025             for (var _c = 0, files_1 = files; _c < files_1.length; _c++) {
80026                 var directive = files_1[_c];
80027                 var pos = writer.getTextPos();
80028                 writeComment("/// <reference path=\"" + directive.fileName + "\" />");
80029                 if (bundleFileInfo)
80030                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference", data: directive.fileName });
80031                 writeLine();
80032             }
80033             for (var _d = 0, types_22 = types; _d < types_22.length; _d++) {
80034                 var directive = types_22[_d];
80035                 var pos = writer.getTextPos();
80036                 writeComment("/// <reference types=\"" + directive.fileName + "\" />");
80037                 if (bundleFileInfo)
80038                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "type", data: directive.fileName });
80039                 writeLine();
80040             }
80041             for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) {
80042                 var directive = libs_1[_e];
80043                 var pos = writer.getTextPos();
80044                 writeComment("/// <reference lib=\"" + directive.fileName + "\" />");
80045                 if (bundleFileInfo)
80046                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib", data: directive.fileName });
80047                 writeLine();
80048             }
80049         }
80050         function emitSourceFileWorker(node) {
80051             var statements = node.statements;
80052             pushNameGenerationScope(node);
80053             ts.forEach(node.statements, generateNames);
80054             emitHelpers(node);
80055             var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); });
80056             emitTripleSlashDirectivesIfNeeded(node);
80057             emitList(node, statements, 1, index === -1 ? statements.length : index);
80058             popNameGenerationScope(node);
80059         }
80060         function emitPartiallyEmittedExpression(node) {
80061             emitExpression(node.expression);
80062         }
80063         function emitCommaList(node) {
80064             emitExpressionList(node, node.elements, 528);
80065         }
80066         function emitPrologueDirectives(statements, sourceFile, seenPrologueDirectives, recordBundleFileSection) {
80067             var needsToSetSourceFile = !!sourceFile;
80068             for (var i = 0; i < statements.length; i++) {
80069                 var statement = statements[i];
80070                 if (ts.isPrologueDirective(statement)) {
80071                     var shouldEmitPrologueDirective = seenPrologueDirectives ? !seenPrologueDirectives.has(statement.expression.text) : true;
80072                     if (shouldEmitPrologueDirective) {
80073                         if (needsToSetSourceFile) {
80074                             needsToSetSourceFile = false;
80075                             setSourceFile(sourceFile);
80076                         }
80077                         writeLine();
80078                         var pos = writer.getTextPos();
80079                         emit(statement);
80080                         if (recordBundleFileSection && bundleFileInfo)
80081                             bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue", data: statement.expression.text });
80082                         if (seenPrologueDirectives) {
80083                             seenPrologueDirectives.set(statement.expression.text, true);
80084                         }
80085                     }
80086                 }
80087                 else {
80088                     return i;
80089                 }
80090             }
80091             return statements.length;
80092         }
80093         function emitUnparsedPrologues(prologues, seenPrologueDirectives) {
80094             for (var _a = 0, prologues_1 = prologues; _a < prologues_1.length; _a++) {
80095                 var prologue = prologues_1[_a];
80096                 if (!seenPrologueDirectives.has(prologue.data)) {
80097                     writeLine();
80098                     var pos = writer.getTextPos();
80099                     emit(prologue);
80100                     if (bundleFileInfo)
80101                         bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue", data: prologue.data });
80102                     if (seenPrologueDirectives) {
80103                         seenPrologueDirectives.set(prologue.data, true);
80104                     }
80105                 }
80106             }
80107         }
80108         function emitPrologueDirectivesIfNeeded(sourceFileOrBundle) {
80109             if (ts.isSourceFile(sourceFileOrBundle)) {
80110                 emitPrologueDirectives(sourceFileOrBundle.statements, sourceFileOrBundle);
80111             }
80112             else {
80113                 var seenPrologueDirectives = ts.createMap();
80114                 for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) {
80115                     var prepend = _b[_a];
80116                     emitUnparsedPrologues(prepend.prologues, seenPrologueDirectives);
80117                 }
80118                 for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) {
80119                     var sourceFile = _d[_c];
80120                     emitPrologueDirectives(sourceFile.statements, sourceFile, seenPrologueDirectives, true);
80121                 }
80122                 setSourceFile(undefined);
80123             }
80124         }
80125         function getPrologueDirectivesFromBundledSourceFiles(bundle) {
80126             var seenPrologueDirectives = ts.createMap();
80127             var prologues;
80128             for (var index = 0; index < bundle.sourceFiles.length; index++) {
80129                 var sourceFile = bundle.sourceFiles[index];
80130                 var directives = void 0;
80131                 var end = 0;
80132                 for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) {
80133                     var statement = _b[_a];
80134                     if (!ts.isPrologueDirective(statement))
80135                         break;
80136                     if (seenPrologueDirectives.has(statement.expression.text))
80137                         continue;
80138                     seenPrologueDirectives.set(statement.expression.text, true);
80139                     (directives || (directives = [])).push({
80140                         pos: statement.pos,
80141                         end: statement.end,
80142                         expression: {
80143                             pos: statement.expression.pos,
80144                             end: statement.expression.end,
80145                             text: statement.expression.text
80146                         }
80147                     });
80148                     end = end < statement.end ? statement.end : end;
80149                 }
80150                 if (directives)
80151                     (prologues || (prologues = [])).push({ file: index, text: sourceFile.text.substring(0, end), directives: directives });
80152             }
80153             return prologues;
80154         }
80155         function emitShebangIfNeeded(sourceFileOrBundle) {
80156             if (ts.isSourceFile(sourceFileOrBundle) || ts.isUnparsedSource(sourceFileOrBundle)) {
80157                 var shebang = ts.getShebang(sourceFileOrBundle.text);
80158                 if (shebang) {
80159                     writeComment(shebang);
80160                     writeLine();
80161                     return true;
80162                 }
80163             }
80164             else {
80165                 for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) {
80166                     var prepend = _b[_a];
80167                     ts.Debug.assertNode(prepend, ts.isUnparsedSource);
80168                     if (emitShebangIfNeeded(prepend)) {
80169                         return true;
80170                     }
80171                 }
80172                 for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) {
80173                     var sourceFile = _d[_c];
80174                     if (emitShebangIfNeeded(sourceFile)) {
80175                         return true;
80176                     }
80177                 }
80178             }
80179         }
80180         function emitNodeWithWriter(node, writer) {
80181             if (!node)
80182                 return;
80183             var savedWrite = write;
80184             write = writer;
80185             emit(node);
80186             write = savedWrite;
80187         }
80188         function emitModifiers(node, modifiers) {
80189             if (modifiers && modifiers.length) {
80190                 emitList(node, modifiers, 262656);
80191                 writeSpace();
80192             }
80193         }
80194         function emitTypeAnnotation(node) {
80195             if (node) {
80196                 writePunctuation(":");
80197                 writeSpace();
80198                 emit(node);
80199             }
80200         }
80201         function emitInitializer(node, equalCommentStartPos, container) {
80202             if (node) {
80203                 writeSpace();
80204                 emitTokenWithComment(62, equalCommentStartPos, writeOperator, container);
80205                 writeSpace();
80206                 emitExpression(node);
80207             }
80208         }
80209         function emitNodeWithPrefix(prefix, prefixWriter, node, emit) {
80210             if (node) {
80211                 prefixWriter(prefix);
80212                 emit(node);
80213             }
80214         }
80215         function emitWithLeadingSpace(node) {
80216             if (node) {
80217                 writeSpace();
80218                 emit(node);
80219             }
80220         }
80221         function emitExpressionWithLeadingSpace(node) {
80222             if (node) {
80223                 writeSpace();
80224                 emitExpression(node);
80225             }
80226         }
80227         function emitWithTrailingSpace(node) {
80228             if (node) {
80229                 emit(node);
80230                 writeSpace();
80231             }
80232         }
80233         function emitEmbeddedStatement(parent, node) {
80234             if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1) {
80235                 writeSpace();
80236                 emit(node);
80237             }
80238             else {
80239                 writeLine();
80240                 increaseIndent();
80241                 if (ts.isEmptyStatement(node)) {
80242                     pipelineEmit(5, node);
80243                 }
80244                 else {
80245                     emit(node);
80246                 }
80247                 decreaseIndent();
80248             }
80249         }
80250         function emitDecorators(parentNode, decorators) {
80251             emitList(parentNode, decorators, 2146305);
80252         }
80253         function emitTypeArguments(parentNode, typeArguments) {
80254             emitList(parentNode, typeArguments, 53776);
80255         }
80256         function emitTypeParameters(parentNode, typeParameters) {
80257             if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) {
80258                 return emitTypeArguments(parentNode, parentNode.typeArguments);
80259             }
80260             emitList(parentNode, typeParameters, 53776);
80261         }
80262         function emitParameters(parentNode, parameters) {
80263             emitList(parentNode, parameters, 2576);
80264         }
80265         function canEmitSimpleArrowHead(parentNode, parameters) {
80266             var parameter = ts.singleOrUndefined(parameters);
80267             return parameter
80268                 && parameter.pos === parentNode.pos
80269                 && ts.isArrowFunction(parentNode)
80270                 && !parentNode.type
80271                 && !ts.some(parentNode.decorators)
80272                 && !ts.some(parentNode.modifiers)
80273                 && !ts.some(parentNode.typeParameters)
80274                 && !ts.some(parameter.decorators)
80275                 && !ts.some(parameter.modifiers)
80276                 && !parameter.dotDotDotToken
80277                 && !parameter.questionToken
80278                 && !parameter.type
80279                 && !parameter.initializer
80280                 && ts.isIdentifier(parameter.name);
80281         }
80282         function emitParametersForArrow(parentNode, parameters) {
80283             if (canEmitSimpleArrowHead(parentNode, parameters)) {
80284                 emitList(parentNode, parameters, 2576 & ~2048);
80285             }
80286             else {
80287                 emitParameters(parentNode, parameters);
80288             }
80289         }
80290         function emitParametersForIndexSignature(parentNode, parameters) {
80291             emitList(parentNode, parameters, 8848);
80292         }
80293         function emitList(parentNode, children, format, start, count) {
80294             emitNodeList(emit, parentNode, children, format, start, count);
80295         }
80296         function emitExpressionList(parentNode, children, format, start, count) {
80297             emitNodeList(emitExpression, parentNode, children, format, start, count);
80298         }
80299         function writeDelimiter(format) {
80300             switch (format & 60) {
80301                 case 0:
80302                     break;
80303                 case 16:
80304                     writePunctuation(",");
80305                     break;
80306                 case 4:
80307                     writeSpace();
80308                     writePunctuation("|");
80309                     break;
80310                 case 32:
80311                     writeSpace();
80312                     writePunctuation("*");
80313                     writeSpace();
80314                     break;
80315                 case 8:
80316                     writeSpace();
80317                     writePunctuation("&");
80318                     break;
80319             }
80320         }
80321         function emitNodeList(emit, parentNode, children, format, start, count) {
80322             if (start === void 0) { start = 0; }
80323             if (count === void 0) { count = children ? children.length - start : 0; }
80324             var isUndefined = children === undefined;
80325             if (isUndefined && format & 16384) {
80326                 return;
80327             }
80328             var isEmpty = children === undefined || start >= children.length || count === 0;
80329             if (isEmpty && format & 32768) {
80330                 if (onBeforeEmitNodeArray) {
80331                     onBeforeEmitNodeArray(children);
80332                 }
80333                 if (onAfterEmitNodeArray) {
80334                     onAfterEmitNodeArray(children);
80335                 }
80336                 return;
80337             }
80338             if (format & 15360) {
80339                 writePunctuation(getOpeningBracket(format));
80340                 if (isEmpty && !isUndefined) {
80341                     emitTrailingCommentsOfPosition(children.pos, true);
80342                 }
80343             }
80344             if (onBeforeEmitNodeArray) {
80345                 onBeforeEmitNodeArray(children);
80346             }
80347             if (isEmpty) {
80348                 if (format & 1 && !(preserveSourceNewlines && ts.rangeIsOnSingleLine(parentNode, currentSourceFile))) {
80349                     writeLine();
80350                 }
80351                 else if (format & 256 && !(format & 524288)) {
80352                     writeSpace();
80353                 }
80354             }
80355             else {
80356                 var mayEmitInterveningComments = (format & 262144) === 0;
80357                 var shouldEmitInterveningComments = mayEmitInterveningComments;
80358                 var leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children, format);
80359                 if (leadingLineTerminatorCount) {
80360                     writeLine(leadingLineTerminatorCount);
80361                     shouldEmitInterveningComments = false;
80362                 }
80363                 else if (format & 256) {
80364                     writeSpace();
80365                 }
80366                 if (format & 128) {
80367                     increaseIndent();
80368                 }
80369                 var previousSibling = void 0;
80370                 var previousSourceFileTextKind = void 0;
80371                 var shouldDecreaseIndentAfterEmit = false;
80372                 for (var i = 0; i < count; i++) {
80373                     var child = children[start + i];
80374                     if (format & 32) {
80375                         writeLine();
80376                         writeDelimiter(format);
80377                     }
80378                     else if (previousSibling) {
80379                         if (format & 60 && previousSibling.end !== parentNode.end) {
80380                             emitLeadingCommentsOfPosition(previousSibling.end);
80381                         }
80382                         writeDelimiter(format);
80383                         recordBundleFileInternalSectionEnd(previousSourceFileTextKind);
80384                         var separatingLineTerminatorCount = getSeparatingLineTerminatorCount(previousSibling, child, format);
80385                         if (separatingLineTerminatorCount > 0) {
80386                             if ((format & (3 | 128)) === 0) {
80387                                 increaseIndent();
80388                                 shouldDecreaseIndentAfterEmit = true;
80389                             }
80390                             writeLine(separatingLineTerminatorCount);
80391                             shouldEmitInterveningComments = false;
80392                         }
80393                         else if (previousSibling && format & 512) {
80394                             writeSpace();
80395                         }
80396                     }
80397                     previousSourceFileTextKind = recordBundleFileInternalSectionStart(child);
80398                     if (shouldEmitInterveningComments) {
80399                         if (emitTrailingCommentsOfPosition) {
80400                             var commentRange = ts.getCommentRange(child);
80401                             emitTrailingCommentsOfPosition(commentRange.pos);
80402                         }
80403                     }
80404                     else {
80405                         shouldEmitInterveningComments = mayEmitInterveningComments;
80406                     }
80407                     emit(child);
80408                     if (shouldDecreaseIndentAfterEmit) {
80409                         decreaseIndent();
80410                         shouldDecreaseIndentAfterEmit = false;
80411                     }
80412                     previousSibling = child;
80413                 }
80414                 var hasTrailingComma = (format & 64) && children.hasTrailingComma;
80415                 if (format & 16 && hasTrailingComma) {
80416                     writePunctuation(",");
80417                 }
80418                 if (previousSibling && format & 60 && previousSibling.end !== parentNode.end && !(ts.getEmitFlags(previousSibling) & 1024)) {
80419                     emitLeadingCommentsOfPosition(previousSibling.end);
80420                 }
80421                 if (format & 128) {
80422                     decreaseIndent();
80423                 }
80424                 recordBundleFileInternalSectionEnd(previousSourceFileTextKind);
80425                 var closingLineTerminatorCount = getClosingLineTerminatorCount(parentNode, children, format);
80426                 if (closingLineTerminatorCount) {
80427                     writeLine(closingLineTerminatorCount);
80428                 }
80429                 else if (format & (2097152 | 256)) {
80430                     writeSpace();
80431                 }
80432             }
80433             if (onAfterEmitNodeArray) {
80434                 onAfterEmitNodeArray(children);
80435             }
80436             if (format & 15360) {
80437                 if (isEmpty && !isUndefined) {
80438                     emitLeadingCommentsOfPosition(children.end);
80439                 }
80440                 writePunctuation(getClosingBracket(format));
80441             }
80442         }
80443         function writeLiteral(s) {
80444             writer.writeLiteral(s);
80445         }
80446         function writeStringLiteral(s) {
80447             writer.writeStringLiteral(s);
80448         }
80449         function writeBase(s) {
80450             writer.write(s);
80451         }
80452         function writeSymbol(s, sym) {
80453             writer.writeSymbol(s, sym);
80454         }
80455         function writePunctuation(s) {
80456             writer.writePunctuation(s);
80457         }
80458         function writeTrailingSemicolon() {
80459             writer.writeTrailingSemicolon(";");
80460         }
80461         function writeKeyword(s) {
80462             writer.writeKeyword(s);
80463         }
80464         function writeOperator(s) {
80465             writer.writeOperator(s);
80466         }
80467         function writeParameter(s) {
80468             writer.writeParameter(s);
80469         }
80470         function writeComment(s) {
80471             writer.writeComment(s);
80472         }
80473         function writeSpace() {
80474             writer.writeSpace(" ");
80475         }
80476         function writeProperty(s) {
80477             writer.writeProperty(s);
80478         }
80479         function writeLine(count) {
80480             if (count === void 0) { count = 1; }
80481             for (var i = 0; i < count; i++) {
80482                 writer.writeLine(i > 0);
80483             }
80484         }
80485         function increaseIndent() {
80486             writer.increaseIndent();
80487         }
80488         function decreaseIndent() {
80489             writer.decreaseIndent();
80490         }
80491         function writeToken(token, pos, writer, contextNode) {
80492             return !sourceMapsDisabled
80493                 ? emitTokenWithSourceMap(contextNode, token, writer, pos, writeTokenText)
80494                 : writeTokenText(token, writer, pos);
80495         }
80496         function writeTokenNode(node, writer) {
80497             if (onBeforeEmitToken) {
80498                 onBeforeEmitToken(node);
80499             }
80500             writer(ts.tokenToString(node.kind));
80501             if (onAfterEmitToken) {
80502                 onAfterEmitToken(node);
80503             }
80504         }
80505         function writeTokenText(token, writer, pos) {
80506             var tokenString = ts.tokenToString(token);
80507             writer(tokenString);
80508             return pos < 0 ? pos : pos + tokenString.length;
80509         }
80510         function writeLineOrSpace(node) {
80511             if (ts.getEmitFlags(node) & 1) {
80512                 writeSpace();
80513             }
80514             else {
80515                 writeLine();
80516             }
80517         }
80518         function writeLines(text) {
80519             var lines = text.split(/\r\n?|\n/g);
80520             var indentation = ts.guessIndentation(lines);
80521             for (var _a = 0, lines_3 = lines; _a < lines_3.length; _a++) {
80522                 var lineText = lines_3[_a];
80523                 var line = indentation ? lineText.slice(indentation) : lineText;
80524                 if (line.length) {
80525                     writeLine();
80526                     write(line);
80527                 }
80528             }
80529         }
80530         function writeLinesAndIndent(lineCount, writeSpaceIfNotIndenting) {
80531             if (lineCount) {
80532                 increaseIndent();
80533                 writeLine(lineCount);
80534             }
80535             else if (writeSpaceIfNotIndenting) {
80536                 writeSpace();
80537             }
80538         }
80539         function decreaseIndentIf(value1, value2) {
80540             if (value1) {
80541                 decreaseIndent();
80542             }
80543             if (value2) {
80544                 decreaseIndent();
80545             }
80546         }
80547         function getLeadingLineTerminatorCount(parentNode, children, format) {
80548             if (format & 2 || preserveSourceNewlines) {
80549                 if (format & 65536) {
80550                     return 1;
80551                 }
80552                 var firstChild_1 = children[0];
80553                 if (firstChild_1 === undefined) {
80554                     return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
80555                 }
80556                 if (firstChild_1.kind === 11) {
80557                     return 0;
80558                 }
80559                 if (!ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(firstChild_1) && (!firstChild_1.parent || firstChild_1.parent === parentNode)) {
80560                     if (preserveSourceNewlines) {
80561                         return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(firstChild_1.pos, parentNode.pos, currentSourceFile, includeComments); });
80562                     }
80563                     return ts.rangeStartPositionsAreOnSameLine(parentNode, firstChild_1, currentSourceFile) ? 0 : 1;
80564                 }
80565                 if (synthesizedNodeStartsOnNewLine(firstChild_1, format)) {
80566                     return 1;
80567                 }
80568             }
80569             return format & 1 ? 1 : 0;
80570         }
80571         function getSeparatingLineTerminatorCount(previousNode, nextNode, format) {
80572             if (format & 2 || preserveSourceNewlines) {
80573                 if (previousNode === undefined || nextNode === undefined) {
80574                     return 0;
80575                 }
80576                 if (nextNode.kind === 11) {
80577                     return 0;
80578                 }
80579                 else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode) && previousNode.parent === nextNode.parent) {
80580                     if (preserveSourceNewlines) {
80581                         return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); });
80582                     }
80583                     return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1;
80584                 }
80585                 else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) {
80586                     return 1;
80587                 }
80588             }
80589             else if (ts.getStartsOnNewLine(nextNode)) {
80590                 return 1;
80591             }
80592             return format & 1 ? 1 : 0;
80593         }
80594         function getClosingLineTerminatorCount(parentNode, children, format) {
80595             if (format & 2 || preserveSourceNewlines) {
80596                 if (format & 65536) {
80597                     return 1;
80598                 }
80599                 var lastChild_1 = ts.lastOrUndefined(children);
80600                 if (lastChild_1 === undefined) {
80601                     return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
80602                 }
80603                 if (!ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild_1) && (!lastChild_1.parent || lastChild_1.parent === parentNode)) {
80604                     if (preserveSourceNewlines) {
80605                         return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(lastChild_1.end, parentNode.end, currentSourceFile, includeComments); });
80606                     }
80607                     return ts.rangeEndPositionsAreOnSameLine(parentNode, lastChild_1, currentSourceFile) ? 0 : 1;
80608                 }
80609                 if (synthesizedNodeStartsOnNewLine(lastChild_1, format)) {
80610                     return 1;
80611                 }
80612             }
80613             if (format & 1 && !(format & 131072)) {
80614                 return 1;
80615             }
80616             return 0;
80617         }
80618         function getEffectiveLines(getLineDifference) {
80619             ts.Debug.assert(!!preserveSourceNewlines);
80620             var lines = getLineDifference(true);
80621             if (lines === 0) {
80622                 return getLineDifference(false);
80623             }
80624             return lines;
80625         }
80626         function writeLineSeparatorsAndIndentBefore(node, parent) {
80627             var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], 0);
80628             if (leadingNewlines) {
80629                 writeLinesAndIndent(leadingNewlines, false);
80630             }
80631             return !!leadingNewlines;
80632         }
80633         function writeLineSeparatorsAfter(node, parent) {
80634             var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], 0);
80635             if (trailingNewlines) {
80636                 writeLine(trailingNewlines);
80637             }
80638         }
80639         function synthesizedNodeStartsOnNewLine(node, format) {
80640             if (ts.nodeIsSynthesized(node)) {
80641                 var startsOnNewLine = ts.getStartsOnNewLine(node);
80642                 if (startsOnNewLine === undefined) {
80643                     return (format & 65536) !== 0;
80644                 }
80645                 return startsOnNewLine;
80646             }
80647             return (format & 65536) !== 0;
80648         }
80649         function getLinesBetweenNodes(parent, node1, node2) {
80650             if (ts.getEmitFlags(parent) & 131072) {
80651                 return 0;
80652             }
80653             parent = skipSynthesizedParentheses(parent);
80654             node1 = skipSynthesizedParentheses(node1);
80655             node2 = skipSynthesizedParentheses(node2);
80656             if (ts.getStartsOnNewLine(node2)) {
80657                 return 1;
80658             }
80659             if (!ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
80660                 if (preserveSourceNewlines) {
80661                     return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(node1, node2, currentSourceFile, includeComments); });
80662                 }
80663                 return ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile) ? 0 : 1;
80664             }
80665             return 0;
80666         }
80667         function isEmptyBlock(block) {
80668             return block.statements.length === 0
80669                 && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile);
80670         }
80671         function skipSynthesizedParentheses(node) {
80672             while (node.kind === 200 && ts.nodeIsSynthesized(node)) {
80673                 node = node.expression;
80674             }
80675             return node;
80676         }
80677         function getTextOfNode(node, includeTrivia) {
80678             if (ts.isGeneratedIdentifier(node)) {
80679                 return generateName(node);
80680             }
80681             else if ((ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) {
80682                 return ts.idText(node);
80683             }
80684             else if (node.kind === 10 && node.textSourceNode) {
80685                 return getTextOfNode(node.textSourceNode, includeTrivia);
80686             }
80687             else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) {
80688                 return node.text;
80689             }
80690             return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia);
80691         }
80692         function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) {
80693             if (node.kind === 10 && node.textSourceNode) {
80694                 var textSourceNode = node.textSourceNode;
80695                 if (ts.isIdentifier(textSourceNode)) {
80696                     return jsxAttributeEscape ? "\"" + ts.escapeJsxAttributeString(getTextOfNode(textSourceNode)) + "\"" :
80697                         neverAsciiEscape || (ts.getEmitFlags(node) & 16777216) ? "\"" + ts.escapeString(getTextOfNode(textSourceNode)) + "\"" :
80698                             "\"" + ts.escapeNonAsciiString(getTextOfNode(textSourceNode)) + "\"";
80699                 }
80700                 else {
80701                     return getLiteralTextOfNode(textSourceNode, neverAsciiEscape, jsxAttributeEscape);
80702                 }
80703             }
80704             return ts.getLiteralText(node, currentSourceFile, neverAsciiEscape, jsxAttributeEscape);
80705         }
80706         function pushNameGenerationScope(node) {
80707             if (node && ts.getEmitFlags(node) & 524288) {
80708                 return;
80709             }
80710             tempFlagsStack.push(tempFlags);
80711             tempFlags = 0;
80712             reservedNamesStack.push(reservedNames);
80713         }
80714         function popNameGenerationScope(node) {
80715             if (node && ts.getEmitFlags(node) & 524288) {
80716                 return;
80717             }
80718             tempFlags = tempFlagsStack.pop();
80719             reservedNames = reservedNamesStack.pop();
80720         }
80721         function reserveNameInNestedScopes(name) {
80722             if (!reservedNames || reservedNames === ts.lastOrUndefined(reservedNamesStack)) {
80723                 reservedNames = ts.createMap();
80724             }
80725             reservedNames.set(name, true);
80726         }
80727         function generateNames(node) {
80728             if (!node)
80729                 return;
80730             switch (node.kind) {
80731                 case 223:
80732                     ts.forEach(node.statements, generateNames);
80733                     break;
80734                 case 238:
80735                 case 236:
80736                 case 228:
80737                 case 229:
80738                     generateNames(node.statement);
80739                     break;
80740                 case 227:
80741                     generateNames(node.thenStatement);
80742                     generateNames(node.elseStatement);
80743                     break;
80744                 case 230:
80745                 case 232:
80746                 case 231:
80747                     generateNames(node.initializer);
80748                     generateNames(node.statement);
80749                     break;
80750                 case 237:
80751                     generateNames(node.caseBlock);
80752                     break;
80753                 case 251:
80754                     ts.forEach(node.clauses, generateNames);
80755                     break;
80756                 case 277:
80757                 case 278:
80758                     ts.forEach(node.statements, generateNames);
80759                     break;
80760                 case 240:
80761                     generateNames(node.tryBlock);
80762                     generateNames(node.catchClause);
80763                     generateNames(node.finallyBlock);
80764                     break;
80765                 case 280:
80766                     generateNames(node.variableDeclaration);
80767                     generateNames(node.block);
80768                     break;
80769                 case 225:
80770                     generateNames(node.declarationList);
80771                     break;
80772                 case 243:
80773                     ts.forEach(node.declarations, generateNames);
80774                     break;
80775                 case 242:
80776                 case 156:
80777                 case 191:
80778                 case 245:
80779                     generateNameIfNeeded(node.name);
80780                     break;
80781                 case 244:
80782                     generateNameIfNeeded(node.name);
80783                     if (ts.getEmitFlags(node) & 524288) {
80784                         ts.forEach(node.parameters, generateNames);
80785                         generateNames(node.body);
80786                     }
80787                     break;
80788                 case 189:
80789                 case 190:
80790                     ts.forEach(node.elements, generateNames);
80791                     break;
80792                 case 254:
80793                     generateNames(node.importClause);
80794                     break;
80795                 case 255:
80796                     generateNameIfNeeded(node.name);
80797                     generateNames(node.namedBindings);
80798                     break;
80799                 case 256:
80800                     generateNameIfNeeded(node.name);
80801                     break;
80802                 case 262:
80803                     generateNameIfNeeded(node.name);
80804                     break;
80805                 case 257:
80806                     ts.forEach(node.elements, generateNames);
80807                     break;
80808                 case 258:
80809                     generateNameIfNeeded(node.propertyName || node.name);
80810                     break;
80811             }
80812         }
80813         function generateMemberNames(node) {
80814             if (!node)
80815                 return;
80816             switch (node.kind) {
80817                 case 281:
80818                 case 282:
80819                 case 159:
80820                 case 161:
80821                 case 163:
80822                 case 164:
80823                     generateNameIfNeeded(node.name);
80824                     break;
80825             }
80826         }
80827         function generateNameIfNeeded(name) {
80828             if (name) {
80829                 if (ts.isGeneratedIdentifier(name)) {
80830                     generateName(name);
80831                 }
80832                 else if (ts.isBindingPattern(name)) {
80833                     generateNames(name);
80834                 }
80835             }
80836         }
80837         function generateName(name) {
80838             if ((name.autoGenerateFlags & 7) === 4) {
80839                 return generateNameCached(getNodeForGeneratedName(name), name.autoGenerateFlags);
80840             }
80841             else {
80842                 var autoGenerateId = name.autoGenerateId;
80843                 return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = makeName(name));
80844             }
80845         }
80846         function generateNameCached(node, flags) {
80847             var nodeId = ts.getNodeId(node);
80848             return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = generateNameForNode(node, flags));
80849         }
80850         function isUniqueName(name) {
80851             return isFileLevelUniqueName(name)
80852                 && !generatedNames.has(name)
80853                 && !(reservedNames && reservedNames.has(name));
80854         }
80855         function isFileLevelUniqueName(name) {
80856             return currentSourceFile ? ts.isFileLevelUniqueName(currentSourceFile, name, hasGlobalName) : true;
80857         }
80858         function isUniqueLocalName(name, container) {
80859             for (var node = container; ts.isNodeDescendantOf(node, container); node = node.nextContainer) {
80860                 if (node.locals) {
80861                     var local = node.locals.get(ts.escapeLeadingUnderscores(name));
80862                     if (local && local.flags & (111551 | 1048576 | 2097152)) {
80863                         return false;
80864                     }
80865                 }
80866             }
80867             return true;
80868         }
80869         function makeTempVariableName(flags, reservedInNestedScopes) {
80870             if (flags && !(tempFlags & flags)) {
80871                 var name = flags === 268435456 ? "_i" : "_n";
80872                 if (isUniqueName(name)) {
80873                     tempFlags |= flags;
80874                     if (reservedInNestedScopes) {
80875                         reserveNameInNestedScopes(name);
80876                     }
80877                     return name;
80878                 }
80879             }
80880             while (true) {
80881                 var count = tempFlags & 268435455;
80882                 tempFlags++;
80883                 if (count !== 8 && count !== 13) {
80884                     var name = count < 26
80885                         ? "_" + String.fromCharCode(97 + count)
80886                         : "_" + (count - 26);
80887                     if (isUniqueName(name)) {
80888                         if (reservedInNestedScopes) {
80889                             reserveNameInNestedScopes(name);
80890                         }
80891                         return name;
80892                     }
80893                 }
80894             }
80895         }
80896         function makeUniqueName(baseName, checkFn, optimistic, scoped) {
80897             if (checkFn === void 0) { checkFn = isUniqueName; }
80898             if (optimistic) {
80899                 if (checkFn(baseName)) {
80900                     if (scoped) {
80901                         reserveNameInNestedScopes(baseName);
80902                     }
80903                     else {
80904                         generatedNames.set(baseName, true);
80905                     }
80906                     return baseName;
80907                 }
80908             }
80909             if (baseName.charCodeAt(baseName.length - 1) !== 95) {
80910                 baseName += "_";
80911             }
80912             var i = 1;
80913             while (true) {
80914                 var generatedName = baseName + i;
80915                 if (checkFn(generatedName)) {
80916                     if (scoped) {
80917                         reserveNameInNestedScopes(generatedName);
80918                     }
80919                     else {
80920                         generatedNames.set(generatedName, true);
80921                     }
80922                     return generatedName;
80923                 }
80924                 i++;
80925             }
80926         }
80927         function makeFileLevelOptimisticUniqueName(name) {
80928             return makeUniqueName(name, isFileLevelUniqueName, true);
80929         }
80930         function generateNameForModuleOrEnum(node) {
80931             var name = getTextOfNode(node.name);
80932             return isUniqueLocalName(name, node) ? name : makeUniqueName(name);
80933         }
80934         function generateNameForImportOrExportDeclaration(node) {
80935             var expr = ts.getExternalModuleName(node);
80936             var baseName = ts.isStringLiteral(expr) ?
80937                 ts.makeIdentifierFromModuleName(expr.text) : "module";
80938             return makeUniqueName(baseName);
80939         }
80940         function generateNameForExportDefault() {
80941             return makeUniqueName("default");
80942         }
80943         function generateNameForClassExpression() {
80944             return makeUniqueName("class");
80945         }
80946         function generateNameForMethodOrAccessor(node) {
80947             if (ts.isIdentifier(node.name)) {
80948                 return generateNameCached(node.name);
80949             }
80950             return makeTempVariableName(0);
80951         }
80952         function generateNameForNode(node, flags) {
80953             switch (node.kind) {
80954                 case 75:
80955                     return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16), !!(flags & 8));
80956                 case 249:
80957                 case 248:
80958                     return generateNameForModuleOrEnum(node);
80959                 case 254:
80960                 case 260:
80961                     return generateNameForImportOrExportDeclaration(node);
80962                 case 244:
80963                 case 245:
80964                 case 259:
80965                     return generateNameForExportDefault();
80966                 case 214:
80967                     return generateNameForClassExpression();
80968                 case 161:
80969                 case 163:
80970                 case 164:
80971                     return generateNameForMethodOrAccessor(node);
80972                 case 154:
80973                     return makeTempVariableName(0, true);
80974                 default:
80975                     return makeTempVariableName(0);
80976             }
80977         }
80978         function makeName(name) {
80979             switch (name.autoGenerateFlags & 7) {
80980                 case 1:
80981                     return makeTempVariableName(0, !!(name.autoGenerateFlags & 8));
80982                 case 2:
80983                     return makeTempVariableName(268435456, !!(name.autoGenerateFlags & 8));
80984                 case 3:
80985                     return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16), !!(name.autoGenerateFlags & 8));
80986             }
80987             return ts.Debug.fail("Unsupported GeneratedIdentifierKind.");
80988         }
80989         function getNodeForGeneratedName(name) {
80990             var autoGenerateId = name.autoGenerateId;
80991             var node = name;
80992             var original = node.original;
80993             while (original) {
80994                 node = original;
80995                 if (ts.isIdentifier(node)
80996                     && !!(node.autoGenerateFlags & 4)
80997                     && node.autoGenerateId !== autoGenerateId) {
80998                     break;
80999                 }
81000                 original = node.original;
81001             }
81002             return node;
81003         }
81004         function pipelineEmitWithComments(hint, node) {
81005             ts.Debug.assert(lastNode === node || lastSubstitution === node);
81006             enterComment();
81007             hasWrittenComment = false;
81008             var emitFlags = ts.getEmitFlags(node);
81009             var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end;
81010             var isEmittedNode = node.kind !== 325;
81011             var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0 || node.kind === 11;
81012             var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0 || node.kind === 11;
81013             var savedContainerPos = containerPos;
81014             var savedContainerEnd = containerEnd;
81015             var savedDeclarationListContainerEnd = declarationListContainerEnd;
81016             if ((pos > 0 || end > 0) && pos !== end) {
81017                 if (!skipLeadingComments) {
81018                     emitLeadingComments(pos, isEmittedNode);
81019                 }
81020                 if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512) !== 0)) {
81021                     containerPos = pos;
81022                 }
81023                 if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024) !== 0)) {
81024                     containerEnd = end;
81025                     if (node.kind === 243) {
81026                         declarationListContainerEnd = end;
81027                     }
81028                 }
81029             }
81030             ts.forEach(ts.getSyntheticLeadingComments(node), emitLeadingSynthesizedComment);
81031             exitComment();
81032             var pipelinePhase = getNextPipelinePhase(2, hint, node);
81033             if (emitFlags & 2048) {
81034                 commentsDisabled = true;
81035                 pipelinePhase(hint, node);
81036                 commentsDisabled = false;
81037             }
81038             else {
81039                 pipelinePhase(hint, node);
81040             }
81041             enterComment();
81042             ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment);
81043             if ((pos > 0 || end > 0) && pos !== end) {
81044                 containerPos = savedContainerPos;
81045                 containerEnd = savedContainerEnd;
81046                 declarationListContainerEnd = savedDeclarationListContainerEnd;
81047                 if (!skipTrailingComments && isEmittedNode) {
81048                     emitTrailingComments(end);
81049                 }
81050             }
81051             exitComment();
81052             ts.Debug.assert(lastNode === node || lastSubstitution === node);
81053         }
81054         function emitLeadingSynthesizedComment(comment) {
81055             if (comment.kind === 2) {
81056                 writer.writeLine();
81057             }
81058             writeSynthesizedComment(comment);
81059             if (comment.hasTrailingNewLine || comment.kind === 2) {
81060                 writer.writeLine();
81061             }
81062             else {
81063                 writer.writeSpace(" ");
81064             }
81065         }
81066         function emitTrailingSynthesizedComment(comment) {
81067             if (!writer.isAtStartOfLine()) {
81068                 writer.writeSpace(" ");
81069             }
81070             writeSynthesizedComment(comment);
81071             if (comment.hasTrailingNewLine) {
81072                 writer.writeLine();
81073             }
81074         }
81075         function writeSynthesizedComment(comment) {
81076             var text = formatSynthesizedComment(comment);
81077             var lineMap = comment.kind === 3 ? ts.computeLineStarts(text) : undefined;
81078             ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine);
81079         }
81080         function formatSynthesizedComment(comment) {
81081             return comment.kind === 3
81082                 ? "/*" + comment.text + "*/"
81083                 : "//" + comment.text;
81084         }
81085         function emitBodyWithDetachedComments(node, detachedRange, emitCallback) {
81086             enterComment();
81087             var pos = detachedRange.pos, end = detachedRange.end;
81088             var emitFlags = ts.getEmitFlags(node);
81089             var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0;
81090             var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024) !== 0;
81091             if (!skipLeadingComments) {
81092                 emitDetachedCommentsAndUpdateCommentsInfo(detachedRange);
81093             }
81094             exitComment();
81095             if (emitFlags & 2048 && !commentsDisabled) {
81096                 commentsDisabled = true;
81097                 emitCallback(node);
81098                 commentsDisabled = false;
81099             }
81100             else {
81101                 emitCallback(node);
81102             }
81103             enterComment();
81104             if (!skipTrailingComments) {
81105                 emitLeadingComments(detachedRange.end, true);
81106                 if (hasWrittenComment && !writer.isAtStartOfLine()) {
81107                     writer.writeLine();
81108                 }
81109             }
81110             exitComment();
81111         }
81112         function emitLeadingComments(pos, isEmittedNode) {
81113             hasWrittenComment = false;
81114             if (isEmittedNode) {
81115                 forEachLeadingCommentToEmit(pos, emitLeadingComment);
81116             }
81117             else if (pos === 0) {
81118                 forEachLeadingCommentToEmit(pos, emitTripleSlashLeadingComment);
81119             }
81120         }
81121         function emitTripleSlashLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
81122             if (isTripleSlashComment(commentPos, commentEnd)) {
81123                 emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos);
81124             }
81125         }
81126         function shouldWriteComment(text, pos) {
81127             if (printerOptions.onlyPrintJsDocStyle) {
81128                 return (ts.isJSDocLikeText(text, pos) || ts.isPinnedComment(text, pos));
81129             }
81130             return true;
81131         }
81132         function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
81133             if (!shouldWriteComment(currentSourceFile.text, commentPos))
81134                 return;
81135             if (!hasWrittenComment) {
81136                 ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos);
81137                 hasWrittenComment = true;
81138             }
81139             emitPos(commentPos);
81140             ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
81141             emitPos(commentEnd);
81142             if (hasTrailingNewLine) {
81143                 writer.writeLine();
81144             }
81145             else if (kind === 3) {
81146                 writer.writeSpace(" ");
81147             }
81148         }
81149         function emitLeadingCommentsOfPosition(pos) {
81150             if (commentsDisabled || pos === -1) {
81151                 return;
81152             }
81153             emitLeadingComments(pos, true);
81154         }
81155         function emitTrailingComments(pos) {
81156             forEachTrailingCommentToEmit(pos, emitTrailingComment);
81157         }
81158         function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) {
81159             if (!shouldWriteComment(currentSourceFile.text, commentPos))
81160                 return;
81161             if (!writer.isAtStartOfLine()) {
81162                 writer.writeSpace(" ");
81163             }
81164             emitPos(commentPos);
81165             ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
81166             emitPos(commentEnd);
81167             if (hasTrailingNewLine) {
81168                 writer.writeLine();
81169             }
81170         }
81171         function emitTrailingCommentsOfPosition(pos, prefixSpace) {
81172             if (commentsDisabled) {
81173                 return;
81174             }
81175             enterComment();
81176             forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : emitTrailingCommentOfPosition);
81177             exitComment();
81178         }
81179         function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) {
81180             emitPos(commentPos);
81181             ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
81182             emitPos(commentEnd);
81183             if (hasTrailingNewLine) {
81184                 writer.writeLine();
81185             }
81186             else {
81187                 writer.writeSpace(" ");
81188             }
81189         }
81190         function forEachLeadingCommentToEmit(pos, cb) {
81191             if (currentSourceFile && (containerPos === -1 || pos !== containerPos)) {
81192                 if (hasDetachedComments(pos)) {
81193                     forEachLeadingCommentWithoutDetachedComments(cb);
81194                 }
81195                 else {
81196                     ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, pos);
81197                 }
81198             }
81199         }
81200         function forEachTrailingCommentToEmit(end, cb) {
81201             if (currentSourceFile && (containerEnd === -1 || (end !== containerEnd && end !== declarationListContainerEnd))) {
81202                 ts.forEachTrailingCommentRange(currentSourceFile.text, end, cb);
81203             }
81204         }
81205         function hasDetachedComments(pos) {
81206             return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos;
81207         }
81208         function forEachLeadingCommentWithoutDetachedComments(cb) {
81209             var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos;
81210             if (detachedCommentsInfo.length - 1) {
81211                 detachedCommentsInfo.pop();
81212             }
81213             else {
81214                 detachedCommentsInfo = undefined;
81215             }
81216             ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, pos);
81217         }
81218         function emitDetachedCommentsAndUpdateCommentsInfo(range) {
81219             var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled);
81220             if (currentDetachedCommentInfo) {
81221                 if (detachedCommentsInfo) {
81222                     detachedCommentsInfo.push(currentDetachedCommentInfo);
81223                 }
81224                 else {
81225                     detachedCommentsInfo = [currentDetachedCommentInfo];
81226                 }
81227             }
81228         }
81229         function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) {
81230             if (!shouldWriteComment(currentSourceFile.text, commentPos))
81231                 return;
81232             emitPos(commentPos);
81233             ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine);
81234             emitPos(commentEnd);
81235         }
81236         function isTripleSlashComment(commentPos, commentEnd) {
81237             return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
81238         }
81239         function getParsedSourceMap(node) {
81240             if (node.parsedSourceMap === undefined && node.sourceMapText !== undefined) {
81241                 node.parsedSourceMap = ts.tryParseRawSourceMap(node.sourceMapText) || false;
81242             }
81243             return node.parsedSourceMap || undefined;
81244         }
81245         function pipelineEmitWithSourceMap(hint, node) {
81246             ts.Debug.assert(lastNode === node || lastSubstitution === node);
81247             var pipelinePhase = getNextPipelinePhase(3, hint, node);
81248             if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) {
81249                 pipelinePhase(hint, node);
81250             }
81251             else if (ts.isUnparsedNode(node)) {
81252                 var parsed = getParsedSourceMap(node.parent);
81253                 if (parsed && sourceMapGenerator) {
81254                     sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.parent.sourceMapPath, node.parent.getLineAndCharacterOfPosition(node.pos), node.parent.getLineAndCharacterOfPosition(node.end));
81255                 }
81256                 pipelinePhase(hint, node);
81257             }
81258             else {
81259                 var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b;
81260                 var emitFlags = ts.getEmitFlags(node);
81261                 if (node.kind !== 325
81262                     && (emitFlags & 16) === 0
81263                     && pos >= 0) {
81264                     emitSourcePos(source, skipSourceTrivia(source, pos));
81265                 }
81266                 if (emitFlags & 64) {
81267                     sourceMapsDisabled = true;
81268                     pipelinePhase(hint, node);
81269                     sourceMapsDisabled = false;
81270                 }
81271                 else {
81272                     pipelinePhase(hint, node);
81273                 }
81274                 if (node.kind !== 325
81275                     && (emitFlags & 32) === 0
81276                     && end >= 0) {
81277                     emitSourcePos(source, end);
81278                 }
81279             }
81280             ts.Debug.assert(lastNode === node || lastSubstitution === node);
81281         }
81282         function skipSourceTrivia(source, pos) {
81283             return source.skipTrivia ? source.skipTrivia(pos) : ts.skipTrivia(source.text, pos);
81284         }
81285         function emitPos(pos) {
81286             if (sourceMapsDisabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(sourceMapSource)) {
81287                 return;
81288             }
81289             var _a = ts.getLineAndCharacterOfPosition(sourceMapSource, pos), sourceLine = _a.line, sourceCharacter = _a.character;
81290             sourceMapGenerator.addMapping(writer.getLine(), writer.getColumn(), sourceMapSourceIndex, sourceLine, sourceCharacter, undefined);
81291         }
81292         function emitSourcePos(source, pos) {
81293             if (source !== sourceMapSource) {
81294                 var savedSourceMapSource = sourceMapSource;
81295                 setSourceMapSource(source);
81296                 emitPos(pos);
81297                 setSourceMapSource(savedSourceMapSource);
81298             }
81299             else {
81300                 emitPos(pos);
81301             }
81302         }
81303         function emitTokenWithSourceMap(node, token, writer, tokenPos, emitCallback) {
81304             if (sourceMapsDisabled || node && ts.isInJsonFile(node)) {
81305                 return emitCallback(token, writer, tokenPos);
81306             }
81307             var emitNode = node && node.emitNode;
81308             var emitFlags = emitNode && emitNode.flags || 0;
81309             var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token];
81310             var source = range && range.source || sourceMapSource;
81311             tokenPos = skipSourceTrivia(source, range ? range.pos : tokenPos);
81312             if ((emitFlags & 128) === 0 && tokenPos >= 0) {
81313                 emitSourcePos(source, tokenPos);
81314             }
81315             tokenPos = emitCallback(token, writer, tokenPos);
81316             if (range)
81317                 tokenPos = range.end;
81318             if ((emitFlags & 256) === 0 && tokenPos >= 0) {
81319                 emitSourcePos(source, tokenPos);
81320             }
81321             return tokenPos;
81322         }
81323         function setSourceMapSource(source) {
81324             if (sourceMapsDisabled) {
81325                 return;
81326             }
81327             sourceMapSource = source;
81328             if (isJsonSourceMapSource(source)) {
81329                 return;
81330             }
81331             sourceMapSourceIndex = sourceMapGenerator.addSource(source.fileName);
81332             if (printerOptions.inlineSources) {
81333                 sourceMapGenerator.setSourceContent(sourceMapSourceIndex, source.text);
81334             }
81335         }
81336         function isJsonSourceMapSource(sourceFile) {
81337             return ts.fileExtensionIs(sourceFile.fileName, ".json");
81338         }
81339     }
81340     ts.createPrinter = createPrinter;
81341     function createBracketsMap() {
81342         var brackets = [];
81343         brackets[1024] = ["{", "}"];
81344         brackets[2048] = ["(", ")"];
81345         brackets[4096] = ["<", ">"];
81346         brackets[8192] = ["[", "]"];
81347         return brackets;
81348     }
81349     function getOpeningBracket(format) {
81350         return brackets[format & 15360][0];
81351     }
81352     function getClosingBracket(format) {
81353         return brackets[format & 15360][1];
81354     }
81355 })(ts || (ts = {}));
81356 var ts;
81357 (function (ts) {
81358     function createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames) {
81359         if (!host.getDirectories || !host.readDirectory) {
81360             return undefined;
81361         }
81362         var cachedReadDirectoryResult = ts.createMap();
81363         var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
81364         return {
81365             useCaseSensitiveFileNames: useCaseSensitiveFileNames,
81366             fileExists: fileExists,
81367             readFile: function (path, encoding) { return host.readFile(path, encoding); },
81368             directoryExists: host.directoryExists && directoryExists,
81369             getDirectories: getDirectories,
81370             readDirectory: readDirectory,
81371             createDirectory: host.createDirectory && createDirectory,
81372             writeFile: host.writeFile && writeFile,
81373             addOrDeleteFileOrDirectory: addOrDeleteFileOrDirectory,
81374             addOrDeleteFile: addOrDeleteFile,
81375             clearCache: clearCache,
81376             realpath: host.realpath && realpath
81377         };
81378         function toPath(fileName) {
81379             return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
81380         }
81381         function getCachedFileSystemEntries(rootDirPath) {
81382             return cachedReadDirectoryResult.get(ts.ensureTrailingDirectorySeparator(rootDirPath));
81383         }
81384         function getCachedFileSystemEntriesForBaseDir(path) {
81385             return getCachedFileSystemEntries(ts.getDirectoryPath(path));
81386         }
81387         function getBaseNameOfFileName(fileName) {
81388             return ts.getBaseFileName(ts.normalizePath(fileName));
81389         }
81390         function createCachedFileSystemEntries(rootDir, rootDirPath) {
81391             var resultFromHost = {
81392                 files: ts.map(host.readDirectory(rootDir, undefined, undefined, ["*.*"]), getBaseNameOfFileName) || [],
81393                 directories: host.getDirectories(rootDir) || []
81394             };
81395             cachedReadDirectoryResult.set(ts.ensureTrailingDirectorySeparator(rootDirPath), resultFromHost);
81396             return resultFromHost;
81397         }
81398         function tryReadDirectory(rootDir, rootDirPath) {
81399             rootDirPath = ts.ensureTrailingDirectorySeparator(rootDirPath);
81400             var cachedResult = getCachedFileSystemEntries(rootDirPath);
81401             if (cachedResult) {
81402                 return cachedResult;
81403             }
81404             try {
81405                 return createCachedFileSystemEntries(rootDir, rootDirPath);
81406             }
81407             catch (_e) {
81408                 ts.Debug.assert(!cachedReadDirectoryResult.has(ts.ensureTrailingDirectorySeparator(rootDirPath)));
81409                 return undefined;
81410             }
81411         }
81412         function fileNameEqual(name1, name2) {
81413             return getCanonicalFileName(name1) === getCanonicalFileName(name2);
81414         }
81415         function hasEntry(entries, name) {
81416             return ts.some(entries, function (file) { return fileNameEqual(file, name); });
81417         }
81418         function updateFileSystemEntry(entries, baseName, isValid) {
81419             if (hasEntry(entries, baseName)) {
81420                 if (!isValid) {
81421                     return ts.filterMutate(entries, function (entry) { return !fileNameEqual(entry, baseName); });
81422                 }
81423             }
81424             else if (isValid) {
81425                 return entries.push(baseName);
81426             }
81427         }
81428         function writeFile(fileName, data, writeByteOrderMark) {
81429             var path = toPath(fileName);
81430             var result = getCachedFileSystemEntriesForBaseDir(path);
81431             if (result) {
81432                 updateFilesOfFileSystemEntry(result, getBaseNameOfFileName(fileName), true);
81433             }
81434             return host.writeFile(fileName, data, writeByteOrderMark);
81435         }
81436         function fileExists(fileName) {
81437             var path = toPath(fileName);
81438             var result = getCachedFileSystemEntriesForBaseDir(path);
81439             return result && hasEntry(result.files, getBaseNameOfFileName(fileName)) ||
81440                 host.fileExists(fileName);
81441         }
81442         function directoryExists(dirPath) {
81443             var path = toPath(dirPath);
81444             return cachedReadDirectoryResult.has(ts.ensureTrailingDirectorySeparator(path)) || host.directoryExists(dirPath);
81445         }
81446         function createDirectory(dirPath) {
81447             var path = toPath(dirPath);
81448             var result = getCachedFileSystemEntriesForBaseDir(path);
81449             var baseFileName = getBaseNameOfFileName(dirPath);
81450             if (result) {
81451                 updateFileSystemEntry(result.directories, baseFileName, true);
81452             }
81453             host.createDirectory(dirPath);
81454         }
81455         function getDirectories(rootDir) {
81456             var rootDirPath = toPath(rootDir);
81457             var result = tryReadDirectory(rootDir, rootDirPath);
81458             if (result) {
81459                 return result.directories.slice();
81460             }
81461             return host.getDirectories(rootDir);
81462         }
81463         function readDirectory(rootDir, extensions, excludes, includes, depth) {
81464             var rootDirPath = toPath(rootDir);
81465             var result = tryReadDirectory(rootDir, rootDirPath);
81466             if (result) {
81467                 return ts.matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath);
81468             }
81469             return host.readDirectory(rootDir, extensions, excludes, includes, depth);
81470             function getFileSystemEntries(dir) {
81471                 var path = toPath(dir);
81472                 if (path === rootDirPath) {
81473                     return result;
81474                 }
81475                 return tryReadDirectory(dir, path) || ts.emptyFileSystemEntries;
81476             }
81477         }
81478         function realpath(s) {
81479             return host.realpath ? host.realpath(s) : s;
81480         }
81481         function addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath) {
81482             var existingResult = getCachedFileSystemEntries(fileOrDirectoryPath);
81483             if (existingResult) {
81484                 clearCache();
81485                 return undefined;
81486             }
81487             var parentResult = getCachedFileSystemEntriesForBaseDir(fileOrDirectoryPath);
81488             if (!parentResult) {
81489                 return undefined;
81490             }
81491             if (!host.directoryExists) {
81492                 clearCache();
81493                 return undefined;
81494             }
81495             var baseName = getBaseNameOfFileName(fileOrDirectory);
81496             var fsQueryResult = {
81497                 fileExists: host.fileExists(fileOrDirectoryPath),
81498                 directoryExists: host.directoryExists(fileOrDirectoryPath)
81499             };
81500             if (fsQueryResult.directoryExists || hasEntry(parentResult.directories, baseName)) {
81501                 clearCache();
81502             }
81503             else {
81504                 updateFilesOfFileSystemEntry(parentResult, baseName, fsQueryResult.fileExists);
81505             }
81506             return fsQueryResult;
81507         }
81508         function addOrDeleteFile(fileName, filePath, eventKind) {
81509             if (eventKind === ts.FileWatcherEventKind.Changed) {
81510                 return;
81511             }
81512             var parentResult = getCachedFileSystemEntriesForBaseDir(filePath);
81513             if (parentResult) {
81514                 updateFilesOfFileSystemEntry(parentResult, getBaseNameOfFileName(fileName), eventKind === ts.FileWatcherEventKind.Created);
81515             }
81516         }
81517         function updateFilesOfFileSystemEntry(parentResult, baseName, fileExists) {
81518             updateFileSystemEntry(parentResult.files, baseName, fileExists);
81519         }
81520         function clearCache() {
81521             cachedReadDirectoryResult.clear();
81522         }
81523     }
81524     ts.createCachedDirectoryStructureHost = createCachedDirectoryStructureHost;
81525     var ConfigFileProgramReloadLevel;
81526     (function (ConfigFileProgramReloadLevel) {
81527         ConfigFileProgramReloadLevel[ConfigFileProgramReloadLevel["None"] = 0] = "None";
81528         ConfigFileProgramReloadLevel[ConfigFileProgramReloadLevel["Partial"] = 1] = "Partial";
81529         ConfigFileProgramReloadLevel[ConfigFileProgramReloadLevel["Full"] = 2] = "Full";
81530     })(ConfigFileProgramReloadLevel = ts.ConfigFileProgramReloadLevel || (ts.ConfigFileProgramReloadLevel = {}));
81531     function updateMissingFilePathsWatch(program, missingFileWatches, createMissingFileWatch) {
81532         var missingFilePaths = program.getMissingFilePaths();
81533         var newMissingFilePathMap = ts.arrayToSet(missingFilePaths);
81534         ts.mutateMap(missingFileWatches, newMissingFilePathMap, {
81535             createNewValue: createMissingFileWatch,
81536             onDeleteValue: ts.closeFileWatcher
81537         });
81538     }
81539     ts.updateMissingFilePathsWatch = updateMissingFilePathsWatch;
81540     function updateWatchingWildcardDirectories(existingWatchedForWildcards, wildcardDirectories, watchDirectory) {
81541         ts.mutateMap(existingWatchedForWildcards, wildcardDirectories, {
81542             createNewValue: createWildcardDirectoryWatcher,
81543             onDeleteValue: closeFileWatcherOf,
81544             onExistingValue: updateWildcardDirectoryWatcher
81545         });
81546         function createWildcardDirectoryWatcher(directory, flags) {
81547             return {
81548                 watcher: watchDirectory(directory, flags),
81549                 flags: flags
81550             };
81551         }
81552         function updateWildcardDirectoryWatcher(existingWatcher, flags, directory) {
81553             if (existingWatcher.flags === flags) {
81554                 return;
81555             }
81556             existingWatcher.watcher.close();
81557             existingWatchedForWildcards.set(directory, createWildcardDirectoryWatcher(directory, flags));
81558         }
81559     }
81560     ts.updateWatchingWildcardDirectories = updateWatchingWildcardDirectories;
81561     function isEmittedFileOfProgram(program, file) {
81562         if (!program) {
81563             return false;
81564         }
81565         return program.isEmittedFile(file);
81566     }
81567     ts.isEmittedFileOfProgram = isEmittedFileOfProgram;
81568     var WatchLogLevel;
81569     (function (WatchLogLevel) {
81570         WatchLogLevel[WatchLogLevel["None"] = 0] = "None";
81571         WatchLogLevel[WatchLogLevel["TriggerOnly"] = 1] = "TriggerOnly";
81572         WatchLogLevel[WatchLogLevel["Verbose"] = 2] = "Verbose";
81573     })(WatchLogLevel = ts.WatchLogLevel || (ts.WatchLogLevel = {}));
81574     function getWatchFactory(watchLogLevel, log, getDetailWatchInfo) {
81575         return getWatchFactoryWith(watchLogLevel, log, getDetailWatchInfo, watchFile, watchDirectory);
81576     }
81577     ts.getWatchFactory = getWatchFactory;
81578     function getWatchFactoryWith(watchLogLevel, log, getDetailWatchInfo, watchFile, watchDirectory) {
81579         var createFileWatcher = getCreateFileWatcher(watchLogLevel, watchFile);
81580         var createFilePathWatcher = watchLogLevel === WatchLogLevel.None ? watchFilePath : createFileWatcher;
81581         var createDirectoryWatcher = getCreateFileWatcher(watchLogLevel, watchDirectory);
81582         if (watchLogLevel === WatchLogLevel.Verbose && ts.sysLog === ts.noop) {
81583             ts.setSysLog(function (s) { return log(s); });
81584         }
81585         return {
81586             watchFile: function (host, file, callback, pollingInterval, options, detailInfo1, detailInfo2) {
81587                 return createFileWatcher(host, file, callback, pollingInterval, options, undefined, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo);
81588             },
81589             watchFilePath: function (host, file, callback, pollingInterval, options, path, detailInfo1, detailInfo2) {
81590                 return createFilePathWatcher(host, file, callback, pollingInterval, options, path, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo);
81591             },
81592             watchDirectory: function (host, directory, callback, flags, options, detailInfo1, detailInfo2) {
81593                 return createDirectoryWatcher(host, directory, callback, flags, options, undefined, detailInfo1, detailInfo2, watchDirectory, log, "DirectoryWatcher", getDetailWatchInfo);
81594             }
81595         };
81596     }
81597     function watchFile(host, file, callback, pollingInterval, options) {
81598         return host.watchFile(file, callback, pollingInterval, options);
81599     }
81600     function watchFilePath(host, file, callback, pollingInterval, options, path) {
81601         return watchFile(host, file, function (fileName, eventKind) { return callback(fileName, eventKind, path); }, pollingInterval, options);
81602     }
81603     function watchDirectory(host, directory, callback, flags, options) {
81604         return host.watchDirectory(directory, callback, (flags & 1) !== 0, options);
81605     }
81606     function getCreateFileWatcher(watchLogLevel, addWatch) {
81607         switch (watchLogLevel) {
81608             case WatchLogLevel.None:
81609                 return addWatch;
81610             case WatchLogLevel.TriggerOnly:
81611                 return createFileWatcherWithTriggerLogging;
81612             case WatchLogLevel.Verbose:
81613                 return addWatch === watchDirectory ? createDirectoryWatcherWithLogging : createFileWatcherWithLogging;
81614         }
81615     }
81616     function createFileWatcherWithLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo) {
81617         log(watchCaption + ":: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo));
81618         var watcher = createFileWatcherWithTriggerLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo);
81619         return {
81620             close: function () {
81621                 log(watchCaption + ":: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo));
81622                 watcher.close();
81623             }
81624         };
81625     }
81626     function createDirectoryWatcherWithLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo) {
81627         var watchInfo = watchCaption + ":: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo);
81628         log(watchInfo);
81629         var start = ts.timestamp();
81630         var watcher = createFileWatcherWithTriggerLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo);
81631         var elapsed = ts.timestamp() - start;
81632         log("Elapsed:: " + elapsed + "ms " + watchInfo);
81633         return {
81634             close: function () {
81635                 var watchInfo = watchCaption + ":: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo);
81636                 log(watchInfo);
81637                 var start = ts.timestamp();
81638                 watcher.close();
81639                 var elapsed = ts.timestamp() - start;
81640                 log("Elapsed:: " + elapsed + "ms " + watchInfo);
81641             }
81642         };
81643     }
81644     function createFileWatcherWithTriggerLogging(host, file, cb, flags, options, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo) {
81645         return addWatch(host, file, function (fileName, cbOptional) {
81646             var triggerredInfo = watchCaption + ":: Triggered with " + fileName + " " + (cbOptional !== undefined ? cbOptional : "") + ":: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo);
81647             log(triggerredInfo);
81648             var start = ts.timestamp();
81649             cb(fileName, cbOptional, passThrough);
81650             var elapsed = ts.timestamp() - start;
81651             log("Elapsed:: " + elapsed + "ms " + triggerredInfo);
81652         }, flags, options);
81653     }
81654     function getFallbackOptions(options) {
81655         var fallbackPolling = options === null || options === void 0 ? void 0 : options.fallbackPolling;
81656         return {
81657             watchFile: fallbackPolling !== undefined ?
81658                 fallbackPolling :
81659                 ts.WatchFileKind.PriorityPollingInterval
81660         };
81661     }
81662     ts.getFallbackOptions = getFallbackOptions;
81663     function getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo) {
81664         return "WatchInfo: " + file + " " + flags + " " + JSON.stringify(options) + " " + (getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : detailInfo1 + " " + detailInfo2);
81665     }
81666     function closeFileWatcherOf(objWithWatcher) {
81667         objWithWatcher.watcher.close();
81668     }
81669     ts.closeFileWatcherOf = closeFileWatcherOf;
81670 })(ts || (ts = {}));
81671 var ts;
81672 (function (ts) {
81673     function findConfigFile(searchPath, fileExists, configName) {
81674         if (configName === void 0) { configName = "tsconfig.json"; }
81675         return ts.forEachAncestorDirectory(searchPath, function (ancestor) {
81676             var fileName = ts.combinePaths(ancestor, configName);
81677             return fileExists(fileName) ? fileName : undefined;
81678         });
81679     }
81680     ts.findConfigFile = findConfigFile;
81681     function resolveTripleslashReference(moduleName, containingFile) {
81682         var basePath = ts.getDirectoryPath(containingFile);
81683         var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName);
81684         return ts.normalizePath(referencedFileName);
81685     }
81686     ts.resolveTripleslashReference = resolveTripleslashReference;
81687     function computeCommonSourceDirectoryOfFilenames(fileNames, currentDirectory, getCanonicalFileName) {
81688         var commonPathComponents;
81689         var failed = ts.forEach(fileNames, function (sourceFile) {
81690             var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile, currentDirectory);
81691             sourcePathComponents.pop();
81692             if (!commonPathComponents) {
81693                 commonPathComponents = sourcePathComponents;
81694                 return;
81695             }
81696             var n = Math.min(commonPathComponents.length, sourcePathComponents.length);
81697             for (var i = 0; i < n; i++) {
81698                 if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) {
81699                     if (i === 0) {
81700                         return true;
81701                     }
81702                     commonPathComponents.length = i;
81703                     break;
81704                 }
81705             }
81706             if (sourcePathComponents.length < commonPathComponents.length) {
81707                 commonPathComponents.length = sourcePathComponents.length;
81708             }
81709         });
81710         if (failed) {
81711             return "";
81712         }
81713         if (!commonPathComponents) {
81714             return currentDirectory;
81715         }
81716         return ts.getPathFromPathComponents(commonPathComponents);
81717     }
81718     ts.computeCommonSourceDirectoryOfFilenames = computeCommonSourceDirectoryOfFilenames;
81719     function createCompilerHost(options, setParentNodes) {
81720         return createCompilerHostWorker(options, setParentNodes);
81721     }
81722     ts.createCompilerHost = createCompilerHost;
81723     function createCompilerHostWorker(options, setParentNodes, system) {
81724         if (system === void 0) { system = ts.sys; }
81725         var existingDirectories = ts.createMap();
81726         var getCanonicalFileName = ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames);
81727         function getSourceFile(fileName, languageVersion, onError) {
81728             var text;
81729             try {
81730                 ts.performance.mark("beforeIORead");
81731                 text = compilerHost.readFile(fileName);
81732                 ts.performance.mark("afterIORead");
81733                 ts.performance.measure("I/O Read", "beforeIORead", "afterIORead");
81734             }
81735             catch (e) {
81736                 if (onError) {
81737                     onError(e.message);
81738                 }
81739                 text = "";
81740             }
81741             return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined;
81742         }
81743         function directoryExists(directoryPath) {
81744             if (existingDirectories.has(directoryPath)) {
81745                 return true;
81746             }
81747             if ((compilerHost.directoryExists || system.directoryExists)(directoryPath)) {
81748                 existingDirectories.set(directoryPath, true);
81749                 return true;
81750             }
81751             return false;
81752         }
81753         function writeFile(fileName, data, writeByteOrderMark, onError) {
81754             try {
81755                 ts.performance.mark("beforeIOWrite");
81756                 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); });
81757                 ts.performance.mark("afterIOWrite");
81758                 ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
81759             }
81760             catch (e) {
81761                 if (onError) {
81762                     onError(e.message);
81763                 }
81764             }
81765         }
81766         var outputFingerprints;
81767         function writeFileWorker(fileName, data, writeByteOrderMark) {
81768             if (!ts.isWatchSet(options) || !system.createHash || !system.getModifiedTime) {
81769                 system.writeFile(fileName, data, writeByteOrderMark);
81770                 return;
81771             }
81772             if (!outputFingerprints) {
81773                 outputFingerprints = ts.createMap();
81774             }
81775             var hash = system.createHash(data);
81776             var mtimeBefore = system.getModifiedTime(fileName);
81777             if (mtimeBefore) {
81778                 var fingerprint = outputFingerprints.get(fileName);
81779                 if (fingerprint &&
81780                     fingerprint.byteOrderMark === writeByteOrderMark &&
81781                     fingerprint.hash === hash &&
81782                     fingerprint.mtime.getTime() === mtimeBefore.getTime()) {
81783                     return;
81784                 }
81785             }
81786             system.writeFile(fileName, data, writeByteOrderMark);
81787             var mtimeAfter = system.getModifiedTime(fileName) || ts.missingFileModifiedTime;
81788             outputFingerprints.set(fileName, {
81789                 hash: hash,
81790                 byteOrderMark: writeByteOrderMark,
81791                 mtime: mtimeAfter
81792             });
81793         }
81794         function getDefaultLibLocation() {
81795             return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath()));
81796         }
81797         var newLine = ts.getNewLineCharacter(options, function () { return system.newLine; });
81798         var realpath = system.realpath && (function (path) { return system.realpath(path); });
81799         var compilerHost = {
81800             getSourceFile: getSourceFile,
81801             getDefaultLibLocation: getDefaultLibLocation,
81802             getDefaultLibFileName: function (options) { return ts.combinePaths(getDefaultLibLocation(), ts.getDefaultLibFileName(options)); },
81803             writeFile: writeFile,
81804             getCurrentDirectory: ts.memoize(function () { return system.getCurrentDirectory(); }),
81805             useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; },
81806             getCanonicalFileName: getCanonicalFileName,
81807             getNewLine: function () { return newLine; },
81808             fileExists: function (fileName) { return system.fileExists(fileName); },
81809             readFile: function (fileName) { return system.readFile(fileName); },
81810             trace: function (s) { return system.write(s + newLine); },
81811             directoryExists: function (directoryName) { return system.directoryExists(directoryName); },
81812             getEnvironmentVariable: function (name) { return system.getEnvironmentVariable ? system.getEnvironmentVariable(name) : ""; },
81813             getDirectories: function (path) { return system.getDirectories(path); },
81814             realpath: realpath,
81815             readDirectory: function (path, extensions, include, exclude, depth) { return system.readDirectory(path, extensions, include, exclude, depth); },
81816             createDirectory: function (d) { return system.createDirectory(d); },
81817             createHash: ts.maybeBind(system, system.createHash)
81818         };
81819         return compilerHost;
81820     }
81821     ts.createCompilerHostWorker = createCompilerHostWorker;
81822     function changeCompilerHostLikeToUseCache(host, toPath, getSourceFile) {
81823         var originalReadFile = host.readFile;
81824         var originalFileExists = host.fileExists;
81825         var originalDirectoryExists = host.directoryExists;
81826         var originalCreateDirectory = host.createDirectory;
81827         var originalWriteFile = host.writeFile;
81828         var readFileCache = ts.createMap();
81829         var fileExistsCache = ts.createMap();
81830         var directoryExistsCache = ts.createMap();
81831         var sourceFileCache = ts.createMap();
81832         var readFileWithCache = function (fileName) {
81833             var key = toPath(fileName);
81834             var value = readFileCache.get(key);
81835             if (value !== undefined)
81836                 return value !== false ? value : undefined;
81837             return setReadFileCache(key, fileName);
81838         };
81839         var setReadFileCache = function (key, fileName) {
81840             var newValue = originalReadFile.call(host, fileName);
81841             readFileCache.set(key, newValue !== undefined ? newValue : false);
81842             return newValue;
81843         };
81844         host.readFile = function (fileName) {
81845             var key = toPath(fileName);
81846             var value = readFileCache.get(key);
81847             if (value !== undefined)
81848                 return value !== false ? value : undefined;
81849             if (!ts.fileExtensionIs(fileName, ".json") && !ts.isBuildInfoFile(fileName)) {
81850                 return originalReadFile.call(host, fileName);
81851             }
81852             return setReadFileCache(key, fileName);
81853         };
81854         var getSourceFileWithCache = getSourceFile ? function (fileName, languageVersion, onError, shouldCreateNewSourceFile) {
81855             var key = toPath(fileName);
81856             var value = sourceFileCache.get(key);
81857             if (value)
81858                 return value;
81859             var sourceFile = getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile);
81860             if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json"))) {
81861                 sourceFileCache.set(key, sourceFile);
81862             }
81863             return sourceFile;
81864         } : undefined;
81865         host.fileExists = function (fileName) {
81866             var key = toPath(fileName);
81867             var value = fileExistsCache.get(key);
81868             if (value !== undefined)
81869                 return value;
81870             var newValue = originalFileExists.call(host, fileName);
81871             fileExistsCache.set(key, !!newValue);
81872             return newValue;
81873         };
81874         if (originalWriteFile) {
81875             host.writeFile = function (fileName, data, writeByteOrderMark, onError, sourceFiles) {
81876                 var key = toPath(fileName);
81877                 fileExistsCache.delete(key);
81878                 var value = readFileCache.get(key);
81879                 if (value !== undefined && value !== data) {
81880                     readFileCache.delete(key);
81881                     sourceFileCache.delete(key);
81882                 }
81883                 else if (getSourceFileWithCache) {
81884                     var sourceFile = sourceFileCache.get(key);
81885                     if (sourceFile && sourceFile.text !== data) {
81886                         sourceFileCache.delete(key);
81887                     }
81888                 }
81889                 originalWriteFile.call(host, fileName, data, writeByteOrderMark, onError, sourceFiles);
81890             };
81891         }
81892         if (originalDirectoryExists && originalCreateDirectory) {
81893             host.directoryExists = function (directory) {
81894                 var key = toPath(directory);
81895                 var value = directoryExistsCache.get(key);
81896                 if (value !== undefined)
81897                     return value;
81898                 var newValue = originalDirectoryExists.call(host, directory);
81899                 directoryExistsCache.set(key, !!newValue);
81900                 return newValue;
81901             };
81902             host.createDirectory = function (directory) {
81903                 var key = toPath(directory);
81904                 directoryExistsCache.delete(key);
81905                 originalCreateDirectory.call(host, directory);
81906             };
81907         }
81908         return {
81909             originalReadFile: originalReadFile,
81910             originalFileExists: originalFileExists,
81911             originalDirectoryExists: originalDirectoryExists,
81912             originalCreateDirectory: originalCreateDirectory,
81913             originalWriteFile: originalWriteFile,
81914             getSourceFileWithCache: getSourceFileWithCache,
81915             readFileWithCache: readFileWithCache
81916         };
81917     }
81918     ts.changeCompilerHostLikeToUseCache = changeCompilerHostLikeToUseCache;
81919     function getPreEmitDiagnostics(program, sourceFile, cancellationToken) {
81920         var diagnostics;
81921         diagnostics = ts.addRange(diagnostics, program.getConfigFileParsingDiagnostics());
81922         diagnostics = ts.addRange(diagnostics, program.getOptionsDiagnostics(cancellationToken));
81923         diagnostics = ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile, cancellationToken));
81924         diagnostics = ts.addRange(diagnostics, program.getGlobalDiagnostics(cancellationToken));
81925         diagnostics = ts.addRange(diagnostics, program.getSemanticDiagnostics(sourceFile, cancellationToken));
81926         if (ts.getEmitDeclarations(program.getCompilerOptions())) {
81927             diagnostics = ts.addRange(diagnostics, program.getDeclarationDiagnostics(sourceFile, cancellationToken));
81928         }
81929         return ts.sortAndDeduplicateDiagnostics(diagnostics || ts.emptyArray);
81930     }
81931     ts.getPreEmitDiagnostics = getPreEmitDiagnostics;
81932     function formatDiagnostics(diagnostics, host) {
81933         var output = "";
81934         for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) {
81935             var diagnostic = diagnostics_2[_i];
81936             output += formatDiagnostic(diagnostic, host);
81937         }
81938         return output;
81939     }
81940     ts.formatDiagnostics = formatDiagnostics;
81941     function formatDiagnostic(diagnostic, host) {
81942         var errorMessage = ts.diagnosticCategoryName(diagnostic) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine();
81943         if (diagnostic.file) {
81944             var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character;
81945             var fileName = diagnostic.file.fileName;
81946             var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); });
81947             return relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): " + errorMessage;
81948         }
81949         return errorMessage;
81950     }
81951     ts.formatDiagnostic = formatDiagnostic;
81952     var ForegroundColorEscapeSequences;
81953     (function (ForegroundColorEscapeSequences) {
81954         ForegroundColorEscapeSequences["Grey"] = "\u001B[90m";
81955         ForegroundColorEscapeSequences["Red"] = "\u001B[91m";
81956         ForegroundColorEscapeSequences["Yellow"] = "\u001B[93m";
81957         ForegroundColorEscapeSequences["Blue"] = "\u001B[94m";
81958         ForegroundColorEscapeSequences["Cyan"] = "\u001B[96m";
81959     })(ForegroundColorEscapeSequences = ts.ForegroundColorEscapeSequences || (ts.ForegroundColorEscapeSequences = {}));
81960     var gutterStyleSequence = "\u001b[7m";
81961     var gutterSeparator = " ";
81962     var resetEscapeSequence = "\u001b[0m";
81963     var ellipsis = "...";
81964     var halfIndent = "  ";
81965     var indent = "    ";
81966     function getCategoryFormat(category) {
81967         switch (category) {
81968             case ts.DiagnosticCategory.Error: return ForegroundColorEscapeSequences.Red;
81969             case ts.DiagnosticCategory.Warning: return ForegroundColorEscapeSequences.Yellow;
81970             case ts.DiagnosticCategory.Suggestion: return ts.Debug.fail("Should never get an Info diagnostic on the command line.");
81971             case ts.DiagnosticCategory.Message: return ForegroundColorEscapeSequences.Blue;
81972         }
81973     }
81974     function formatColorAndReset(text, formatStyle) {
81975         return formatStyle + text + resetEscapeSequence;
81976     }
81977     ts.formatColorAndReset = formatColorAndReset;
81978     function formatCodeSpan(file, start, length, indent, squiggleColor, host) {
81979         var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character;
81980         var _b = ts.getLineAndCharacterOfPosition(file, start + length), lastLine = _b.line, lastLineChar = _b.character;
81981         var lastLineInFile = ts.getLineAndCharacterOfPosition(file, file.text.length).line;
81982         var hasMoreThanFiveLines = (lastLine - firstLine) >= 4;
81983         var gutterWidth = (lastLine + 1 + "").length;
81984         if (hasMoreThanFiveLines) {
81985             gutterWidth = Math.max(ellipsis.length, gutterWidth);
81986         }
81987         var context = "";
81988         for (var i = firstLine; i <= lastLine; i++) {
81989             context += host.getNewLine();
81990             if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) {
81991                 context += indent + formatColorAndReset(ts.padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine();
81992                 i = lastLine - 1;
81993             }
81994             var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0);
81995             var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length;
81996             var lineContent = file.text.slice(lineStart, lineEnd);
81997             lineContent = lineContent.replace(/\s+$/g, "");
81998             lineContent = lineContent.replace("\t", " ");
81999             context += indent + formatColorAndReset(ts.padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator;
82000             context += lineContent + host.getNewLine();
82001             context += indent + formatColorAndReset(ts.padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator;
82002             context += squiggleColor;
82003             if (i === firstLine) {
82004                 var lastCharForLine = i === lastLine ? lastLineChar : undefined;
82005                 context += lineContent.slice(0, firstLineChar).replace(/\S/g, " ");
82006                 context += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "~");
82007             }
82008             else if (i === lastLine) {
82009                 context += lineContent.slice(0, lastLineChar).replace(/./g, "~");
82010             }
82011             else {
82012                 context += lineContent.replace(/./g, "~");
82013             }
82014             context += resetEscapeSequence;
82015         }
82016         return context;
82017     }
82018     function formatLocation(file, start, host, color) {
82019         if (color === void 0) { color = formatColorAndReset; }
82020         var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character;
82021         var relativeFileName = host ? ts.convertToRelativePath(file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file.fileName;
82022         var output = "";
82023         output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan);
82024         output += ":";
82025         output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow);
82026         output += ":";
82027         output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow);
82028         return output;
82029     }
82030     ts.formatLocation = formatLocation;
82031     function formatDiagnosticsWithColorAndContext(diagnostics, host) {
82032         var output = "";
82033         for (var _i = 0, diagnostics_3 = diagnostics; _i < diagnostics_3.length; _i++) {
82034             var diagnostic = diagnostics_3[_i];
82035             if (diagnostic.file) {
82036                 var file = diagnostic.file, start = diagnostic.start;
82037                 output += formatLocation(file, start, host);
82038                 output += " - ";
82039             }
82040             output += formatColorAndReset(ts.diagnosticCategoryName(diagnostic), getCategoryFormat(diagnostic.category));
82041             output += formatColorAndReset(" TS" + diagnostic.code + ": ", ForegroundColorEscapeSequences.Grey);
82042             output += flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine());
82043             if (diagnostic.file) {
82044                 output += host.getNewLine();
82045                 output += formatCodeSpan(diagnostic.file, diagnostic.start, diagnostic.length, "", getCategoryFormat(diagnostic.category), host);
82046                 if (diagnostic.relatedInformation) {
82047                     output += host.getNewLine();
82048                     for (var _a = 0, _b = diagnostic.relatedInformation; _a < _b.length; _a++) {
82049                         var _c = _b[_a], file = _c.file, start = _c.start, length_8 = _c.length, messageText = _c.messageText;
82050                         if (file) {
82051                             output += host.getNewLine();
82052                             output += halfIndent + formatLocation(file, start, host);
82053                             output += formatCodeSpan(file, start, length_8, indent, ForegroundColorEscapeSequences.Cyan, host);
82054                         }
82055                         output += host.getNewLine();
82056                         output += indent + flattenDiagnosticMessageText(messageText, host.getNewLine());
82057                     }
82058                 }
82059             }
82060             output += host.getNewLine();
82061         }
82062         return output;
82063     }
82064     ts.formatDiagnosticsWithColorAndContext = formatDiagnosticsWithColorAndContext;
82065     function flattenDiagnosticMessageText(diag, newLine, indent) {
82066         if (indent === void 0) { indent = 0; }
82067         if (ts.isString(diag)) {
82068             return diag;
82069         }
82070         else if (diag === undefined) {
82071             return "";
82072         }
82073         var result = "";
82074         if (indent) {
82075             result += newLine;
82076             for (var i = 0; i < indent; i++) {
82077                 result += "  ";
82078             }
82079         }
82080         result += diag.messageText;
82081         indent++;
82082         if (diag.next) {
82083             for (var _i = 0, _a = diag.next; _i < _a.length; _i++) {
82084                 var kid = _a[_i];
82085                 result += flattenDiagnosticMessageText(kid, newLine, indent);
82086             }
82087         }
82088         return result;
82089     }
82090     ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText;
82091     function loadWithLocalCache(names, containingFile, redirectedReference, loader) {
82092         if (names.length === 0) {
82093             return [];
82094         }
82095         var resolutions = [];
82096         var cache = ts.createMap();
82097         for (var _i = 0, names_2 = names; _i < names_2.length; _i++) {
82098             var name = names_2[_i];
82099             var result = void 0;
82100             if (cache.has(name)) {
82101                 result = cache.get(name);
82102             }
82103             else {
82104                 cache.set(name, result = loader(name, containingFile, redirectedReference));
82105             }
82106             resolutions.push(result);
82107         }
82108         return resolutions;
82109     }
82110     ts.loadWithLocalCache = loadWithLocalCache;
82111     ts.inferredTypesContainingFile = "__inferred type names__.ts";
82112     function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences) {
82113         if (!program || hasChangedAutomaticTypeDirectiveNames) {
82114             return false;
82115         }
82116         if (!ts.arrayIsEqualTo(program.getRootFileNames(), rootFileNames)) {
82117             return false;
82118         }
82119         var seenResolvedRefs;
82120         if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) {
82121             return false;
82122         }
82123         if (program.getSourceFiles().some(sourceFileNotUptoDate)) {
82124             return false;
82125         }
82126         if (program.getMissingFilePaths().some(fileExists)) {
82127             return false;
82128         }
82129         var currentOptions = program.getCompilerOptions();
82130         if (!ts.compareDataObjects(currentOptions, newOptions)) {
82131             return false;
82132         }
82133         if (currentOptions.configFile && newOptions.configFile) {
82134             return currentOptions.configFile.text === newOptions.configFile.text;
82135         }
82136         return true;
82137         function sourceFileNotUptoDate(sourceFile) {
82138             return !sourceFileVersionUptoDate(sourceFile) ||
82139                 hasInvalidatedResolution(sourceFile.path);
82140         }
82141         function sourceFileVersionUptoDate(sourceFile) {
82142             return sourceFile.version === getSourceVersion(sourceFile.resolvedPath, sourceFile.fileName);
82143         }
82144         function projectReferenceUptoDate(oldRef, newRef, index) {
82145             if (!ts.projectReferenceIsEqualTo(oldRef, newRef)) {
82146                 return false;
82147             }
82148             return resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef);
82149         }
82150         function resolvedProjectReferenceUptoDate(oldResolvedRef, oldRef) {
82151             if (oldResolvedRef) {
82152                 if (ts.contains(seenResolvedRefs, oldResolvedRef)) {
82153                     return true;
82154                 }
82155                 if (!sourceFileVersionUptoDate(oldResolvedRef.sourceFile)) {
82156                     return false;
82157                 }
82158                 (seenResolvedRefs || (seenResolvedRefs = [])).push(oldResolvedRef);
82159                 return !ts.forEach(oldResolvedRef.references, function (childResolvedRef, index) {
82160                     return !resolvedProjectReferenceUptoDate(childResolvedRef, oldResolvedRef.commandLine.projectReferences[index]);
82161                 });
82162             }
82163             return !fileExists(resolveProjectReferencePath(oldRef));
82164         }
82165     }
82166     ts.isProgramUptoDate = isProgramUptoDate;
82167     function getConfigFileParsingDiagnostics(configFileParseResult) {
82168         return configFileParseResult.options.configFile ? __spreadArrays(configFileParseResult.options.configFile.parseDiagnostics, configFileParseResult.errors) :
82169             configFileParseResult.errors;
82170     }
82171     ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics;
82172     function shouldProgramCreateNewSourceFiles(program, newOptions) {
82173         if (!program)
82174             return false;
82175         var oldOptions = program.getCompilerOptions();
82176         return !!ts.sourceFileAffectingCompilerOptions.some(function (option) {
82177             return !ts.isJsonEqual(ts.getCompilerOptionValue(oldOptions, option), ts.getCompilerOptionValue(newOptions, option));
82178         });
82179     }
82180     function createCreateProgramOptions(rootNames, options, host, oldProgram, configFileParsingDiagnostics) {
82181         return {
82182             rootNames: rootNames,
82183             options: options,
82184             host: host,
82185             oldProgram: oldProgram,
82186             configFileParsingDiagnostics: configFileParsingDiagnostics
82187         };
82188     }
82189     function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
82190         var _a;
82191         var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions;
82192         var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences;
82193         var oldProgram = createProgramOptions.oldProgram;
82194         var processingDefaultLibFiles;
82195         var processingOtherFiles;
82196         var files;
82197         var symlinks;
82198         var commonSourceDirectory;
82199         var diagnosticsProducingTypeChecker;
82200         var noDiagnosticsTypeChecker;
82201         var classifiableNames;
82202         var ambientModuleNameToUnmodifiedFileName = ts.createMap();
82203         var refFileMap;
82204         var cachedBindAndCheckDiagnosticsForFile = {};
82205         var cachedDeclarationDiagnosticsForFile = {};
82206         var resolvedTypeReferenceDirectives = ts.createMap();
82207         var fileProcessingDiagnostics = ts.createDiagnosticCollection();
82208         var maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
82209         var currentNodeModulesDepth = 0;
82210         var modulesWithElidedImports = ts.createMap();
82211         var sourceFilesFoundSearchingNodeModules = ts.createMap();
82212         ts.performance.mark("beforeProgram");
82213         var host = createProgramOptions.host || createCompilerHost(options);
82214         var configParsingHost = parseConfigHostFromCompilerHostLike(host);
82215         var skipDefaultLib = options.noLib;
82216         var getDefaultLibraryFileName = ts.memoize(function () { return host.getDefaultLibFileName(options); });
82217         var defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : ts.getDirectoryPath(getDefaultLibraryFileName());
82218         var programDiagnostics = ts.createDiagnosticCollection();
82219         var currentDirectory = host.getCurrentDirectory();
82220         var supportedExtensions = ts.getSupportedExtensions(options);
82221         var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
82222         var hasEmitBlockingDiagnostics = ts.createMap();
82223         var _compilerOptionsObjectLiteralSyntax;
82224         var moduleResolutionCache;
82225         var actualResolveModuleNamesWorker;
82226         var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
82227         if (host.resolveModuleNames) {
82228             actualResolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFile, reusedNames, redirectedReference, options).map(function (resolved) {
82229                 if (!resolved || resolved.extension !== undefined) {
82230                     return resolved;
82231                 }
82232                 var withExtension = ts.clone(resolved);
82233                 withExtension.extension = ts.extensionFromPath(resolved.resolvedFileName);
82234                 return withExtension;
82235             }); };
82236         }
82237         else {
82238             moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }, options);
82239             var loader_1 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache, redirectedReference).resolvedModule; };
82240             actualResolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_1); };
82241         }
82242         var actualResolveTypeReferenceDirectiveNamesWorker;
82243         if (host.resolveTypeReferenceDirectives) {
82244             actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); };
82245         }
82246         else {
82247             var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; };
82248             actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_2); };
82249         }
82250         var packageIdToSourceFile = ts.createMap();
82251         var sourceFileToPackageName = ts.createMap();
82252         var redirectTargetsMap = ts.createMultiMap();
82253         var filesByName = ts.createMap();
82254         var missingFilePaths;
82255         var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createMap() : undefined;
82256         var resolvedProjectReferences;
82257         var projectReferenceRedirects;
82258         var mapFromFileToProjectReferenceRedirects;
82259         var mapFromToProjectReferenceRedirectSource;
82260         var useSourceOfProjectReferenceRedirect = !!((_a = host.useSourceOfProjectReferenceRedirect) === null || _a === void 0 ? void 0 : _a.call(host)) &&
82261             !options.disableSourceOfProjectReferenceRedirect;
82262         var _b = updateHostForUseSourceOfProjectReferenceRedirect({
82263             compilerHost: host,
82264             useSourceOfProjectReferenceRedirect: useSourceOfProjectReferenceRedirect,
82265             toPath: toPath,
82266             getResolvedProjectReferences: getResolvedProjectReferences,
82267             getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect,
82268             forEachResolvedProjectReference: forEachResolvedProjectReference
82269         }), onProgramCreateComplete = _b.onProgramCreateComplete, fileExists = _b.fileExists;
82270         var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
82271         var structuralIsReused;
82272         structuralIsReused = tryReuseStructureFromOldProgram();
82273         if (structuralIsReused !== 2) {
82274             processingDefaultLibFiles = [];
82275             processingOtherFiles = [];
82276             if (projectReferences) {
82277                 if (!resolvedProjectReferences) {
82278                     resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile);
82279                 }
82280                 if (rootNames.length) {
82281                     for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) {
82282                         var parsedRef = resolvedProjectReferences_1[_i];
82283                         if (!parsedRef)
82284                             continue;
82285                         var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out;
82286                         if (useSourceOfProjectReferenceRedirect) {
82287                             if (out || ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) {
82288                                 for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) {
82289                                     var fileName = _d[_c];
82290                                     processSourceFile(fileName, false, false, undefined);
82291                                 }
82292                             }
82293                         }
82294                         else {
82295                             if (out) {
82296                                 processSourceFile(ts.changeExtension(out, ".d.ts"), false, false, undefined);
82297                             }
82298                             else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) {
82299                                 for (var _e = 0, _f = parsedRef.commandLine.fileNames; _e < _f.length; _e++) {
82300                                     var fileName = _f[_e];
82301                                     if (!ts.fileExtensionIs(fileName, ".d.ts") && !ts.fileExtensionIs(fileName, ".json")) {
82302                                         processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), false, false, undefined);
82303                                     }
82304                                 }
82305                             }
82306                         }
82307                     }
82308                 }
82309             }
82310             ts.forEach(rootNames, function (name) { return processRootFile(name, false, false); });
82311             var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray;
82312             if (typeReferences.length) {
82313                 var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
82314                 var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
82315                 var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
82316                 for (var i = 0; i < typeReferences.length; i++) {
82317                     processTypeReferenceDirective(typeReferences[i], resolutions[i]);
82318                 }
82319             }
82320             if (rootNames.length && !skipDefaultLib) {
82321                 var defaultLibraryFileName = getDefaultLibraryFileName();
82322                 if (!options.lib && defaultLibraryFileName) {
82323                     processRootFile(defaultLibraryFileName, true, false);
82324                 }
82325                 else {
82326                     ts.forEach(options.lib, function (libFileName) {
82327                         processRootFile(ts.combinePaths(defaultLibraryPath, libFileName), true, false);
82328                     });
82329                 }
82330             }
82331             missingFilePaths = ts.arrayFrom(ts.mapDefinedIterator(filesByName.entries(), function (_a) {
82332                 var path = _a[0], file = _a[1];
82333                 return file === undefined ? path : undefined;
82334             }));
82335             files = ts.stableSort(processingDefaultLibFiles, compareDefaultLibFiles).concat(processingOtherFiles);
82336             processingDefaultLibFiles = undefined;
82337             processingOtherFiles = undefined;
82338         }
82339         ts.Debug.assert(!!missingFilePaths);
82340         if (oldProgram && host.onReleaseOldSourceFile) {
82341             var oldSourceFiles = oldProgram.getSourceFiles();
82342             for (var _g = 0, oldSourceFiles_1 = oldSourceFiles; _g < oldSourceFiles_1.length; _g++) {
82343                 var oldSourceFile = oldSourceFiles_1[_g];
82344                 var newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
82345                 if (shouldCreateNewSourceFile || !newFile ||
82346                     (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) {
82347                     host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
82348                 }
82349             }
82350             oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference, resolvedProjectReferencePath) {
82351                 if (resolvedProjectReference && !getResolvedProjectReferenceByPath(resolvedProjectReferencePath)) {
82352                     host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), false);
82353                 }
82354             });
82355         }
82356         oldProgram = undefined;
82357         var program = {
82358             getRootFileNames: function () { return rootNames; },
82359             getSourceFile: getSourceFile,
82360             getSourceFileByPath: getSourceFileByPath,
82361             getSourceFiles: function () { return files; },
82362             getMissingFilePaths: function () { return missingFilePaths; },
82363             getRefFileMap: function () { return refFileMap; },
82364             getFilesByNameMap: function () { return filesByName; },
82365             getCompilerOptions: function () { return options; },
82366             getSyntacticDiagnostics: getSyntacticDiagnostics,
82367             getOptionsDiagnostics: getOptionsDiagnostics,
82368             getGlobalDiagnostics: getGlobalDiagnostics,
82369             getSemanticDiagnostics: getSemanticDiagnostics,
82370             getSuggestionDiagnostics: getSuggestionDiagnostics,
82371             getDeclarationDiagnostics: getDeclarationDiagnostics,
82372             getBindAndCheckDiagnostics: getBindAndCheckDiagnostics,
82373             getProgramDiagnostics: getProgramDiagnostics,
82374             getTypeChecker: getTypeChecker,
82375             getClassifiableNames: getClassifiableNames,
82376             getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker,
82377             getCommonSourceDirectory: getCommonSourceDirectory,
82378             emit: emit,
82379             getCurrentDirectory: function () { return currentDirectory; },
82380             getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); },
82381             getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); },
82382             getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); },
82383             getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); },
82384             getInstantiationCount: function () { return getDiagnosticsProducingTypeChecker().getInstantiationCount(); },
82385             getRelationCacheSizes: function () { return getDiagnosticsProducingTypeChecker().getRelationCacheSizes(); },
82386             getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; },
82387             getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; },
82388             isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
82389             isSourceFileDefaultLibrary: isSourceFileDefaultLibrary,
82390             dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker,
82391             getSourceFileFromReference: getSourceFileFromReference,
82392             getLibFileFromReference: getLibFileFromReference,
82393             sourceFileToPackageName: sourceFileToPackageName,
82394             redirectTargetsMap: redirectTargetsMap,
82395             isEmittedFile: isEmittedFile,
82396             getConfigFileParsingDiagnostics: getConfigFileParsingDiagnostics,
82397             getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
82398             getProjectReferences: getProjectReferences,
82399             getResolvedProjectReferences: getResolvedProjectReferences,
82400             getProjectReferenceRedirect: getProjectReferenceRedirect,
82401             getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect,
82402             getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath,
82403             forEachResolvedProjectReference: forEachResolvedProjectReference,
82404             isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
82405             emitBuildInfo: emitBuildInfo,
82406             fileExists: fileExists,
82407             getProbableSymlinks: getProbableSymlinks,
82408             useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
82409         };
82410         onProgramCreateComplete();
82411         verifyCompilerOptions();
82412         ts.performance.mark("afterProgram");
82413         ts.performance.measure("Program", "beforeProgram", "afterProgram");
82414         return program;
82415         function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames, redirectedReference) {
82416             ts.performance.mark("beforeResolveModule");
82417             var result = actualResolveModuleNamesWorker(moduleNames, containingFile, reusedNames, redirectedReference);
82418             ts.performance.mark("afterResolveModule");
82419             ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
82420             return result;
82421         }
82422         function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, redirectedReference) {
82423             ts.performance.mark("beforeResolveTypeReference");
82424             var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, redirectedReference);
82425             ts.performance.mark("afterResolveTypeReference");
82426             ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
82427             return result;
82428         }
82429         function compareDefaultLibFiles(a, b) {
82430             return ts.compareValues(getDefaultLibFilePriority(a), getDefaultLibFilePriority(b));
82431         }
82432         function getDefaultLibFilePriority(a) {
82433             if (ts.containsPath(defaultLibraryPath, a.fileName, false)) {
82434                 var basename = ts.getBaseFileName(a.fileName);
82435                 if (basename === "lib.d.ts" || basename === "lib.es6.d.ts")
82436                     return 0;
82437                 var name = ts.removeSuffix(ts.removePrefix(basename, "lib."), ".d.ts");
82438                 var index = ts.libs.indexOf(name);
82439                 if (index !== -1)
82440                     return index + 1;
82441             }
82442             return ts.libs.length + 2;
82443         }
82444         function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) {
82445             return moduleResolutionCache && ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache);
82446         }
82447         function toPath(fileName) {
82448             return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
82449         }
82450         function getCommonSourceDirectory() {
82451             if (commonSourceDirectory === undefined) {
82452                 var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, program); });
82453                 if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) {
82454                     commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory);
82455                 }
82456                 else if (options.composite && options.configFilePath) {
82457                     commonSourceDirectory = ts.getDirectoryPath(ts.normalizeSlashes(options.configFilePath));
82458                     checkSourceFilesBelongToPath(emittedFiles, commonSourceDirectory);
82459                 }
82460                 else {
82461                     commonSourceDirectory = computeCommonSourceDirectory(emittedFiles);
82462                 }
82463                 if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) {
82464                     commonSourceDirectory += ts.directorySeparator;
82465                 }
82466             }
82467             return commonSourceDirectory;
82468         }
82469         function getClassifiableNames() {
82470             if (!classifiableNames) {
82471                 getTypeChecker();
82472                 classifiableNames = ts.createUnderscoreEscapedMap();
82473                 for (var _i = 0, files_2 = files; _i < files_2.length; _i++) {
82474                     var sourceFile = files_2[_i];
82475                     ts.copyEntries(sourceFile.classifiableNames, classifiableNames);
82476                 }
82477             }
82478             return classifiableNames;
82479         }
82480         function resolveModuleNamesReusingOldState(moduleNames, containingFile, file) {
82481             if (structuralIsReused === 0 && !file.ambientModuleNames.length) {
82482                 return resolveModuleNamesWorker(moduleNames, containingFile, undefined, getResolvedProjectReferenceToRedirect(file.originalFileName));
82483             }
82484             var oldSourceFile = oldProgram && oldProgram.getSourceFile(containingFile);
82485             if (oldSourceFile !== file && file.resolvedModules) {
82486                 var result_11 = [];
82487                 for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) {
82488                     var moduleName = moduleNames_1[_i];
82489                     var resolvedModule = file.resolvedModules.get(moduleName);
82490                     result_11.push(resolvedModule);
82491                 }
82492                 return result_11;
82493             }
82494             var unknownModuleNames;
82495             var result;
82496             var reusedNames;
82497             var predictedToResolveToAmbientModuleMarker = {};
82498             for (var i = 0; i < moduleNames.length; i++) {
82499                 var moduleName = moduleNames[i];
82500                 if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
82501                     var oldResolvedModule = oldSourceFile && oldSourceFile.resolvedModules.get(moduleName);
82502                     if (oldResolvedModule) {
82503                         if (ts.isTraceEnabled(options, host)) {
82504                             ts.trace(host, ts.Diagnostics.Reusing_resolution_of_module_0_to_file_1_from_old_program, moduleName, containingFile);
82505                         }
82506                         (result || (result = new Array(moduleNames.length)))[i] = oldResolvedModule;
82507                         (reusedNames || (reusedNames = [])).push(moduleName);
82508                         continue;
82509                     }
82510                 }
82511                 var resolvesToAmbientModuleInNonModifiedFile = false;
82512                 if (ts.contains(file.ambientModuleNames, moduleName)) {
82513                     resolvesToAmbientModuleInNonModifiedFile = true;
82514                     if (ts.isTraceEnabled(options, host)) {
82515                         ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1, moduleName, containingFile);
82516                     }
82517                 }
82518                 else {
82519                     resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName);
82520                 }
82521                 if (resolvesToAmbientModuleInNonModifiedFile) {
82522                     (result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
82523                 }
82524                 else {
82525                     (unknownModuleNames || (unknownModuleNames = [])).push(moduleName);
82526                 }
82527             }
82528             var resolutions = unknownModuleNames && unknownModuleNames.length
82529                 ? resolveModuleNamesWorker(unknownModuleNames, containingFile, reusedNames, getResolvedProjectReferenceToRedirect(file.originalFileName))
82530                 : ts.emptyArray;
82531             if (!result) {
82532                 ts.Debug.assert(resolutions.length === moduleNames.length);
82533                 return resolutions;
82534             }
82535             var j = 0;
82536             for (var i = 0; i < result.length; i++) {
82537                 if (result[i]) {
82538                     if (result[i] === predictedToResolveToAmbientModuleMarker) {
82539                         result[i] = undefined;
82540                     }
82541                 }
82542                 else {
82543                     result[i] = resolutions[j];
82544                     j++;
82545                 }
82546             }
82547             ts.Debug.assert(j === resolutions.length);
82548             return result;
82549             function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName) {
82550                 var resolutionToFile = ts.getResolvedModule(oldSourceFile, moduleName);
82551                 var resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName);
82552                 if (resolutionToFile && resolvedFile) {
82553                     return false;
82554                 }
82555                 var unmodifiedFile = ambientModuleNameToUnmodifiedFileName.get(moduleName);
82556                 if (!unmodifiedFile) {
82557                     return false;
82558                 }
82559                 if (ts.isTraceEnabled(options, host)) {
82560                     ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, unmodifiedFile);
82561                 }
82562                 return true;
82563             }
82564         }
82565         function canReuseProjectReferences() {
82566             return !forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, index, parent) {
82567                 var newRef = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
82568                 var newResolvedRef = parseProjectReferenceConfigFile(newRef);
82569                 if (oldResolvedRef) {
82570                     return !newResolvedRef || newResolvedRef.sourceFile !== oldResolvedRef.sourceFile;
82571                 }
82572                 else {
82573                     return newResolvedRef !== undefined;
82574                 }
82575             }, function (oldProjectReferences, parent) {
82576                 var newReferences = parent ? getResolvedProjectReferenceByPath(parent.sourceFile.path).commandLine.projectReferences : projectReferences;
82577                 return !ts.arrayIsEqualTo(oldProjectReferences, newReferences, ts.projectReferenceIsEqualTo);
82578             });
82579         }
82580         function tryReuseStructureFromOldProgram() {
82581             if (!oldProgram) {
82582                 return 0;
82583             }
82584             var oldOptions = oldProgram.getCompilerOptions();
82585             if (ts.changesAffectModuleResolution(oldOptions, options)) {
82586                 return oldProgram.structureIsReused = 0;
82587             }
82588             ts.Debug.assert(!(oldProgram.structureIsReused & (2 | 1)));
82589             var oldRootNames = oldProgram.getRootFileNames();
82590             if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) {
82591                 return oldProgram.structureIsReused = 0;
82592             }
82593             if (!ts.arrayIsEqualTo(options.types, oldOptions.types)) {
82594                 return oldProgram.structureIsReused = 0;
82595             }
82596             if (!canReuseProjectReferences()) {
82597                 return oldProgram.structureIsReused = 0;
82598             }
82599             if (projectReferences) {
82600                 resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile);
82601             }
82602             var newSourceFiles = [];
82603             var modifiedSourceFiles = [];
82604             oldProgram.structureIsReused = 2;
82605             if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) {
82606                 return oldProgram.structureIsReused = 0;
82607             }
82608             var oldSourceFiles = oldProgram.getSourceFiles();
82609             var seenPackageNames = ts.createMap();
82610             for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
82611                 var oldSourceFile = oldSourceFiles_2[_i];
82612                 var newSourceFile = host.getSourceFileByPath
82613                     ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, options.target, undefined, shouldCreateNewSourceFile)
82614                     : host.getSourceFile(oldSourceFile.fileName, options.target, undefined, shouldCreateNewSourceFile);
82615                 if (!newSourceFile) {
82616                     return oldProgram.structureIsReused = 0;
82617                 }
82618                 ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`");
82619                 var fileChanged = void 0;
82620                 if (oldSourceFile.redirectInfo) {
82621                     if (newSourceFile !== oldSourceFile.redirectInfo.unredirected) {
82622                         return oldProgram.structureIsReused = 0;
82623                     }
82624                     fileChanged = false;
82625                     newSourceFile = oldSourceFile;
82626                 }
82627                 else if (oldProgram.redirectTargetsMap.has(oldSourceFile.path)) {
82628                     if (newSourceFile !== oldSourceFile) {
82629                         return oldProgram.structureIsReused = 0;
82630                     }
82631                     fileChanged = false;
82632                 }
82633                 else {
82634                     fileChanged = newSourceFile !== oldSourceFile;
82635                 }
82636                 newSourceFile.path = oldSourceFile.path;
82637                 newSourceFile.originalFileName = oldSourceFile.originalFileName;
82638                 newSourceFile.resolvedPath = oldSourceFile.resolvedPath;
82639                 newSourceFile.fileName = oldSourceFile.fileName;
82640                 var packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path);
82641                 if (packageName !== undefined) {
82642                     var prevKind = seenPackageNames.get(packageName);
82643                     var newKind = fileChanged ? 1 : 0;
82644                     if ((prevKind !== undefined && newKind === 1) || prevKind === 1) {
82645                         return oldProgram.structureIsReused = 0;
82646                     }
82647                     seenPackageNames.set(packageName, newKind);
82648                 }
82649                 if (fileChanged) {
82650                     if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
82651                         return oldProgram.structureIsReused = 0;
82652                     }
82653                     if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
82654                         oldProgram.structureIsReused = 1;
82655                     }
82656                     if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
82657                         oldProgram.structureIsReused = 1;
82658                     }
82659                     collectExternalModuleReferences(newSourceFile);
82660                     if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
82661                         oldProgram.structureIsReused = 1;
82662                     }
82663                     if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
82664                         oldProgram.structureIsReused = 1;
82665                     }
82666                     if ((oldSourceFile.flags & 3145728) !== (newSourceFile.flags & 3145728)) {
82667                         oldProgram.structureIsReused = 1;
82668                     }
82669                     if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
82670                         oldProgram.structureIsReused = 1;
82671                     }
82672                     modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
82673                 }
82674                 else if (hasInvalidatedResolution(oldSourceFile.path)) {
82675                     oldProgram.structureIsReused = 1;
82676                     modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
82677                 }
82678                 newSourceFiles.push(newSourceFile);
82679             }
82680             if (oldProgram.structureIsReused !== 2) {
82681                 return oldProgram.structureIsReused;
82682             }
82683             var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; });
82684             for (var _a = 0, oldSourceFiles_3 = oldSourceFiles; _a < oldSourceFiles_3.length; _a++) {
82685                 var oldFile = oldSourceFiles_3[_a];
82686                 if (!ts.contains(modifiedFiles, oldFile)) {
82687                     for (var _b = 0, _c = oldFile.ambientModuleNames; _b < _c.length; _b++) {
82688                         var moduleName = _c[_b];
82689                         ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName);
82690                     }
82691                 }
82692             }
82693             for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) {
82694                 var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile;
82695                 var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.originalFileName, currentDirectory);
82696                 var moduleNames = getModuleNames(newSourceFile);
82697                 var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile);
82698                 var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo);
82699                 if (resolutionsChanged) {
82700                     oldProgram.structureIsReused = 1;
82701                     newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions);
82702                 }
82703                 else {
82704                     newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
82705                 }
82706                 if (resolveTypeReferenceDirectiveNamesWorker) {
82707                     var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
82708                     var resolutions_1 = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName));
82709                     var resolutionsChanged_1 = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions_1, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo);
82710                     if (resolutionsChanged_1) {
82711                         oldProgram.structureIsReused = 1;
82712                         newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions_1);
82713                     }
82714                     else {
82715                         newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
82716                     }
82717                 }
82718             }
82719             if (oldProgram.structureIsReused !== 2) {
82720                 return oldProgram.structureIsReused;
82721             }
82722             if (host.hasChangedAutomaticTypeDirectiveNames) {
82723                 return oldProgram.structureIsReused = 1;
82724             }
82725             missingFilePaths = oldProgram.getMissingFilePaths();
82726             refFileMap = oldProgram.getRefFileMap();
82727             ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
82728             for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) {
82729                 var newSourceFile = newSourceFiles_1[_f];
82730                 filesByName.set(newSourceFile.path, newSourceFile);
82731             }
82732             var oldFilesByNameMap = oldProgram.getFilesByNameMap();
82733             oldFilesByNameMap.forEach(function (oldFile, path) {
82734                 if (!oldFile) {
82735                     filesByName.set(path, oldFile);
82736                     return;
82737                 }
82738                 if (oldFile.path === path) {
82739                     if (oldProgram.isSourceFileFromExternalLibrary(oldFile)) {
82740                         sourceFilesFoundSearchingNodeModules.set(oldFile.path, true);
82741                     }
82742                     return;
82743                 }
82744                 filesByName.set(path, filesByName.get(oldFile.path));
82745             });
82746             files = newSourceFiles;
82747             fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
82748             for (var _g = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _g < modifiedSourceFiles_2.length; _g++) {
82749                 var modifiedFile = modifiedSourceFiles_2[_g];
82750                 fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile);
82751             }
82752             resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
82753             sourceFileToPackageName = oldProgram.sourceFileToPackageName;
82754             redirectTargetsMap = oldProgram.redirectTargetsMap;
82755             return oldProgram.structureIsReused = 2;
82756         }
82757         function getEmitHost(writeFileCallback) {
82758             return {
82759                 getPrependNodes: getPrependNodes,
82760                 getCanonicalFileName: getCanonicalFileName,
82761                 getCommonSourceDirectory: program.getCommonSourceDirectory,
82762                 getCompilerOptions: program.getCompilerOptions,
82763                 getCurrentDirectory: function () { return currentDirectory; },
82764                 getNewLine: function () { return host.getNewLine(); },
82765                 getSourceFile: program.getSourceFile,
82766                 getSourceFileByPath: program.getSourceFileByPath,
82767                 getSourceFiles: program.getSourceFiles,
82768                 getLibFileFromReference: program.getLibFileFromReference,
82769                 isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
82770                 getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect,
82771                 getProjectReferenceRedirect: getProjectReferenceRedirect,
82772                 isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
82773                 getProbableSymlinks: getProbableSymlinks,
82774                 writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }),
82775                 isEmitBlocked: isEmitBlocked,
82776                 readFile: function (f) { return host.readFile(f); },
82777                 fileExists: function (f) {
82778                     var path = toPath(f);
82779                     if (getSourceFileByPath(path))
82780                         return true;
82781                     if (ts.contains(missingFilePaths, path))
82782                         return false;
82783                     return host.fileExists(f);
82784                 },
82785                 useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
82786                 getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); },
82787                 getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); },
82788                 redirectTargetsMap: redirectTargetsMap,
82789             };
82790         }
82791         function emitBuildInfo(writeFileCallback) {
82792             ts.Debug.assert(!options.out && !options.outFile);
82793             ts.performance.mark("beforeEmit");
82794             var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), undefined, ts.noTransformers, false, true);
82795             ts.performance.mark("afterEmit");
82796             ts.performance.measure("Emit", "beforeEmit", "afterEmit");
82797             return emitResult;
82798         }
82799         function getResolvedProjectReferences() {
82800             return resolvedProjectReferences;
82801         }
82802         function getProjectReferences() {
82803             return projectReferences;
82804         }
82805         function getPrependNodes() {
82806             return createPrependNodes(projectReferences, function (_ref, index) { return resolvedProjectReferences[index].commandLine; }, function (fileName) {
82807                 var path = toPath(fileName);
82808                 var sourceFile = getSourceFileByPath(path);
82809                 return sourceFile ? sourceFile.text : filesByName.has(path) ? undefined : host.readFile(path);
82810             });
82811         }
82812         function isSourceFileFromExternalLibrary(file) {
82813             return !!sourceFilesFoundSearchingNodeModules.get(file.path);
82814         }
82815         function isSourceFileDefaultLibrary(file) {
82816             if (file.hasNoDefaultLib) {
82817                 return true;
82818             }
82819             if (!options.noLib) {
82820                 return false;
82821             }
82822             var equalityComparer = host.useCaseSensitiveFileNames() ? ts.equateStringsCaseSensitive : ts.equateStringsCaseInsensitive;
82823             if (!options.lib) {
82824                 return equalityComparer(file.fileName, getDefaultLibraryFileName());
82825             }
82826             else {
82827                 return ts.some(options.lib, function (libFileName) { return equalityComparer(file.fileName, ts.combinePaths(defaultLibraryPath, libFileName)); });
82828             }
82829         }
82830         function getDiagnosticsProducingTypeChecker() {
82831             return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true));
82832         }
82833         function dropDiagnosticsProducingTypeChecker() {
82834             diagnosticsProducingTypeChecker = undefined;
82835         }
82836         function getTypeChecker() {
82837             return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false));
82838         }
82839         function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) {
82840             return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); });
82841         }
82842         function isEmitBlocked(emitFileName) {
82843             return hasEmitBlockingDiagnostics.has(toPath(emitFileName));
82844         }
82845         function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) {
82846             if (!forceDtsEmit) {
82847                 var result = handleNoEmitOptions(program, sourceFile, cancellationToken);
82848                 if (result)
82849                     return result;
82850             }
82851             var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken);
82852             ts.performance.mark("beforeEmit");
82853             var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, false, forceDtsEmit);
82854             ts.performance.mark("afterEmit");
82855             ts.performance.measure("Emit", "beforeEmit", "afterEmit");
82856             return emitResult;
82857         }
82858         function getSourceFile(fileName) {
82859             return getSourceFileByPath(toPath(fileName));
82860         }
82861         function getSourceFileByPath(path) {
82862             return filesByName.get(path) || undefined;
82863         }
82864         function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) {
82865             if (sourceFile) {
82866                 return getDiagnostics(sourceFile, cancellationToken);
82867             }
82868             return ts.sortAndDeduplicateDiagnostics(ts.flatMap(program.getSourceFiles(), function (sourceFile) {
82869                 if (cancellationToken) {
82870                     cancellationToken.throwIfCancellationRequested();
82871                 }
82872                 return getDiagnostics(sourceFile, cancellationToken);
82873             }));
82874         }
82875         function getSyntacticDiagnostics(sourceFile, cancellationToken) {
82876             return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken);
82877         }
82878         function getSemanticDiagnostics(sourceFile, cancellationToken) {
82879             return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken);
82880         }
82881         function getBindAndCheckDiagnostics(sourceFile, cancellationToken) {
82882             return getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken);
82883         }
82884         function getProgramDiagnostics(sourceFile) {
82885             if (ts.skipTypeChecking(sourceFile, options, program)) {
82886                 return ts.emptyArray;
82887             }
82888             var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName);
82889             var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
82890             return getMergedProgramDiagnostics(sourceFile, fileProcessingDiagnosticsInFile, programDiagnosticsInFile);
82891         }
82892         function getMergedProgramDiagnostics(sourceFile) {
82893             var _a;
82894             var allDiagnostics = [];
82895             for (var _i = 1; _i < arguments.length; _i++) {
82896                 allDiagnostics[_i - 1] = arguments[_i];
82897             }
82898             var flatDiagnostics = ts.flatten(allDiagnostics);
82899             if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) {
82900                 return flatDiagnostics;
82901             }
82902             return getDiagnosticsWithPrecedingDirectives(sourceFile, sourceFile.commentDirectives, flatDiagnostics).diagnostics;
82903         }
82904         function getDeclarationDiagnostics(sourceFile, cancellationToken) {
82905             var options = program.getCompilerOptions();
82906             if (!sourceFile || options.out || options.outFile) {
82907                 return getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
82908             }
82909             else {
82910                 return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken);
82911             }
82912         }
82913         function getSyntacticDiagnosticsForFile(sourceFile) {
82914             if (ts.isSourceFileJS(sourceFile)) {
82915                 if (!sourceFile.additionalSyntacticDiagnostics) {
82916                     sourceFile.additionalSyntacticDiagnostics = getJSSyntacticDiagnosticsForFile(sourceFile);
82917                 }
82918                 return ts.concatenate(sourceFile.additionalSyntacticDiagnostics, sourceFile.parseDiagnostics);
82919             }
82920             return sourceFile.parseDiagnostics;
82921         }
82922         function runWithCancellationToken(func) {
82923             try {
82924                 return func();
82925             }
82926             catch (e) {
82927                 if (e instanceof ts.OperationCanceledException) {
82928                     noDiagnosticsTypeChecker = undefined;
82929                     diagnosticsProducingTypeChecker = undefined;
82930                 }
82931                 throw e;
82932             }
82933         }
82934         function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) {
82935             return ts.concatenate(getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken), getProgramDiagnostics(sourceFile));
82936         }
82937         function getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken) {
82938             return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedBindAndCheckDiagnosticsForFile, getBindAndCheckDiagnosticsForFileNoCache);
82939         }
82940         function getBindAndCheckDiagnosticsForFileNoCache(sourceFile, cancellationToken) {
82941             return runWithCancellationToken(function () {
82942                 if (ts.skipTypeChecking(sourceFile, options, program)) {
82943                     return ts.emptyArray;
82944                 }
82945                 var typeChecker = getDiagnosticsProducingTypeChecker();
82946                 ts.Debug.assert(!!sourceFile.bindDiagnostics);
82947                 var isCheckJs = ts.isCheckJsEnabledForFile(sourceFile, options);
82948                 var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
82949                 var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 || sourceFile.scriptKind === 4 ||
82950                     sourceFile.scriptKind === 5 || isCheckJs || sourceFile.scriptKind === 7);
82951                 var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray;
82952                 var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray;
82953                 return getMergedBindAndCheckDiagnostics(sourceFile, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined);
82954             });
82955         }
82956         function getMergedBindAndCheckDiagnostics(sourceFile) {
82957             var _a;
82958             var allDiagnostics = [];
82959             for (var _i = 1; _i < arguments.length; _i++) {
82960                 allDiagnostics[_i - 1] = arguments[_i];
82961             }
82962             var flatDiagnostics = ts.flatten(allDiagnostics);
82963             if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) {
82964                 return flatDiagnostics;
82965             }
82966             var _b = getDiagnosticsWithPrecedingDirectives(sourceFile, sourceFile.commentDirectives, flatDiagnostics), diagnostics = _b.diagnostics, directives = _b.directives;
82967             for (var _c = 0, _d = directives.getUnusedExpectations(); _c < _d.length; _c++) {
82968                 var errorExpectation = _d[_c];
82969                 diagnostics.push(ts.createDiagnosticForRange(sourceFile, errorExpectation.range, ts.Diagnostics.Unused_ts_expect_error_directive));
82970             }
82971             return diagnostics;
82972         }
82973         function getDiagnosticsWithPrecedingDirectives(sourceFile, commentDirectives, flatDiagnostics) {
82974             var directives = ts.createCommentDirectivesMap(sourceFile, commentDirectives);
82975             var diagnostics = flatDiagnostics.filter(function (diagnostic) { return markPrecedingCommentDirectiveLine(diagnostic, directives) === -1; });
82976             return { diagnostics: diagnostics, directives: directives };
82977         }
82978         function getSuggestionDiagnostics(sourceFile, cancellationToken) {
82979             return runWithCancellationToken(function () {
82980                 return getDiagnosticsProducingTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken);
82981             });
82982         }
82983         function markPrecedingCommentDirectiveLine(diagnostic, directives) {
82984             var file = diagnostic.file, start = diagnostic.start;
82985             if (!file) {
82986                 return -1;
82987             }
82988             var lineStarts = ts.getLineStarts(file);
82989             var line = ts.computeLineAndCharacterOfPosition(lineStarts, start).line - 1;
82990             while (line >= 0) {
82991                 if (directives.markUsed(line)) {
82992                     return line;
82993                 }
82994                 var lineText = file.text.slice(lineStarts[line], lineStarts[line + 1]).trim();
82995                 if (lineText !== "" && !/^(\s*)\/\/(.*)$/.test(lineText)) {
82996                     return -1;
82997                 }
82998                 line--;
82999             }
83000             return -1;
83001         }
83002         function getJSSyntacticDiagnosticsForFile(sourceFile) {
83003             return runWithCancellationToken(function () {
83004                 var diagnostics = [];
83005                 walk(sourceFile, sourceFile);
83006                 ts.forEachChildRecursively(sourceFile, walk, walkArray);
83007                 return diagnostics;
83008                 function walk(node, parent) {
83009                     switch (parent.kind) {
83010                         case 156:
83011                         case 159:
83012                         case 161:
83013                             if (parent.questionToken === node) {
83014                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?"));
83015                                 return "skip";
83016                             }
83017                         case 160:
83018                         case 162:
83019                         case 163:
83020                         case 164:
83021                         case 201:
83022                         case 244:
83023                         case 202:
83024                         case 242:
83025                             if (parent.type === node) {
83026                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files));
83027                                 return "skip";
83028                             }
83029                     }
83030                     switch (node.kind) {
83031                         case 255:
83032                             if (node.isTypeOnly) {
83033                                 diagnostics.push(createDiagnosticForNode(node.parent, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "import type"));
83034                                 return "skip";
83035                             }
83036                             break;
83037                         case 260:
83038                             if (node.isTypeOnly) {
83039                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "export type"));
83040                                 return "skip";
83041                             }
83042                             break;
83043                         case 253:
83044                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files));
83045                             return "skip";
83046                         case 259:
83047                             if (node.isExportEquals) {
83048                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files));
83049                                 return "skip";
83050                             }
83051                             break;
83052                         case 279:
83053                             var heritageClause = node;
83054                             if (heritageClause.token === 113) {
83055                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files));
83056                                 return "skip";
83057                             }
83058                             break;
83059                         case 246:
83060                             var interfaceKeyword = ts.tokenToString(114);
83061                             ts.Debug.assertIsDefined(interfaceKeyword);
83062                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword));
83063                             return "skip";
83064                         case 249:
83065                             var moduleKeyword = node.flags & 16 ? ts.tokenToString(136) : ts.tokenToString(135);
83066                             ts.Debug.assertIsDefined(moduleKeyword);
83067                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword));
83068                             return "skip";
83069                         case 247:
83070                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files));
83071                             return "skip";
83072                         case 248:
83073                             var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(88));
83074                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword));
83075                             return "skip";
83076                         case 218:
83077                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files));
83078                             return "skip";
83079                         case 217:
83080                             diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files));
83081                             return "skip";
83082                         case 199:
83083                             ts.Debug.fail();
83084                     }
83085                 }
83086                 function walkArray(nodes, parent) {
83087                     if (parent.decorators === nodes && !options.experimentalDecorators) {
83088                         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));
83089                     }
83090                     switch (parent.kind) {
83091                         case 245:
83092                         case 214:
83093                         case 161:
83094                         case 162:
83095                         case 163:
83096                         case 164:
83097                         case 201:
83098                         case 244:
83099                         case 202:
83100                             if (nodes === parent.typeParameters) {
83101                                 diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files));
83102                                 return "skip";
83103                             }
83104                         case 225:
83105                             if (nodes === parent.modifiers) {
83106                                 checkModifiers(parent.modifiers, parent.kind === 225);
83107                                 return "skip";
83108                             }
83109                             break;
83110                         case 159:
83111                             if (nodes === parent.modifiers) {
83112                                 for (var _i = 0, _a = nodes; _i < _a.length; _i++) {
83113                                     var modifier = _a[_i];
83114                                     if (modifier.kind !== 120) {
83115                                         diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind)));
83116                                     }
83117                                 }
83118                                 return "skip";
83119                             }
83120                             break;
83121                         case 156:
83122                             if (nodes === parent.modifiers) {
83123                                 diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files));
83124                                 return "skip";
83125                             }
83126                             break;
83127                         case 196:
83128                         case 197:
83129                         case 216:
83130                         case 267:
83131                         case 268:
83132                         case 198:
83133                             if (nodes === parent.typeArguments) {
83134                                 diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files));
83135                                 return "skip";
83136                             }
83137                             break;
83138                     }
83139                 }
83140                 function checkModifiers(modifiers, isConstValid) {
83141                     for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) {
83142                         var modifier = modifiers_1[_i];
83143                         switch (modifier.kind) {
83144                             case 81:
83145                                 if (isConstValid) {
83146                                     continue;
83147                                 }
83148                             case 119:
83149                             case 117:
83150                             case 118:
83151                             case 138:
83152                             case 130:
83153                             case 122:
83154                                 diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind)));
83155                                 break;
83156                             case 120:
83157                             case 89:
83158                             case 84:
83159                         }
83160                     }
83161                 }
83162                 function createDiagnosticForNodeArray(nodes, message, arg0, arg1, arg2) {
83163                     var start = nodes.pos;
83164                     return ts.createFileDiagnostic(sourceFile, start, nodes.end - start, message, arg0, arg1, arg2);
83165                 }
83166                 function createDiagnosticForNode(node, message, arg0, arg1, arg2) {
83167                     return ts.createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2);
83168                 }
83169             });
83170         }
83171         function getDeclarationDiagnosticsWorker(sourceFile, cancellationToken) {
83172             return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedDeclarationDiagnosticsForFile, getDeclarationDiagnosticsForFileNoCache);
83173         }
83174         function getDeclarationDiagnosticsForFileNoCache(sourceFile, cancellationToken) {
83175             return runWithCancellationToken(function () {
83176                 var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken);
83177                 return ts.getDeclarationDiagnostics(getEmitHost(ts.noop), resolver, sourceFile) || ts.emptyArray;
83178             });
83179         }
83180         function getAndCacheDiagnostics(sourceFile, cancellationToken, cache, getDiagnostics) {
83181             var cachedResult = sourceFile
83182                 ? cache.perFile && cache.perFile.get(sourceFile.path)
83183                 : cache.allDiagnostics;
83184             if (cachedResult) {
83185                 return cachedResult;
83186             }
83187             var result = getDiagnostics(sourceFile, cancellationToken);
83188             if (sourceFile) {
83189                 if (!cache.perFile) {
83190                     cache.perFile = ts.createMap();
83191                 }
83192                 cache.perFile.set(sourceFile.path, result);
83193             }
83194             else {
83195                 cache.allDiagnostics = result;
83196             }
83197             return result;
83198         }
83199         function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) {
83200             return sourceFile.isDeclarationFile ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
83201         }
83202         function getOptionsDiagnostics() {
83203             return ts.sortAndDeduplicateDiagnostics(ts.concatenate(fileProcessingDiagnostics.getGlobalDiagnostics(), ts.concatenate(programDiagnostics.getGlobalDiagnostics(), getOptionsDiagnosticsOfConfigFile())));
83204         }
83205         function getOptionsDiagnosticsOfConfigFile() {
83206             if (!options.configFile) {
83207                 return ts.emptyArray;
83208             }
83209             var diagnostics = programDiagnostics.getDiagnostics(options.configFile.fileName);
83210             forEachResolvedProjectReference(function (resolvedRef) {
83211                 if (resolvedRef) {
83212                     diagnostics = ts.concatenate(diagnostics, programDiagnostics.getDiagnostics(resolvedRef.sourceFile.fileName));
83213                 }
83214             });
83215             return diagnostics;
83216         }
83217         function getGlobalDiagnostics() {
83218             return rootNames.length ? ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()) : ts.emptyArray;
83219         }
83220         function getConfigFileParsingDiagnostics() {
83221             return configFileParsingDiagnostics || ts.emptyArray;
83222         }
83223         function processRootFile(fileName, isDefaultLib, ignoreNoDefaultLib) {
83224             processSourceFile(ts.normalizePath(fileName), isDefaultLib, ignoreNoDefaultLib, undefined);
83225         }
83226         function fileReferenceIsEqualTo(a, b) {
83227             return a.fileName === b.fileName;
83228         }
83229         function moduleNameIsEqualTo(a, b) {
83230             return a.kind === 75
83231                 ? b.kind === 75 && a.escapedText === b.escapedText
83232                 : b.kind === 10 && a.text === b.text;
83233         }
83234         function collectExternalModuleReferences(file) {
83235             if (file.imports) {
83236                 return;
83237             }
83238             var isJavaScriptFile = ts.isSourceFileJS(file);
83239             var isExternalModuleFile = ts.isExternalModule(file);
83240             var imports;
83241             var moduleAugmentations;
83242             var ambientModules;
83243             if (options.importHelpers
83244                 && (options.isolatedModules || isExternalModuleFile)
83245                 && !file.isDeclarationFile) {
83246                 var externalHelpersModuleReference = ts.createLiteral(ts.externalHelpersModuleNameText);
83247                 var importDecl = ts.createImportDeclaration(undefined, undefined, undefined, externalHelpersModuleReference);
83248                 ts.addEmitFlags(importDecl, 67108864);
83249                 externalHelpersModuleReference.parent = importDecl;
83250                 importDecl.parent = file;
83251                 imports = [externalHelpersModuleReference];
83252             }
83253             for (var _i = 0, _a = file.statements; _i < _a.length; _i++) {
83254                 var node = _a[_i];
83255                 collectModuleReferences(node, false);
83256             }
83257             if ((file.flags & 1048576) || isJavaScriptFile) {
83258                 collectDynamicImportOrRequireCalls(file);
83259             }
83260             file.imports = imports || ts.emptyArray;
83261             file.moduleAugmentations = moduleAugmentations || ts.emptyArray;
83262             file.ambientModuleNames = ambientModules || ts.emptyArray;
83263             return;
83264             function collectModuleReferences(node, inAmbientModule) {
83265                 if (ts.isAnyImportOrReExport(node)) {
83266                     var moduleNameExpr = ts.getExternalModuleName(node);
83267                     if (moduleNameExpr && ts.isStringLiteral(moduleNameExpr) && moduleNameExpr.text && (!inAmbientModule || !ts.isExternalModuleNameRelative(moduleNameExpr.text))) {
83268                         imports = ts.append(imports, moduleNameExpr);
83269                     }
83270                 }
83271                 else if (ts.isModuleDeclaration(node)) {
83272                     if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || file.isDeclarationFile)) {
83273                         var nameText = ts.getTextOfIdentifierOrLiteral(node.name);
83274                         if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(nameText))) {
83275                             (moduleAugmentations || (moduleAugmentations = [])).push(node.name);
83276                         }
83277                         else if (!inAmbientModule) {
83278                             if (file.isDeclarationFile) {
83279                                 (ambientModules || (ambientModules = [])).push(nameText);
83280                             }
83281                             var body = node.body;
83282                             if (body) {
83283                                 for (var _i = 0, _a = body.statements; _i < _a.length; _i++) {
83284                                     var statement = _a[_i];
83285                                     collectModuleReferences(statement, true);
83286                                 }
83287                             }
83288                         }
83289                     }
83290                 }
83291             }
83292             function collectDynamicImportOrRequireCalls(file) {
83293                 var r = /import|require/g;
83294                 while (r.exec(file.text) !== null) {
83295                     var node = getNodeAtPosition(file, r.lastIndex);
83296                     if (ts.isRequireCall(node, true)) {
83297                         imports = ts.append(imports, node.arguments[0]);
83298                     }
83299                     else if (ts.isImportCall(node) && node.arguments.length === 1 && ts.isStringLiteralLike(node.arguments[0])) {
83300                         imports = ts.append(imports, node.arguments[0]);
83301                     }
83302                     else if (ts.isLiteralImportTypeNode(node)) {
83303                         imports = ts.append(imports, node.argument.literal);
83304                     }
83305                 }
83306             }
83307             function getNodeAtPosition(sourceFile, position) {
83308                 var current = sourceFile;
83309                 var getContainingChild = function (child) {
83310                     if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1)))) {
83311                         return child;
83312                     }
83313                 };
83314                 while (true) {
83315                     var child = isJavaScriptFile && ts.hasJSDocNodes(current) && ts.forEach(current.jsDoc, getContainingChild) || ts.forEachChild(current, getContainingChild);
83316                     if (!child) {
83317                         return current;
83318                     }
83319                     current = child;
83320                 }
83321             }
83322         }
83323         function getLibFileFromReference(ref) {
83324             var libName = ts.toFileNameLowerCase(ref.fileName);
83325             var libFileName = ts.libMap.get(libName);
83326             if (libFileName) {
83327                 return getSourceFile(ts.combinePaths(defaultLibraryPath, libFileName));
83328             }
83329         }
83330         function getSourceFileFromReference(referencingFile, ref) {
83331             return getSourceFileFromReferenceWorker(resolveTripleslashReference(ref.fileName, referencingFile.fileName), function (fileName) { return filesByName.get(toPath(fileName)) || undefined; });
83332         }
83333         function getSourceFileFromReferenceWorker(fileName, getSourceFile, fail, refFile) {
83334             if (ts.hasExtension(fileName)) {
83335                 var canonicalFileName_1 = host.getCanonicalFileName(fileName);
83336                 if (!options.allowNonTsExtensions && !ts.forEach(supportedExtensionsWithJsonIfResolveJsonModule, function (extension) { return ts.fileExtensionIs(canonicalFileName_1, extension); })) {
83337                     if (fail) {
83338                         if (ts.hasJSFileExtension(canonicalFileName_1)) {
83339                             fail(ts.Diagnostics.File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option, fileName);
83340                         }
83341                         else {
83342                             fail(ts.Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + supportedExtensions.join("', '") + "'");
83343                         }
83344                     }
83345                     return undefined;
83346                 }
83347                 var sourceFile = getSourceFile(fileName);
83348                 if (fail) {
83349                     if (!sourceFile) {
83350                         var redirect = getProjectReferenceRedirect(fileName);
83351                         if (redirect) {
83352                             fail(ts.Diagnostics.Output_file_0_has_not_been_built_from_source_file_1, redirect, fileName);
83353                         }
83354                         else {
83355                             fail(ts.Diagnostics.File_0_not_found, fileName);
83356                         }
83357                     }
83358                     else if (refFile && canonicalFileName_1 === host.getCanonicalFileName(refFile.fileName)) {
83359                         fail(ts.Diagnostics.A_file_cannot_have_a_reference_to_itself);
83360                     }
83361                 }
83362                 return sourceFile;
83363             }
83364             else {
83365                 var sourceFileNoExtension = options.allowNonTsExtensions && getSourceFile(fileName);
83366                 if (sourceFileNoExtension)
83367                     return sourceFileNoExtension;
83368                 if (fail && options.allowNonTsExtensions) {
83369                     fail(ts.Diagnostics.File_0_not_found, fileName);
83370                     return undefined;
83371                 }
83372                 var sourceFileWithAddedExtension = ts.forEach(supportedExtensions, function (extension) { return getSourceFile(fileName + extension); });
83373                 if (fail && !sourceFileWithAddedExtension)
83374                     fail(ts.Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + supportedExtensions.join("', '") + "'");
83375                 return sourceFileWithAddedExtension;
83376             }
83377         }
83378         function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile) {
83379             getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, packageId); }, function (diagnostic) {
83380                 var args = [];
83381                 for (var _i = 1; _i < arguments.length; _i++) {
83382                     args[_i - 1] = arguments[_i];
83383                 }
83384                 return fileProcessingDiagnostics.add(createRefFileDiagnostic.apply(void 0, __spreadArrays([refFile, diagnostic], args)));
83385             }, refFile && refFile.file);
83386         }
83387         function reportFileNamesDifferOnlyInCasingError(fileName, existingFile, refFile) {
83388             var refs = !refFile ? refFileMap && refFileMap.get(existingFile.path) : undefined;
83389             var refToReportErrorOn = refs && ts.find(refs, function (ref) { return ref.referencedFileName === existingFile.fileName; });
83390             fileProcessingDiagnostics.add(refToReportErrorOn ?
83391                 createFileDiagnosticAtReference(refToReportErrorOn, ts.Diagnostics.Already_included_file_name_0_differs_from_file_name_1_only_in_casing, existingFile.fileName, fileName) :
83392                 createRefFileDiagnostic(refFile, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFile.fileName));
83393         }
83394         function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) {
83395             var redirect = Object.create(redirectTarget);
83396             redirect.fileName = fileName;
83397             redirect.path = path;
83398             redirect.resolvedPath = resolvedPath;
83399             redirect.originalFileName = originalFileName;
83400             redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected };
83401             sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
83402             Object.defineProperties(redirect, {
83403                 id: {
83404                     get: function () { return this.redirectInfo.redirectTarget.id; },
83405                     set: function (value) { this.redirectInfo.redirectTarget.id = value; },
83406                 },
83407                 symbol: {
83408                     get: function () { return this.redirectInfo.redirectTarget.symbol; },
83409                     set: function (value) { this.redirectInfo.redirectTarget.symbol = value; },
83410                 },
83411             });
83412             return redirect;
83413         }
83414         function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) {
83415             if (useSourceOfProjectReferenceRedirect) {
83416                 var source = getSourceOfProjectReferenceRedirect(fileName);
83417                 if (!source &&
83418                     host.realpath &&
83419                     options.preserveSymlinks &&
83420                     ts.isDeclarationFileName(fileName) &&
83421                     ts.stringContains(fileName, ts.nodeModulesPathPart)) {
83422                     var realPath = host.realpath(fileName);
83423                     if (realPath !== fileName)
83424                         source = getSourceOfProjectReferenceRedirect(realPath);
83425                 }
83426                 if (source) {
83427                     var file_1 = ts.isString(source) ?
83428                         findSourceFile(source, toPath(source), isDefaultLib, ignoreNoDefaultLib, refFile, packageId) :
83429                         undefined;
83430                     if (file_1)
83431                         addFileToFilesByName(file_1, path, undefined);
83432                     return file_1;
83433                 }
83434             }
83435             var originalFileName = fileName;
83436             if (filesByName.has(path)) {
83437                 var file_2 = filesByName.get(path);
83438                 addFileToRefFileMap(fileName, file_2 || undefined, refFile);
83439                 if (file_2 && options.forceConsistentCasingInFileNames) {
83440                     var checkedName = file_2.fileName;
83441                     var isRedirect = toPath(checkedName) !== toPath(fileName);
83442                     if (isRedirect) {
83443                         fileName = getProjectReferenceRedirect(fileName) || fileName;
83444                     }
83445                     var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory);
83446                     var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory);
83447                     if (checkedAbsolutePath !== inputAbsolutePath) {
83448                         reportFileNamesDifferOnlyInCasingError(fileName, file_2, refFile);
83449                     }
83450                 }
83451                 if (file_2 && sourceFilesFoundSearchingNodeModules.get(file_2.path) && currentNodeModulesDepth === 0) {
83452                     sourceFilesFoundSearchingNodeModules.set(file_2.path, false);
83453                     if (!options.noResolve) {
83454                         processReferencedFiles(file_2, isDefaultLib);
83455                         processTypeReferenceDirectives(file_2);
83456                     }
83457                     if (!options.noLib) {
83458                         processLibReferenceDirectives(file_2);
83459                     }
83460                     modulesWithElidedImports.set(file_2.path, false);
83461                     processImportedModules(file_2);
83462                 }
83463                 else if (file_2 && modulesWithElidedImports.get(file_2.path)) {
83464                     if (currentNodeModulesDepth < maxNodeModuleJsDepth) {
83465                         modulesWithElidedImports.set(file_2.path, false);
83466                         processImportedModules(file_2);
83467                     }
83468                 }
83469                 return file_2 || undefined;
83470             }
83471             var redirectedPath;
83472             if (refFile && !useSourceOfProjectReferenceRedirect) {
83473                 var redirectProject = getProjectReferenceRedirectProject(fileName);
83474                 if (redirectProject) {
83475                     if (redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out) {
83476                         return undefined;
83477                     }
83478                     var redirect = getProjectReferenceOutputName(redirectProject, fileName);
83479                     fileName = redirect;
83480                     redirectedPath = toPath(redirect);
83481                 }
83482             }
83483             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);
83484             if (packageId) {
83485                 var packageIdKey = ts.packageIdToString(packageId);
83486                 var fileFromPackageId = packageIdToSourceFile.get(packageIdKey);
83487                 if (fileFromPackageId) {
83488                     var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName);
83489                     redirectTargetsMap.add(fileFromPackageId.path, fileName);
83490                     addFileToFilesByName(dupFile, path, redirectedPath);
83491                     sourceFileToPackageName.set(path, packageId.name);
83492                     processingOtherFiles.push(dupFile);
83493                     return dupFile;
83494                 }
83495                 else if (file) {
83496                     packageIdToSourceFile.set(packageIdKey, file);
83497                     sourceFileToPackageName.set(path, packageId.name);
83498                 }
83499             }
83500             addFileToFilesByName(file, path, redirectedPath);
83501             if (file) {
83502                 sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
83503                 file.fileName = fileName;
83504                 file.path = path;
83505                 file.resolvedPath = toPath(fileName);
83506                 file.originalFileName = originalFileName;
83507                 addFileToRefFileMap(fileName, file, refFile);
83508                 if (host.useCaseSensitiveFileNames()) {
83509                     var pathLowerCase = ts.toFileNameLowerCase(path);
83510                     var existingFile = filesByNameIgnoreCase.get(pathLowerCase);
83511                     if (existingFile) {
83512                         reportFileNamesDifferOnlyInCasingError(fileName, existingFile, refFile);
83513                     }
83514                     else {
83515                         filesByNameIgnoreCase.set(pathLowerCase, file);
83516                     }
83517                 }
83518                 skipDefaultLib = skipDefaultLib || (file.hasNoDefaultLib && !ignoreNoDefaultLib);
83519                 if (!options.noResolve) {
83520                     processReferencedFiles(file, isDefaultLib);
83521                     processTypeReferenceDirectives(file);
83522                 }
83523                 if (!options.noLib) {
83524                     processLibReferenceDirectives(file);
83525                 }
83526                 processImportedModules(file);
83527                 if (isDefaultLib) {
83528                     processingDefaultLibFiles.push(file);
83529                 }
83530                 else {
83531                     processingOtherFiles.push(file);
83532                 }
83533             }
83534             return file;
83535         }
83536         function addFileToRefFileMap(referencedFileName, file, refFile) {
83537             if (refFile && file) {
83538                 (refFileMap || (refFileMap = ts.createMultiMap())).add(file.path, {
83539                     referencedFileName: referencedFileName,
83540                     kind: refFile.kind,
83541                     index: refFile.index,
83542                     file: refFile.file.path
83543                 });
83544             }
83545         }
83546         function addFileToFilesByName(file, path, redirectedPath) {
83547             if (redirectedPath) {
83548                 filesByName.set(redirectedPath, file);
83549                 filesByName.set(path, file || false);
83550             }
83551             else {
83552                 filesByName.set(path, file);
83553             }
83554         }
83555         function getProjectReferenceRedirect(fileName) {
83556             var referencedProject = getProjectReferenceRedirectProject(fileName);
83557             return referencedProject && getProjectReferenceOutputName(referencedProject, fileName);
83558         }
83559         function getProjectReferenceRedirectProject(fileName) {
83560             if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts") || ts.fileExtensionIs(fileName, ".json")) {
83561                 return undefined;
83562             }
83563             return getResolvedProjectReferenceToRedirect(fileName);
83564         }
83565         function getProjectReferenceOutputName(referencedProject, fileName) {
83566             var out = referencedProject.commandLine.options.outFile || referencedProject.commandLine.options.out;
83567             return out ?
83568                 ts.changeExtension(out, ".d.ts") :
83569                 ts.getOutputDeclarationFileName(fileName, referencedProject.commandLine, !host.useCaseSensitiveFileNames());
83570         }
83571         function getResolvedProjectReferenceToRedirect(fileName) {
83572             if (mapFromFileToProjectReferenceRedirects === undefined) {
83573                 mapFromFileToProjectReferenceRedirects = ts.createMap();
83574                 forEachResolvedProjectReference(function (referencedProject, referenceProjectPath) {
83575                     if (referencedProject &&
83576                         toPath(options.configFilePath) !== referenceProjectPath) {
83577                         referencedProject.commandLine.fileNames.forEach(function (f) {
83578                             return mapFromFileToProjectReferenceRedirects.set(toPath(f), referenceProjectPath);
83579                         });
83580                     }
83581                 });
83582             }
83583             var referencedProjectPath = mapFromFileToProjectReferenceRedirects.get(toPath(fileName));
83584             return referencedProjectPath && getResolvedProjectReferenceByPath(referencedProjectPath);
83585         }
83586         function forEachResolvedProjectReference(cb) {
83587             return forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) {
83588                 var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
83589                 var resolvedRefPath = toPath(resolveProjectReferencePath(ref));
83590                 return cb(resolvedRef, resolvedRefPath);
83591             });
83592         }
83593         function getSourceOfProjectReferenceRedirect(file) {
83594             if (!ts.isDeclarationFileName(file))
83595                 return undefined;
83596             if (mapFromToProjectReferenceRedirectSource === undefined) {
83597                 mapFromToProjectReferenceRedirectSource = ts.createMap();
83598                 forEachResolvedProjectReference(function (resolvedRef) {
83599                     if (resolvedRef) {
83600                         var out = resolvedRef.commandLine.options.outFile || resolvedRef.commandLine.options.out;
83601                         if (out) {
83602                             var outputDts = ts.changeExtension(out, ".d.ts");
83603                             mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true);
83604                         }
83605                         else {
83606                             ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) {
83607                                 if (!ts.fileExtensionIs(fileName, ".d.ts") && !ts.fileExtensionIs(fileName, ".json")) {
83608                                     var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames());
83609                                     mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName);
83610                                 }
83611                             });
83612                         }
83613                     }
83614                 });
83615             }
83616             return mapFromToProjectReferenceRedirectSource.get(toPath(file));
83617         }
83618         function isSourceOfProjectReferenceRedirect(fileName) {
83619             return useSourceOfProjectReferenceRedirect && !!getResolvedProjectReferenceToRedirect(fileName);
83620         }
83621         function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) {
83622             var seenResolvedRefs;
83623             return worker(projectReferences, resolvedProjectReferences, undefined, cbResolvedRef, cbRef);
83624             function worker(projectReferences, resolvedProjectReferences, parent, cbResolvedRef, cbRef) {
83625                 if (cbRef) {
83626                     var result = cbRef(projectReferences, parent);
83627                     if (result) {
83628                         return result;
83629                     }
83630                 }
83631                 return ts.forEach(resolvedProjectReferences, function (resolvedRef, index) {
83632                     if (ts.contains(seenResolvedRefs, resolvedRef)) {
83633                         return undefined;
83634                     }
83635                     var result = cbResolvedRef(resolvedRef, index, parent);
83636                     if (result) {
83637                         return result;
83638                     }
83639                     if (!resolvedRef)
83640                         return undefined;
83641                     (seenResolvedRefs || (seenResolvedRefs = [])).push(resolvedRef);
83642                     return worker(resolvedRef.commandLine.projectReferences, resolvedRef.references, resolvedRef, cbResolvedRef, cbRef);
83643                 });
83644             }
83645         }
83646         function getResolvedProjectReferenceByPath(projectReferencePath) {
83647             if (!projectReferenceRedirects) {
83648                 return undefined;
83649             }
83650             return projectReferenceRedirects.get(projectReferencePath) || undefined;
83651         }
83652         function processReferencedFiles(file, isDefaultLib) {
83653             ts.forEach(file.referencedFiles, function (ref, index) {
83654                 var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName);
83655                 processSourceFile(referencedFileName, isDefaultLib, false, undefined, {
83656                     kind: ts.RefFileKind.ReferenceFile,
83657                     index: index,
83658                     file: file,
83659                     pos: ref.pos,
83660                     end: ref.end
83661                 });
83662             });
83663         }
83664         function processTypeReferenceDirectives(file) {
83665             var typeDirectives = ts.map(file.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
83666             if (!typeDirectives) {
83667                 return;
83668             }
83669             var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file.originalFileName, getResolvedProjectReferenceToRedirect(file.originalFileName));
83670             for (var i = 0; i < typeDirectives.length; i++) {
83671                 var ref = file.typeReferenceDirectives[i];
83672                 var resolvedTypeReferenceDirective = resolutions[i];
83673                 var fileName = ts.toFileNameLowerCase(ref.fileName);
83674                 ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
83675                 processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, {
83676                     kind: ts.RefFileKind.TypeReferenceDirective,
83677                     index: i,
83678                     file: file,
83679                     pos: ref.pos,
83680                     end: ref.end
83681                 });
83682             }
83683         }
83684         function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) {
83685             var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective);
83686             if (previousResolution && previousResolution.primary) {
83687                 return;
83688             }
83689             var saveResolution = true;
83690             if (resolvedTypeReferenceDirective) {
83691                 if (resolvedTypeReferenceDirective.isExternalLibraryImport)
83692                     currentNodeModulesDepth++;
83693                 if (resolvedTypeReferenceDirective.primary) {
83694                     processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile);
83695                 }
83696                 else {
83697                     if (previousResolution) {
83698                         if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) {
83699                             var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName);
83700                             var existingFile_1 = getSourceFile(previousResolution.resolvedFileName);
83701                             if (otherFileText !== existingFile_1.text) {
83702                                 var refs = !refFile ? refFileMap && refFileMap.get(existingFile_1.path) : undefined;
83703                                 var refToReportErrorOn = refs && ts.find(refs, function (ref) { return ref.referencedFileName === existingFile_1.fileName; });
83704                                 fileProcessingDiagnostics.add(refToReportErrorOn ?
83705                                     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) :
83706                                     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));
83707                             }
83708                         }
83709                         saveResolution = false;
83710                     }
83711                     else {
83712                         processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile);
83713                     }
83714                 }
83715                 if (resolvedTypeReferenceDirective.isExternalLibraryImport)
83716                     currentNodeModulesDepth--;
83717             }
83718             else {
83719                 fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective));
83720             }
83721             if (saveResolution) {
83722                 resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective);
83723             }
83724         }
83725         function processLibReferenceDirectives(file) {
83726             ts.forEach(file.libReferenceDirectives, function (libReference) {
83727                 var libName = ts.toFileNameLowerCase(libReference.fileName);
83728                 var libFileName = ts.libMap.get(libName);
83729                 if (libFileName) {
83730                     processRootFile(ts.combinePaths(defaultLibraryPath, libFileName), true, true);
83731                 }
83732                 else {
83733                     var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts");
83734                     var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity);
83735                     var message = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0;
83736                     fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, libReference.pos, libReference.end - libReference.pos, message, libName, suggestion));
83737                 }
83738             });
83739         }
83740         function createRefFileDiagnostic(refFile, message) {
83741             var args = [];
83742             for (var _i = 2; _i < arguments.length; _i++) {
83743                 args[_i - 2] = arguments[_i];
83744             }
83745             if (!refFile) {
83746                 return ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args));
83747             }
83748             else {
83749                 return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile.file, refFile.pos, refFile.end - refFile.pos, message], args));
83750             }
83751         }
83752         function getCanonicalFileName(fileName) {
83753             return host.getCanonicalFileName(fileName);
83754         }
83755         function processImportedModules(file) {
83756             collectExternalModuleReferences(file);
83757             if (file.imports.length || file.moduleAugmentations.length) {
83758                 var moduleNames = getModuleNames(file);
83759                 var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), file);
83760                 ts.Debug.assert(resolutions.length === moduleNames.length);
83761                 for (var i = 0; i < moduleNames.length; i++) {
83762                     var resolution = resolutions[i];
83763                     ts.setResolvedModule(file, moduleNames[i], resolution);
83764                     if (!resolution) {
83765                         continue;
83766                     }
83767                     var isFromNodeModulesSearch = resolution.isExternalLibraryImport;
83768                     var isJsFile = !ts.resolutionExtensionIsTSOrJson(resolution.extension);
83769                     var isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile;
83770                     var resolvedFileName = resolution.resolvedFileName;
83771                     if (isFromNodeModulesSearch) {
83772                         currentNodeModulesDepth++;
83773                     }
83774                     var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth;
83775                     var shouldAddFile = resolvedFileName
83776                         && !getResolutionDiagnostic(options, resolution)
83777                         && !options.noResolve
83778                         && i < file.imports.length
83779                         && !elideImport
83780                         && !(isJsFile && !options.allowJs)
83781                         && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 4194304));
83782                     if (elideImport) {
83783                         modulesWithElidedImports.set(file.path, true);
83784                     }
83785                     else if (shouldAddFile) {
83786                         var path = toPath(resolvedFileName);
83787                         var pos = ts.skipTrivia(file.text, file.imports[i].pos);
83788                         findSourceFile(resolvedFileName, path, false, false, {
83789                             kind: ts.RefFileKind.Import,
83790                             index: i,
83791                             file: file,
83792                             pos: pos,
83793                             end: file.imports[i].end
83794                         }, resolution.packageId);
83795                     }
83796                     if (isFromNodeModulesSearch) {
83797                         currentNodeModulesDepth--;
83798                     }
83799                 }
83800             }
83801             else {
83802                 file.resolvedModules = undefined;
83803             }
83804         }
83805         function computeCommonSourceDirectory(sourceFiles) {
83806             var fileNames = ts.mapDefined(sourceFiles, function (file) { return file.isDeclarationFile ? undefined : file.fileName; });
83807             return computeCommonSourceDirectoryOfFilenames(fileNames, currentDirectory, getCanonicalFileName);
83808         }
83809         function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) {
83810             var allFilesBelongToPath = true;
83811             var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory));
83812             var rootPaths;
83813             for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) {
83814                 var sourceFile = sourceFiles_2[_i];
83815                 if (!sourceFile.isDeclarationFile) {
83816                     var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
83817                     if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {
83818                         if (!rootPaths)
83819                             rootPaths = ts.arrayToSet(rootNames, toPath);
83820                         addProgramDiagnosticAtRefPath(sourceFile, rootPaths, ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory);
83821                         allFilesBelongToPath = false;
83822                     }
83823                 }
83824             }
83825             return allFilesBelongToPath;
83826         }
83827         function parseProjectReferenceConfigFile(ref) {
83828             if (!projectReferenceRedirects) {
83829                 projectReferenceRedirects = ts.createMap();
83830             }
83831             var refPath = resolveProjectReferencePath(ref);
83832             var sourceFilePath = toPath(refPath);
83833             var fromCache = projectReferenceRedirects.get(sourceFilePath);
83834             if (fromCache !== undefined) {
83835                 return fromCache || undefined;
83836             }
83837             var commandLine;
83838             var sourceFile;
83839             if (host.getParsedCommandLine) {
83840                 commandLine = host.getParsedCommandLine(refPath);
83841                 if (!commandLine) {
83842                     addFileToFilesByName(undefined, sourceFilePath, undefined);
83843                     projectReferenceRedirects.set(sourceFilePath, false);
83844                     return undefined;
83845                 }
83846                 sourceFile = ts.Debug.checkDefined(commandLine.options.configFile);
83847                 ts.Debug.assert(!sourceFile.path || sourceFile.path === sourceFilePath);
83848                 addFileToFilesByName(sourceFile, sourceFilePath, undefined);
83849             }
83850             else {
83851                 var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory());
83852                 sourceFile = host.getSourceFile(refPath, 100);
83853                 addFileToFilesByName(sourceFile, sourceFilePath, undefined);
83854                 if (sourceFile === undefined) {
83855                     projectReferenceRedirects.set(sourceFilePath, false);
83856                     return undefined;
83857                 }
83858                 commandLine = ts.parseJsonSourceFileConfigFileContent(sourceFile, configParsingHost, basePath, undefined, refPath);
83859             }
83860             sourceFile.fileName = refPath;
83861             sourceFile.path = sourceFilePath;
83862             sourceFile.resolvedPath = sourceFilePath;
83863             sourceFile.originalFileName = refPath;
83864             var resolvedRef = { commandLine: commandLine, sourceFile: sourceFile };
83865             projectReferenceRedirects.set(sourceFilePath, resolvedRef);
83866             if (commandLine.projectReferences) {
83867                 resolvedRef.references = commandLine.projectReferences.map(parseProjectReferenceConfigFile);
83868             }
83869             return resolvedRef;
83870         }
83871         function verifyCompilerOptions() {
83872             if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) {
83873                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks");
83874             }
83875             if (options.isolatedModules) {
83876                 if (options.out) {
83877                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules");
83878                 }
83879                 if (options.outFile) {
83880                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules");
83881                 }
83882             }
83883             if (options.inlineSourceMap) {
83884                 if (options.sourceMap) {
83885                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap");
83886                 }
83887                 if (options.mapRoot) {
83888                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap");
83889                 }
83890             }
83891             if (options.paths && options.baseUrl === undefined) {
83892                 createDiagnosticForOptionName(ts.Diagnostics.Option_paths_cannot_be_used_without_specifying_baseUrl_option, "paths");
83893             }
83894             if (options.composite) {
83895                 if (options.declaration === false) {
83896                     createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_declaration_emit, "declaration");
83897                 }
83898                 if (options.incremental === false) {
83899                     createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_incremental_compilation, "declaration");
83900                 }
83901             }
83902             if (options.tsBuildInfoFile) {
83903                 if (!ts.isIncrementalCompilation(options)) {
83904                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "tsBuildInfoFile", "incremental", "composite");
83905                 }
83906             }
83907             else if (options.incremental && !options.outFile && !options.out && !options.configFilePath) {
83908                 programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified));
83909             }
83910             if (!options.listFilesOnly && options.noEmit && ts.isIncrementalCompilation(options)) {
83911                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", options.incremental ? "incremental" : "composite");
83912             }
83913             verifyProjectReferences();
83914             if (options.composite) {
83915                 var rootPaths = ts.arrayToSet(rootNames, toPath);
83916                 for (var _i = 0, files_3 = files; _i < files_3.length; _i++) {
83917                     var file = files_3[_i];
83918                     if (ts.sourceFileMayBeEmitted(file, program) && !rootPaths.has(file.path)) {
83919                         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 || "");
83920                     }
83921                 }
83922             }
83923             if (options.paths) {
83924                 for (var key in options.paths) {
83925                     if (!ts.hasProperty(options.paths, key)) {
83926                         continue;
83927                     }
83928                     if (!ts.hasZeroOrOneAsteriskCharacter(key)) {
83929                         createDiagnosticForOptionPaths(true, key, ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, key);
83930                     }
83931                     if (ts.isArray(options.paths[key])) {
83932                         var len = options.paths[key].length;
83933                         if (len === 0) {
83934                             createDiagnosticForOptionPaths(false, key, ts.Diagnostics.Substitutions_for_pattern_0_shouldn_t_be_an_empty_array, key);
83935                         }
83936                         for (var i = 0; i < len; i++) {
83937                             var subst = options.paths[key][i];
83938                             var typeOfSubst = typeof subst;
83939                             if (typeOfSubst === "string") {
83940                                 if (!ts.hasZeroOrOneAsteriskCharacter(subst)) {
83941                                     createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character, subst, key);
83942                                 }
83943                             }
83944                             else {
83945                                 createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2, subst, key, typeOfSubst);
83946                             }
83947                         }
83948                     }
83949                     else {
83950                         createDiagnosticForOptionPaths(false, key, ts.Diagnostics.Substitutions_for_pattern_0_should_be_an_array, key);
83951                     }
83952                 }
83953             }
83954             if (!options.sourceMap && !options.inlineSourceMap) {
83955                 if (options.inlineSources) {
83956                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided, "inlineSources");
83957                 }
83958                 if (options.sourceRoot) {
83959                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided, "sourceRoot");
83960                 }
83961             }
83962             if (options.out && options.outFile) {
83963                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile");
83964             }
83965             if (options.mapRoot && !(options.sourceMap || options.declarationMap)) {
83966                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "mapRoot", "sourceMap", "declarationMap");
83967             }
83968             if (options.declarationDir) {
83969                 if (!ts.getEmitDeclarations(options)) {
83970                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "declarationDir", "declaration", "composite");
83971                 }
83972                 if (options.out || options.outFile) {
83973                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declarationDir", options.out ? "out" : "outFile");
83974                 }
83975             }
83976             if (options.declarationMap && !ts.getEmitDeclarations(options)) {
83977                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "declarationMap", "declaration", "composite");
83978             }
83979             if (options.lib && options.noLib) {
83980                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib");
83981             }
83982             if (options.noImplicitUseStrict && ts.getStrictOptionValue(options, "alwaysStrict")) {
83983                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict");
83984             }
83985             var languageVersion = options.target || 0;
83986             var outFile = options.outFile || options.out;
83987             var firstNonAmbientExternalModuleSourceFile = ts.find(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile; });
83988             if (options.isolatedModules) {
83989                 if (options.module === ts.ModuleKind.None && languageVersion < 2) {
83990                     createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target");
83991                 }
83992                 var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6; });
83993                 if (firstNonExternalModuleSourceFile) {
83994                     var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
83995                     programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.All_files_must_be_modules_when_the_isolatedModules_flag_is_provided));
83996                 }
83997             }
83998             else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 && options.module === ts.ModuleKind.None) {
83999                 var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
84000                 programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
84001             }
84002             if (outFile && !options.emitDeclarationOnly) {
84003                 if (options.module && !(options.module === ts.ModuleKind.AMD || options.module === ts.ModuleKind.System)) {
84004                     createDiagnosticForOptionName(ts.Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile", "module");
84005                 }
84006                 else if (options.module === undefined && firstNonAmbientExternalModuleSourceFile) {
84007                     var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
84008                     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"));
84009                 }
84010             }
84011             if (options.resolveJsonModule) {
84012                 if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs) {
84013                     createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule");
84014                 }
84015                 else if (!ts.hasJsonModuleEmitEnabled(options)) {
84016                     createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext, "resolveJsonModule", "module");
84017                 }
84018             }
84019             if (options.outDir ||
84020                 options.sourceRoot ||
84021                 options.mapRoot) {
84022                 var dir = getCommonSourceDirectory();
84023                 if (options.outDir && dir === "" && files.some(function (file) { return ts.getRootLength(file.fileName) > 1; })) {
84024                     createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir");
84025                 }
84026             }
84027             if (options.useDefineForClassFields && languageVersion === 0) {
84028                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields");
84029             }
84030             if (options.checkJs && !options.allowJs) {
84031                 programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs"));
84032             }
84033             if (options.emitDeclarationOnly) {
84034                 if (!ts.getEmitDeclarations(options)) {
84035                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "emitDeclarationOnly", "declaration", "composite");
84036                 }
84037                 if (options.noEmit) {
84038                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "emitDeclarationOnly", "noEmit");
84039                 }
84040             }
84041             if (options.emitDecoratorMetadata &&
84042                 !options.experimentalDecorators) {
84043                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators");
84044             }
84045             if (options.jsxFactory) {
84046                 if (options.reactNamespace) {
84047                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory");
84048                 }
84049                 if (!ts.parseIsolatedEntityName(options.jsxFactory, languageVersion)) {
84050                     createOptionValueDiagnostic("jsxFactory", ts.Diagnostics.Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name, options.jsxFactory);
84051                 }
84052             }
84053             else if (options.reactNamespace && !ts.isIdentifierText(options.reactNamespace, languageVersion)) {
84054                 createOptionValueDiagnostic("reactNamespace", ts.Diagnostics.Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier, options.reactNamespace);
84055             }
84056             if (!options.noEmit && !options.suppressOutputPathCheck) {
84057                 var emitHost = getEmitHost();
84058                 var emitFilesSeen_1 = ts.createMap();
84059                 ts.forEachEmittedFile(emitHost, function (emitFileNames) {
84060                     if (!options.emitDeclarationOnly) {
84061                         verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1);
84062                     }
84063                     verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1);
84064                 });
84065             }
84066             function verifyEmitFilePath(emitFileName, emitFilesSeen) {
84067                 if (emitFileName) {
84068                     var emitFilePath = toPath(emitFileName);
84069                     if (filesByName.has(emitFilePath)) {
84070                         var chain = void 0;
84071                         if (!options.configFilePath) {
84072                             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);
84073                         }
84074                         chain = ts.chainDiagnosticMessages(chain, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName);
84075                         blockEmittingOfFile(emitFileName, ts.createCompilerDiagnosticFromMessageChain(chain));
84076                     }
84077                     var emitFileKey = !host.useCaseSensitiveFileNames() ? ts.toFileNameLowerCase(emitFilePath) : emitFilePath;
84078                     if (emitFilesSeen.has(emitFileKey)) {
84079                         blockEmittingOfFile(emitFileName, ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, emitFileName));
84080                     }
84081                     else {
84082                         emitFilesSeen.set(emitFileKey, true);
84083                     }
84084                 }
84085             }
84086         }
84087         function createFileDiagnosticAtReference(refPathToReportErrorOn, message) {
84088             var _a, _b;
84089             var args = [];
84090             for (var _i = 2; _i < arguments.length; _i++) {
84091                 args[_i - 2] = arguments[_i];
84092             }
84093             var refFile = ts.Debug.checkDefined(getSourceFileByPath(refPathToReportErrorOn.file));
84094             var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index;
84095             var pos, end;
84096             switch (kind) {
84097                 case ts.RefFileKind.Import:
84098                     pos = ts.skipTrivia(refFile.text, refFile.imports[index].pos);
84099                     end = refFile.imports[index].end;
84100                     break;
84101                 case ts.RefFileKind.ReferenceFile:
84102                     (_a = refFile.referencedFiles[index], pos = _a.pos, end = _a.end);
84103                     break;
84104                 case ts.RefFileKind.TypeReferenceDirective:
84105                     (_b = refFile.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
84106                     break;
84107                 default:
84108                     return ts.Debug.assertNever(kind);
84109             }
84110             return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, pos, end - pos, message], args));
84111         }
84112         function addProgramDiagnosticAtRefPath(file, rootPaths, message) {
84113             var args = [];
84114             for (var _i = 3; _i < arguments.length; _i++) {
84115                 args[_i - 3] = arguments[_i];
84116             }
84117             var refPaths = refFileMap && refFileMap.get(file.path);
84118             var refPathToReportErrorOn = ts.forEach(refPaths, function (refPath) { return rootPaths.has(refPath.file) ? refPath : undefined; }) ||
84119                 ts.elementAt(refPaths, 0);
84120             programDiagnostics.add(refPathToReportErrorOn ? createFileDiagnosticAtReference.apply(void 0, __spreadArrays([refPathToReportErrorOn, message], args)) : ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)));
84121         }
84122         function verifyProjectReferences() {
84123             var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getTsBuildInfoEmitOutputFilePath(options) : undefined;
84124             forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) {
84125                 var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
84126                 var parentFile = parent && parent.sourceFile;
84127                 if (!resolvedRef) {
84128                     createDiagnosticForReference(parentFile, index, ts.Diagnostics.File_0_not_found, ref.path);
84129                     return;
84130                 }
84131                 var options = resolvedRef.commandLine.options;
84132                 if (!options.composite) {
84133                     var inputs = parent ? parent.commandLine.fileNames : rootNames;
84134                     if (inputs.length) {
84135                         createDiagnosticForReference(parentFile, index, ts.Diagnostics.Referenced_project_0_must_have_setting_composite_Colon_true, ref.path);
84136                     }
84137                 }
84138                 if (ref.prepend) {
84139                     var out = options.outFile || options.out;
84140                     if (out) {
84141                         if (!host.fileExists(out)) {
84142                             createDiagnosticForReference(parentFile, index, ts.Diagnostics.Output_file_0_from_project_1_does_not_exist, out, ref.path);
84143                         }
84144                     }
84145                     else {
84146                         createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path);
84147                     }
84148                 }
84149                 if (!parent && buildInfoPath && buildInfoPath === ts.getTsBuildInfoEmitOutputFilePath(options)) {
84150                     createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path);
84151                     hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true);
84152                 }
84153             });
84154         }
84155         function createDiagnosticForOptionPathKeyValue(key, valueIndex, message, arg0, arg1, arg2) {
84156             var needCompilerDiagnostic = true;
84157             var pathsSyntax = getOptionPathsSyntax();
84158             for (var _i = 0, pathsSyntax_1 = pathsSyntax; _i < pathsSyntax_1.length; _i++) {
84159                 var pathProp = pathsSyntax_1[_i];
84160                 if (ts.isObjectLiteralExpression(pathProp.initializer)) {
84161                     for (var _a = 0, _b = ts.getPropertyAssignment(pathProp.initializer, key); _a < _b.length; _a++) {
84162                         var keyProps = _b[_a];
84163                         var initializer = keyProps.initializer;
84164                         if (ts.isArrayLiteralExpression(initializer) && initializer.elements.length > valueIndex) {
84165                             programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, initializer.elements[valueIndex], message, arg0, arg1, arg2));
84166                             needCompilerDiagnostic = false;
84167                         }
84168                     }
84169                 }
84170             }
84171             if (needCompilerDiagnostic) {
84172                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1, arg2));
84173             }
84174         }
84175         function createDiagnosticForOptionPaths(onKey, key, message, arg0) {
84176             var needCompilerDiagnostic = true;
84177             var pathsSyntax = getOptionPathsSyntax();
84178             for (var _i = 0, pathsSyntax_2 = pathsSyntax; _i < pathsSyntax_2.length; _i++) {
84179                 var pathProp = pathsSyntax_2[_i];
84180                 if (ts.isObjectLiteralExpression(pathProp.initializer) &&
84181                     createOptionDiagnosticInObjectLiteralSyntax(pathProp.initializer, onKey, key, undefined, message, arg0)) {
84182                     needCompilerDiagnostic = false;
84183                 }
84184             }
84185             if (needCompilerDiagnostic) {
84186                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0));
84187             }
84188         }
84189         function getOptionsSyntaxByName(name) {
84190             var compilerOptionsObjectLiteralSyntax = getCompilerOptionsObjectLiteralSyntax();
84191             if (compilerOptionsObjectLiteralSyntax) {
84192                 return ts.getPropertyAssignment(compilerOptionsObjectLiteralSyntax, name);
84193             }
84194             return undefined;
84195         }
84196         function getOptionPathsSyntax() {
84197             return getOptionsSyntaxByName("paths") || ts.emptyArray;
84198         }
84199         function createDiagnosticForOptionName(message, option1, option2, option3) {
84200             createDiagnosticForOption(true, option1, option2, message, option1, option2, option3);
84201         }
84202         function createOptionValueDiagnostic(option1, message, arg0) {
84203             createDiagnosticForOption(false, option1, undefined, message, arg0);
84204         }
84205         function createDiagnosticForReference(sourceFile, index, message, arg0, arg1) {
84206             var referencesSyntax = ts.firstDefined(ts.getTsConfigPropArray(sourceFile || options.configFile, "references"), function (property) { return ts.isArrayLiteralExpression(property.initializer) ? property.initializer : undefined; });
84207             if (referencesSyntax && referencesSyntax.elements.length > index) {
84208                 programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(sourceFile || options.configFile, referencesSyntax.elements[index], message, arg0, arg1));
84209             }
84210             else {
84211                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1));
84212             }
84213         }
84214         function createDiagnosticForOption(onKey, option1, option2, message, arg0, arg1, arg2) {
84215             var compilerOptionsObjectLiteralSyntax = getCompilerOptionsObjectLiteralSyntax();
84216             var needCompilerDiagnostic = !compilerOptionsObjectLiteralSyntax ||
84217                 !createOptionDiagnosticInObjectLiteralSyntax(compilerOptionsObjectLiteralSyntax, onKey, option1, option2, message, arg0, arg1, arg2);
84218             if (needCompilerDiagnostic) {
84219                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1, arg2));
84220             }
84221         }
84222         function getCompilerOptionsObjectLiteralSyntax() {
84223             if (_compilerOptionsObjectLiteralSyntax === undefined) {
84224                 _compilerOptionsObjectLiteralSyntax = null;
84225                 var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile);
84226                 if (jsonObjectLiteral) {
84227                     for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "compilerOptions"); _i < _a.length; _i++) {
84228                         var prop = _a[_i];
84229                         if (ts.isObjectLiteralExpression(prop.initializer)) {
84230                             _compilerOptionsObjectLiteralSyntax = prop.initializer;
84231                             break;
84232                         }
84233                     }
84234                 }
84235             }
84236             return _compilerOptionsObjectLiteralSyntax;
84237         }
84238         function createOptionDiagnosticInObjectLiteralSyntax(objectLiteral, onKey, key1, key2, message, arg0, arg1, arg2) {
84239             var props = ts.getPropertyAssignment(objectLiteral, key1, key2);
84240             for (var _i = 0, props_3 = props; _i < props_3.length; _i++) {
84241                 var prop = props_3[_i];
84242                 programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, onKey ? prop.name : prop.initializer, message, arg0, arg1, arg2));
84243             }
84244             return !!props.length;
84245         }
84246         function blockEmittingOfFile(emitFileName, diag) {
84247             hasEmitBlockingDiagnostics.set(toPath(emitFileName), true);
84248             programDiagnostics.add(diag);
84249         }
84250         function isEmittedFile(file) {
84251             if (options.noEmit) {
84252                 return false;
84253             }
84254             var filePath = toPath(file);
84255             if (getSourceFileByPath(filePath)) {
84256                 return false;
84257             }
84258             var out = options.outFile || options.out;
84259             if (out) {
84260                 return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts");
84261             }
84262             if (options.declarationDir && ts.containsPath(options.declarationDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames())) {
84263                 return true;
84264             }
84265             if (options.outDir) {
84266                 return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames());
84267             }
84268             if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensions) || ts.fileExtensionIs(filePath, ".d.ts")) {
84269                 var filePathWithoutExtension = ts.removeFileExtension(filePath);
84270                 return !!getSourceFileByPath((filePathWithoutExtension + ".ts")) ||
84271                     !!getSourceFileByPath((filePathWithoutExtension + ".tsx"));
84272             }
84273             return false;
84274         }
84275         function isSameFile(file1, file2) {
84276             return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0;
84277         }
84278         function getProbableSymlinks() {
84279             if (host.getSymlinks) {
84280                 return host.getSymlinks();
84281             }
84282             return symlinks || (symlinks = ts.discoverProbableSymlinks(files, getCanonicalFileName, host.getCurrentDirectory()));
84283         }
84284     }
84285     ts.createProgram = createProgram;
84286     function updateHostForUseSourceOfProjectReferenceRedirect(host) {
84287         var mapOfDeclarationDirectories;
84288         var symlinkedDirectories;
84289         var symlinkedFiles;
84290         var originalFileExists = host.compilerHost.fileExists;
84291         var originalDirectoryExists = host.compilerHost.directoryExists;
84292         var originalGetDirectories = host.compilerHost.getDirectories;
84293         var originalRealpath = host.compilerHost.realpath;
84294         if (!host.useSourceOfProjectReferenceRedirect)
84295             return { onProgramCreateComplete: ts.noop, fileExists: fileExists };
84296         host.compilerHost.fileExists = fileExists;
84297         if (originalDirectoryExists) {
84298             host.compilerHost.directoryExists = function (path) {
84299                 if (originalDirectoryExists.call(host.compilerHost, path)) {
84300                     handleDirectoryCouldBeSymlink(path);
84301                     return true;
84302                 }
84303                 if (!host.getResolvedProjectReferences())
84304                     return false;
84305                 if (!mapOfDeclarationDirectories) {
84306                     mapOfDeclarationDirectories = ts.createMap();
84307                     host.forEachResolvedProjectReference(function (ref) {
84308                         if (!ref)
84309                             return;
84310                         var out = ref.commandLine.options.outFile || ref.commandLine.options.out;
84311                         if (out) {
84312                             mapOfDeclarationDirectories.set(ts.getDirectoryPath(host.toPath(out)), true);
84313                         }
84314                         else {
84315                             var declarationDir = ref.commandLine.options.declarationDir || ref.commandLine.options.outDir;
84316                             if (declarationDir) {
84317                                 mapOfDeclarationDirectories.set(host.toPath(declarationDir), true);
84318                             }
84319                         }
84320                     });
84321                 }
84322                 return fileOrDirectoryExistsUsingSource(path, false);
84323             };
84324         }
84325         if (originalGetDirectories) {
84326             host.compilerHost.getDirectories = function (path) {
84327                 return !host.getResolvedProjectReferences() || (originalDirectoryExists && originalDirectoryExists.call(host.compilerHost, path)) ?
84328                     originalGetDirectories.call(host.compilerHost, path) :
84329                     [];
84330             };
84331         }
84332         if (originalRealpath) {
84333             host.compilerHost.realpath = function (s) {
84334                 return (symlinkedFiles === null || symlinkedFiles === void 0 ? void 0 : symlinkedFiles.get(host.toPath(s))) ||
84335                     originalRealpath.call(host.compilerHost, s);
84336             };
84337         }
84338         return { onProgramCreateComplete: onProgramCreateComplete, fileExists: fileExists };
84339         function onProgramCreateComplete() {
84340             host.compilerHost.fileExists = originalFileExists;
84341             host.compilerHost.directoryExists = originalDirectoryExists;
84342             host.compilerHost.getDirectories = originalGetDirectories;
84343         }
84344         function fileExists(file) {
84345             if (originalFileExists.call(host.compilerHost, file))
84346                 return true;
84347             if (!host.getResolvedProjectReferences())
84348                 return false;
84349             if (!ts.isDeclarationFileName(file))
84350                 return false;
84351             return fileOrDirectoryExistsUsingSource(file, true);
84352         }
84353         function fileExistsIfProjectReferenceDts(file) {
84354             var source = host.getSourceOfProjectReferenceRedirect(file);
84355             return source !== undefined ?
84356                 ts.isString(source) ? originalFileExists.call(host.compilerHost, source) : true :
84357                 undefined;
84358         }
84359         function directoryExistsIfProjectReferenceDeclDir(dir) {
84360             var dirPath = host.toPath(dir);
84361             var dirPathWithTrailingDirectorySeparator = "" + dirPath + ts.directorySeparator;
84362             return ts.forEachKey(mapOfDeclarationDirectories, function (declDirPath) { return dirPath === declDirPath ||
84363                 ts.startsWith(declDirPath, dirPathWithTrailingDirectorySeparator) ||
84364                 ts.startsWith(dirPath, declDirPath + "/"); });
84365         }
84366         function handleDirectoryCouldBeSymlink(directory) {
84367             if (!host.getResolvedProjectReferences())
84368                 return;
84369             if (!originalRealpath || !ts.stringContains(directory, ts.nodeModulesPathPart))
84370                 return;
84371             if (!symlinkedDirectories)
84372                 symlinkedDirectories = ts.createMap();
84373             var directoryPath = ts.ensureTrailingDirectorySeparator(host.toPath(directory));
84374             if (symlinkedDirectories.has(directoryPath))
84375                 return;
84376             var real = ts.normalizePath(originalRealpath.call(host.compilerHost, directory));
84377             var realPath;
84378             if (real === directory ||
84379                 (realPath = ts.ensureTrailingDirectorySeparator(host.toPath(real))) === directoryPath) {
84380                 symlinkedDirectories.set(directoryPath, false);
84381                 return;
84382             }
84383             symlinkedDirectories.set(directoryPath, {
84384                 real: ts.ensureTrailingDirectorySeparator(real),
84385                 realPath: realPath
84386             });
84387         }
84388         function fileOrDirectoryExistsUsingSource(fileOrDirectory, isFile) {
84389             var fileOrDirectoryExistsUsingSource = isFile ?
84390                 function (file) { return fileExistsIfProjectReferenceDts(file); } :
84391                 function (dir) { return directoryExistsIfProjectReferenceDeclDir(dir); };
84392             var result = fileOrDirectoryExistsUsingSource(fileOrDirectory);
84393             if (result !== undefined)
84394                 return result;
84395             if (!symlinkedDirectories)
84396                 return false;
84397             var fileOrDirectoryPath = host.toPath(fileOrDirectory);
84398             if (!ts.stringContains(fileOrDirectoryPath, ts.nodeModulesPathPart))
84399                 return false;
84400             if (isFile && symlinkedFiles && symlinkedFiles.has(fileOrDirectoryPath))
84401                 return true;
84402             return ts.firstDefinedIterator(symlinkedDirectories.entries(), function (_a) {
84403                 var directoryPath = _a[0], symlinkedDirectory = _a[1];
84404                 if (!symlinkedDirectory || !ts.startsWith(fileOrDirectoryPath, directoryPath))
84405                     return undefined;
84406                 var result = fileOrDirectoryExistsUsingSource(fileOrDirectoryPath.replace(directoryPath, symlinkedDirectory.realPath));
84407                 if (isFile && result) {
84408                     if (!symlinkedFiles)
84409                         symlinkedFiles = ts.createMap();
84410                     var absolutePath = ts.getNormalizedAbsolutePath(fileOrDirectory, host.compilerHost.getCurrentDirectory());
84411                     symlinkedFiles.set(fileOrDirectoryPath, "" + symlinkedDirectory.real + absolutePath.replace(new RegExp(directoryPath, "i"), ""));
84412                 }
84413                 return result;
84414             }) || false;
84415         }
84416     }
84417     function handleNoEmitOptions(program, sourceFile, cancellationToken) {
84418         var options = program.getCompilerOptions();
84419         if (options.noEmit) {
84420             return { diagnostics: ts.emptyArray, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true };
84421         }
84422         if (!options.noEmitOnError)
84423             return undefined;
84424         var diagnostics = __spreadArrays(program.getOptionsDiagnostics(cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken));
84425         if (diagnostics.length === 0 && ts.getEmitDeclarations(program.getCompilerOptions())) {
84426             diagnostics = program.getDeclarationDiagnostics(undefined, cancellationToken);
84427         }
84428         return diagnostics.length > 0 ?
84429             { diagnostics: diagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true } :
84430             undefined;
84431     }
84432     ts.handleNoEmitOptions = handleNoEmitOptions;
84433     function parseConfigHostFromCompilerHostLike(host, directoryStructureHost) {
84434         if (directoryStructureHost === void 0) { directoryStructureHost = host; }
84435         return {
84436             fileExists: function (f) { return directoryStructureHost.fileExists(f); },
84437             readDirectory: function (root, extensions, excludes, includes, depth) {
84438                 ts.Debug.assertIsDefined(directoryStructureHost.readDirectory, "'CompilerHost.readDirectory' must be implemented to correctly process 'projectReferences'");
84439                 return directoryStructureHost.readDirectory(root, extensions, excludes, includes, depth);
84440             },
84441             readFile: function (f) { return directoryStructureHost.readFile(f); },
84442             useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(),
84443             getCurrentDirectory: function () { return host.getCurrentDirectory(); },
84444             onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic || ts.returnUndefined,
84445             trace: host.trace ? function (s) { return host.trace(s); } : undefined
84446         };
84447     }
84448     ts.parseConfigHostFromCompilerHostLike = parseConfigHostFromCompilerHostLike;
84449     function createPrependNodes(projectReferences, getCommandLine, readFile) {
84450         if (!projectReferences)
84451             return ts.emptyArray;
84452         var nodes;
84453         for (var i = 0; i < projectReferences.length; i++) {
84454             var ref = projectReferences[i];
84455             var resolvedRefOpts = getCommandLine(ref, i);
84456             if (ref.prepend && resolvedRefOpts && resolvedRefOpts.options) {
84457                 var out = resolvedRefOpts.options.outFile || resolvedRefOpts.options.out;
84458                 if (!out)
84459                     continue;
84460                 var _a = ts.getOutputPathsForBundle(resolvedRefOpts.options, true), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
84461                 var node = ts.createInputFiles(readFile, jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath);
84462                 (nodes || (nodes = [])).push(node);
84463             }
84464         }
84465         return nodes || ts.emptyArray;
84466     }
84467     ts.createPrependNodes = createPrependNodes;
84468     function resolveProjectReferencePath(hostOrRef, ref) {
84469         var passedInRef = ref ? ref : hostOrRef;
84470         return ts.resolveConfigFileProjectName(passedInRef.path);
84471     }
84472     ts.resolveProjectReferencePath = resolveProjectReferencePath;
84473     function getResolutionDiagnostic(options, _a) {
84474         var extension = _a.extension;
84475         switch (extension) {
84476             case ".ts":
84477             case ".d.ts":
84478                 return undefined;
84479             case ".tsx":
84480                 return needJsx();
84481             case ".jsx":
84482                 return needJsx() || needAllowJs();
84483             case ".js":
84484                 return needAllowJs();
84485             case ".json":
84486                 return needResolveJsonModule();
84487         }
84488         function needJsx() {
84489             return options.jsx ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set;
84490         }
84491         function needAllowJs() {
84492             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;
84493         }
84494         function needResolveJsonModule() {
84495             return options.resolveJsonModule ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used;
84496         }
84497     }
84498     ts.getResolutionDiagnostic = getResolutionDiagnostic;
84499     function getModuleNames(_a) {
84500         var imports = _a.imports, moduleAugmentations = _a.moduleAugmentations;
84501         var res = imports.map(function (i) { return i.text; });
84502         for (var _i = 0, moduleAugmentations_1 = moduleAugmentations; _i < moduleAugmentations_1.length; _i++) {
84503             var aug = moduleAugmentations_1[_i];
84504             if (aug.kind === 10) {
84505                 res.push(aug.text);
84506             }
84507         }
84508         return res;
84509     }
84510 })(ts || (ts = {}));
84511 var ts;
84512 (function (ts) {
84513     function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) {
84514         var outputFiles = [];
84515         var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics, exportedModulesFromDeclarationEmit = _a.exportedModulesFromDeclarationEmit;
84516         return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics, exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit };
84517         function writeFile(fileName, text, writeByteOrderMark) {
84518             outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text });
84519         }
84520     }
84521     ts.getFileEmitOutput = getFileEmitOutput;
84522     var BuilderState;
84523     (function (BuilderState) {
84524         function getReferencedFileFromImportedModuleSymbol(symbol) {
84525             if (symbol.declarations && symbol.declarations[0]) {
84526                 var declarationSourceFile = ts.getSourceFileOfNode(symbol.declarations[0]);
84527                 return declarationSourceFile && declarationSourceFile.resolvedPath;
84528             }
84529         }
84530         function getReferencedFileFromImportLiteral(checker, importName) {
84531             var symbol = checker.getSymbolAtLocation(importName);
84532             return symbol && getReferencedFileFromImportedModuleSymbol(symbol);
84533         }
84534         function getReferencedFileFromFileName(program, fileName, sourceFileDirectory, getCanonicalFileName) {
84535             return ts.toPath(program.getProjectReferenceRedirect(fileName) || fileName, sourceFileDirectory, getCanonicalFileName);
84536         }
84537         function getReferencedFiles(program, sourceFile, getCanonicalFileName) {
84538             var referencedFiles;
84539             if (sourceFile.imports && sourceFile.imports.length > 0) {
84540                 var checker = program.getTypeChecker();
84541                 for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) {
84542                     var importName = _a[_i];
84543                     var declarationSourceFilePath = getReferencedFileFromImportLiteral(checker, importName);
84544                     if (declarationSourceFilePath) {
84545                         addReferencedFile(declarationSourceFilePath);
84546                     }
84547                 }
84548             }
84549             var sourceFileDirectory = ts.getDirectoryPath(sourceFile.resolvedPath);
84550             if (sourceFile.referencedFiles && sourceFile.referencedFiles.length > 0) {
84551                 for (var _b = 0, _c = sourceFile.referencedFiles; _b < _c.length; _b++) {
84552                     var referencedFile = _c[_b];
84553                     var referencedPath = getReferencedFileFromFileName(program, referencedFile.fileName, sourceFileDirectory, getCanonicalFileName);
84554                     addReferencedFile(referencedPath);
84555                 }
84556             }
84557             if (sourceFile.resolvedTypeReferenceDirectiveNames) {
84558                 sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (resolvedTypeReferenceDirective) {
84559                     if (!resolvedTypeReferenceDirective) {
84560                         return;
84561                     }
84562                     var fileName = resolvedTypeReferenceDirective.resolvedFileName;
84563                     var typeFilePath = getReferencedFileFromFileName(program, fileName, sourceFileDirectory, getCanonicalFileName);
84564                     addReferencedFile(typeFilePath);
84565                 });
84566             }
84567             if (sourceFile.moduleAugmentations.length) {
84568                 var checker = program.getTypeChecker();
84569                 for (var _d = 0, _e = sourceFile.moduleAugmentations; _d < _e.length; _d++) {
84570                     var moduleName = _e[_d];
84571                     if (!ts.isStringLiteral(moduleName)) {
84572                         continue;
84573                     }
84574                     var symbol = checker.getSymbolAtLocation(moduleName);
84575                     if (!symbol) {
84576                         continue;
84577                     }
84578                     addReferenceFromAmbientModule(symbol);
84579                 }
84580             }
84581             for (var _f = 0, _g = program.getTypeChecker().getAmbientModules(); _f < _g.length; _f++) {
84582                 var ambientModule = _g[_f];
84583                 if (ambientModule.declarations.length > 1) {
84584                     addReferenceFromAmbientModule(ambientModule);
84585                 }
84586             }
84587             return referencedFiles;
84588             function addReferenceFromAmbientModule(symbol) {
84589                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
84590                     var declaration = _a[_i];
84591                     var declarationSourceFile = ts.getSourceFileOfNode(declaration);
84592                     if (declarationSourceFile &&
84593                         declarationSourceFile !== sourceFile) {
84594                         addReferencedFile(declarationSourceFile.resolvedPath);
84595                     }
84596                 }
84597             }
84598             function addReferencedFile(referencedPath) {
84599                 if (!referencedFiles) {
84600                     referencedFiles = ts.createMap();
84601                 }
84602                 referencedFiles.set(referencedPath, true);
84603             }
84604         }
84605         function canReuseOldState(newReferencedMap, oldState) {
84606             return oldState && !oldState.referencedMap === !newReferencedMap;
84607         }
84608         BuilderState.canReuseOldState = canReuseOldState;
84609         function create(newProgram, getCanonicalFileName, oldState) {
84610             var fileInfos = ts.createMap();
84611             var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? ts.createMap() : undefined;
84612             var exportedModulesMap = referencedMap ? ts.createMap() : undefined;
84613             var hasCalledUpdateShapeSignature = ts.createMap();
84614             var useOldState = canReuseOldState(referencedMap, oldState);
84615             for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
84616                 var sourceFile = _a[_i];
84617                 var version_1 = ts.Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set");
84618                 var oldInfo = useOldState ? oldState.fileInfos.get(sourceFile.resolvedPath) : undefined;
84619                 if (referencedMap) {
84620                     var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName);
84621                     if (newReferences) {
84622                         referencedMap.set(sourceFile.resolvedPath, newReferences);
84623                     }
84624                     if (useOldState) {
84625                         var exportedModules = oldState.exportedModulesMap.get(sourceFile.resolvedPath);
84626                         if (exportedModules) {
84627                             exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
84628                         }
84629                     }
84630                 }
84631                 fileInfos.set(sourceFile.resolvedPath, { version: version_1, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) });
84632             }
84633             return {
84634                 fileInfos: fileInfos,
84635                 referencedMap: referencedMap,
84636                 exportedModulesMap: exportedModulesMap,
84637                 hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature
84638             };
84639         }
84640         BuilderState.create = create;
84641         function releaseCache(state) {
84642             state.allFilesExcludingDefaultLibraryFile = undefined;
84643             state.allFileNames = undefined;
84644         }
84645         BuilderState.releaseCache = releaseCache;
84646         function clone(state) {
84647             var fileInfos = ts.createMap();
84648             state.fileInfos.forEach(function (value, key) {
84649                 fileInfos.set(key, __assign({}, value));
84650             });
84651             return {
84652                 fileInfos: fileInfos,
84653                 referencedMap: cloneMapOrUndefined(state.referencedMap),
84654                 exportedModulesMap: cloneMapOrUndefined(state.exportedModulesMap),
84655                 hasCalledUpdateShapeSignature: ts.cloneMap(state.hasCalledUpdateShapeSignature),
84656             };
84657         }
84658         BuilderState.clone = clone;
84659         function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, cacheToUpdateSignature, exportedModulesMapCache) {
84660             var signatureCache = cacheToUpdateSignature || ts.createMap();
84661             var sourceFile = programOfThisState.getSourceFileByPath(path);
84662             if (!sourceFile) {
84663                 return ts.emptyArray;
84664             }
84665             if (!updateShapeSignature(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache)) {
84666                 return [sourceFile];
84667             }
84668             var result = (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache);
84669             if (!cacheToUpdateSignature) {
84670                 updateSignaturesFromCache(state, signatureCache);
84671             }
84672             return result;
84673         }
84674         BuilderState.getFilesAffectedBy = getFilesAffectedBy;
84675         function updateSignaturesFromCache(state, signatureCache) {
84676             signatureCache.forEach(function (signature, path) { return updateSignatureOfFile(state, signature, path); });
84677         }
84678         BuilderState.updateSignaturesFromCache = updateSignaturesFromCache;
84679         function updateSignatureOfFile(state, signature, path) {
84680             state.fileInfos.get(path).signature = signature;
84681             state.hasCalledUpdateShapeSignature.set(path, true);
84682         }
84683         BuilderState.updateSignatureOfFile = updateSignatureOfFile;
84684         function updateShapeSignature(state, programOfThisState, sourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) {
84685             ts.Debug.assert(!!sourceFile);
84686             ts.Debug.assert(!exportedModulesMapCache || !!state.exportedModulesMap, "Compute visible to outside map only if visibleToOutsideReferencedMap present in the state");
84687             if (state.hasCalledUpdateShapeSignature.has(sourceFile.resolvedPath) || cacheToUpdateSignature.has(sourceFile.resolvedPath)) {
84688                 return false;
84689             }
84690             var info = state.fileInfos.get(sourceFile.resolvedPath);
84691             if (!info)
84692                 return ts.Debug.fail();
84693             var prevSignature = info.signature;
84694             var latestSignature;
84695             if (sourceFile.isDeclarationFile) {
84696                 latestSignature = sourceFile.version;
84697                 if (exportedModulesMapCache && latestSignature !== prevSignature) {
84698                     var references = state.referencedMap ? state.referencedMap.get(sourceFile.resolvedPath) : undefined;
84699                     exportedModulesMapCache.set(sourceFile.resolvedPath, references || false);
84700                 }
84701             }
84702             else {
84703                 var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile, true, cancellationToken, undefined, true);
84704                 var firstDts_1 = emitOutput_1.outputFiles &&
84705                     programOfThisState.getCompilerOptions().declarationMap ?
84706                     emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined :
84707                     emitOutput_1.outputFiles.length > 0 ? emitOutput_1.outputFiles[0] : undefined;
84708                 if (firstDts_1) {
84709                     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; })); });
84710                     latestSignature = computeHash(firstDts_1.text);
84711                     if (exportedModulesMapCache && latestSignature !== prevSignature) {
84712                         updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
84713                     }
84714                 }
84715                 else {
84716                     latestSignature = prevSignature;
84717                 }
84718             }
84719             cacheToUpdateSignature.set(sourceFile.resolvedPath, latestSignature);
84720             return !prevSignature || latestSignature !== prevSignature;
84721         }
84722         BuilderState.updateShapeSignature = updateShapeSignature;
84723         function updateExportedModules(sourceFile, exportedModulesFromDeclarationEmit, exportedModulesMapCache) {
84724             if (!exportedModulesFromDeclarationEmit) {
84725                 exportedModulesMapCache.set(sourceFile.resolvedPath, false);
84726                 return;
84727             }
84728             var exportedModules;
84729             exportedModulesFromDeclarationEmit.forEach(function (symbol) { return addExportedModule(getReferencedFileFromImportedModuleSymbol(symbol)); });
84730             exportedModulesMapCache.set(sourceFile.resolvedPath, exportedModules || false);
84731             function addExportedModule(exportedModulePath) {
84732                 if (exportedModulePath) {
84733                     if (!exportedModules) {
84734                         exportedModules = ts.createMap();
84735                     }
84736                     exportedModules.set(exportedModulePath, true);
84737                 }
84738             }
84739         }
84740         function updateExportedFilesMapFromCache(state, exportedModulesMapCache) {
84741             if (exportedModulesMapCache) {
84742                 ts.Debug.assert(!!state.exportedModulesMap);
84743                 exportedModulesMapCache.forEach(function (exportedModules, path) {
84744                     if (exportedModules) {
84745                         state.exportedModulesMap.set(path, exportedModules);
84746                     }
84747                     else {
84748                         state.exportedModulesMap.delete(path);
84749                     }
84750                 });
84751             }
84752         }
84753         BuilderState.updateExportedFilesMapFromCache = updateExportedFilesMapFromCache;
84754         function getAllDependencies(state, programOfThisState, sourceFile) {
84755             var compilerOptions = programOfThisState.getCompilerOptions();
84756             if (compilerOptions.outFile || compilerOptions.out) {
84757                 return getAllFileNames(state, programOfThisState);
84758             }
84759             if (!state.referencedMap || isFileAffectingGlobalScope(sourceFile)) {
84760                 return getAllFileNames(state, programOfThisState);
84761             }
84762             var seenMap = ts.createMap();
84763             var queue = [sourceFile.resolvedPath];
84764             while (queue.length) {
84765                 var path = queue.pop();
84766                 if (!seenMap.has(path)) {
84767                     seenMap.set(path, true);
84768                     var references = state.referencedMap.get(path);
84769                     if (references) {
84770                         var iterator = references.keys();
84771                         for (var iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) {
84772                             queue.push(iterResult.value);
84773                         }
84774                     }
84775                 }
84776             }
84777             return ts.arrayFrom(ts.mapDefinedIterator(seenMap.keys(), function (path) {
84778                 var file = programOfThisState.getSourceFileByPath(path);
84779                 return file ? file.fileName : path;
84780             }));
84781         }
84782         BuilderState.getAllDependencies = getAllDependencies;
84783         function getAllFileNames(state, programOfThisState) {
84784             if (!state.allFileNames) {
84785                 var sourceFiles = programOfThisState.getSourceFiles();
84786                 state.allFileNames = sourceFiles === ts.emptyArray ? ts.emptyArray : sourceFiles.map(function (file) { return file.fileName; });
84787             }
84788             return state.allFileNames;
84789         }
84790         function getReferencedByPaths(state, referencedFilePath) {
84791             return ts.arrayFrom(ts.mapDefinedIterator(state.referencedMap.entries(), function (_a) {
84792                 var filePath = _a[0], referencesInFile = _a[1];
84793                 return referencesInFile.has(referencedFilePath) ? filePath : undefined;
84794             }));
84795         }
84796         BuilderState.getReferencedByPaths = getReferencedByPaths;
84797         function containsOnlyAmbientModules(sourceFile) {
84798             for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
84799                 var statement = _a[_i];
84800                 if (!ts.isModuleWithStringLiteralName(statement)) {
84801                     return false;
84802                 }
84803             }
84804             return true;
84805         }
84806         function containsGlobalScopeAugmentation(sourceFile) {
84807             return ts.some(sourceFile.moduleAugmentations, function (augmentation) { return ts.isGlobalScopeAugmentation(augmentation.parent); });
84808         }
84809         function isFileAffectingGlobalScope(sourceFile) {
84810             return containsGlobalScopeAugmentation(sourceFile) ||
84811                 !ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile);
84812         }
84813         function getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, firstSourceFile) {
84814             if (state.allFilesExcludingDefaultLibraryFile) {
84815                 return state.allFilesExcludingDefaultLibraryFile;
84816             }
84817             var result;
84818             if (firstSourceFile)
84819                 addSourceFile(firstSourceFile);
84820             for (var _i = 0, _a = programOfThisState.getSourceFiles(); _i < _a.length; _i++) {
84821                 var sourceFile = _a[_i];
84822                 if (sourceFile !== firstSourceFile) {
84823                     addSourceFile(sourceFile);
84824                 }
84825             }
84826             state.allFilesExcludingDefaultLibraryFile = result || ts.emptyArray;
84827             return state.allFilesExcludingDefaultLibraryFile;
84828             function addSourceFile(sourceFile) {
84829                 if (!programOfThisState.isSourceFileDefaultLibrary(sourceFile)) {
84830                     (result || (result = [])).push(sourceFile);
84831                 }
84832             }
84833         }
84834         BuilderState.getAllFilesExcludingDefaultLibraryFile = getAllFilesExcludingDefaultLibraryFile;
84835         function getFilesAffectedByUpdatedShapeWhenNonModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape) {
84836             var compilerOptions = programOfThisState.getCompilerOptions();
84837             if (compilerOptions && (compilerOptions.out || compilerOptions.outFile)) {
84838                 return [sourceFileWithUpdatedShape];
84839             }
84840             return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
84841         }
84842         function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) {
84843             if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
84844                 return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
84845             }
84846             var compilerOptions = programOfThisState.getCompilerOptions();
84847             if (compilerOptions && (compilerOptions.isolatedModules || compilerOptions.out || compilerOptions.outFile)) {
84848                 return [sourceFileWithUpdatedShape];
84849             }
84850             var seenFileNamesMap = ts.createMap();
84851             seenFileNamesMap.set(sourceFileWithUpdatedShape.resolvedPath, sourceFileWithUpdatedShape);
84852             var queue = getReferencedByPaths(state, sourceFileWithUpdatedShape.resolvedPath);
84853             while (queue.length > 0) {
84854                 var currentPath = queue.pop();
84855                 if (!seenFileNamesMap.has(currentPath)) {
84856                     var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
84857                     seenFileNamesMap.set(currentPath, currentSourceFile);
84858                     if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache)) {
84859                         queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
84860                     }
84861                 }
84862             }
84863             return ts.arrayFrom(ts.mapDefinedIterator(seenFileNamesMap.values(), function (value) { return value; }));
84864         }
84865     })(BuilderState = ts.BuilderState || (ts.BuilderState = {}));
84866     function cloneMapOrUndefined(map) {
84867         return map ? ts.cloneMap(map) : undefined;
84868     }
84869     ts.cloneMapOrUndefined = cloneMapOrUndefined;
84870 })(ts || (ts = {}));
84871 var ts;
84872 (function (ts) {
84873     function hasSameKeys(map1, map2) {
84874         return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); });
84875     }
84876     function createBuilderProgramState(newProgram, getCanonicalFileName, oldState) {
84877         var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState);
84878         state.program = newProgram;
84879         var compilerOptions = newProgram.getCompilerOptions();
84880         state.compilerOptions = compilerOptions;
84881         if (!compilerOptions.outFile && !compilerOptions.out) {
84882             state.semanticDiagnosticsPerFile = ts.createMap();
84883         }
84884         state.changedFilesSet = ts.createMap();
84885         var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState);
84886         var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
84887         var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
84888             !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
84889         if (useOldState) {
84890             if (!oldState.currentChangedFilePath) {
84891                 var affectedSignatures = oldState.currentAffectedFilesSignatures;
84892                 ts.Debug.assert(!oldState.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated");
84893             }
84894             var changedFilesSet = oldState.changedFilesSet;
84895             if (canCopySemanticDiagnostics) {
84896                 ts.Debug.assert(!changedFilesSet || !ts.forEachKey(changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files");
84897             }
84898             if (changedFilesSet) {
84899                 ts.copyEntries(changedFilesSet, state.changedFilesSet);
84900             }
84901             if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) {
84902                 state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice();
84903                 state.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(oldState.affectedFilesPendingEmitKind);
84904                 state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex;
84905                 state.seenAffectedFiles = ts.createMap();
84906             }
84907         }
84908         var referencedMap = state.referencedMap;
84909         var oldReferencedMap = useOldState ? oldState.referencedMap : undefined;
84910         var copyDeclarationFileDiagnostics = canCopySemanticDiagnostics && !compilerOptions.skipLibCheck === !oldCompilerOptions.skipLibCheck;
84911         var copyLibFileDiagnostics = copyDeclarationFileDiagnostics && !compilerOptions.skipDefaultLibCheck === !oldCompilerOptions.skipDefaultLibCheck;
84912         state.fileInfos.forEach(function (info, sourceFilePath) {
84913             var oldInfo;
84914             var newReferences;
84915             if (!useOldState ||
84916                 !(oldInfo = oldState.fileInfos.get(sourceFilePath)) ||
84917                 oldInfo.version !== info.version ||
84918                 !hasSameKeys(newReferences = referencedMap && referencedMap.get(sourceFilePath), oldReferencedMap && oldReferencedMap.get(sourceFilePath)) ||
84919                 newReferences && ts.forEachKey(newReferences, function (path) { return !state.fileInfos.has(path) && oldState.fileInfos.has(path); })) {
84920                 state.changedFilesSet.set(sourceFilePath, true);
84921             }
84922             else if (canCopySemanticDiagnostics) {
84923                 var sourceFile = newProgram.getSourceFileByPath(sourceFilePath);
84924                 if (sourceFile.isDeclarationFile && !copyDeclarationFileDiagnostics) {
84925                     return;
84926                 }
84927                 if (sourceFile.hasNoDefaultLib && !copyLibFileDiagnostics) {
84928                     return;
84929                 }
84930                 var diagnostics = oldState.semanticDiagnosticsPerFile.get(sourceFilePath);
84931                 if (diagnostics) {
84932                     state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) : diagnostics);
84933                     if (!state.semanticDiagnosticsFromOldState) {
84934                         state.semanticDiagnosticsFromOldState = ts.createMap();
84935                     }
84936                     state.semanticDiagnosticsFromOldState.set(sourceFilePath, true);
84937                 }
84938             }
84939         });
84940         if (useOldState && ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) { return info.affectsGlobalScope && !state.fileInfos.has(sourceFilePath); })) {
84941             ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, newProgram, undefined)
84942                 .forEach(function (file) { return state.changedFilesSet.set(file.resolvedPath, true); });
84943         }
84944         else if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
84945             newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1); });
84946             ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
84947             state.seenAffectedFiles = state.seenAffectedFiles || ts.createMap();
84948         }
84949         state.emittedBuildInfo = !state.changedFilesSet.size && !state.affectedFilesPendingEmit;
84950         return state;
84951     }
84952     function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
84953         if (!diagnostics.length)
84954             return ts.emptyArray;
84955         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory()));
84956         return diagnostics.map(function (diagnostic) {
84957             var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath);
84958             result.reportsUnnecessary = diagnostic.reportsUnnecessary;
84959             result.source = diagnostic.source;
84960             var relatedInformation = diagnostic.relatedInformation;
84961             result.relatedInformation = relatedInformation ?
84962                 relatedInformation.length ?
84963                     relatedInformation.map(function (r) { return convertToDiagnosticRelatedInformation(r, newProgram, toPath); }) :
84964                     ts.emptyArray :
84965                 undefined;
84966             return result;
84967         });
84968         function toPath(path) {
84969             return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
84970         }
84971     }
84972     function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) {
84973         var file = diagnostic.file;
84974         return __assign(__assign({}, diagnostic), { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined });
84975     }
84976     function releaseCache(state) {
84977         ts.BuilderState.releaseCache(state);
84978         state.program = undefined;
84979     }
84980     function cloneBuilderProgramState(state) {
84981         var newState = ts.BuilderState.clone(state);
84982         newState.semanticDiagnosticsPerFile = ts.cloneMapOrUndefined(state.semanticDiagnosticsPerFile);
84983         newState.changedFilesSet = ts.cloneMap(state.changedFilesSet);
84984         newState.affectedFiles = state.affectedFiles;
84985         newState.affectedFilesIndex = state.affectedFilesIndex;
84986         newState.currentChangedFilePath = state.currentChangedFilePath;
84987         newState.currentAffectedFilesSignatures = ts.cloneMapOrUndefined(state.currentAffectedFilesSignatures);
84988         newState.currentAffectedFilesExportedModulesMap = ts.cloneMapOrUndefined(state.currentAffectedFilesExportedModulesMap);
84989         newState.seenAffectedFiles = ts.cloneMapOrUndefined(state.seenAffectedFiles);
84990         newState.cleanedDiagnosticsOfLibFiles = state.cleanedDiagnosticsOfLibFiles;
84991         newState.semanticDiagnosticsFromOldState = ts.cloneMapOrUndefined(state.semanticDiagnosticsFromOldState);
84992         newState.program = state.program;
84993         newState.compilerOptions = state.compilerOptions;
84994         newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
84995         newState.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(state.affectedFilesPendingEmitKind);
84996         newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
84997         newState.seenEmittedFiles = ts.cloneMapOrUndefined(state.seenEmittedFiles);
84998         newState.programEmitComplete = state.programEmitComplete;
84999         return newState;
85000     }
85001     function assertSourceFileOkWithoutNextAffectedCall(state, sourceFile) {
85002         ts.Debug.assert(!sourceFile || !state.affectedFiles || state.affectedFiles[state.affectedFilesIndex - 1] !== sourceFile || !state.semanticDiagnosticsPerFile.has(sourceFile.resolvedPath));
85003     }
85004     function getNextAffectedFile(state, cancellationToken, computeHash) {
85005         while (true) {
85006             var affectedFiles = state.affectedFiles;
85007             if (affectedFiles) {
85008                 var seenAffectedFiles = state.seenAffectedFiles;
85009                 var affectedFilesIndex = state.affectedFilesIndex;
85010                 while (affectedFilesIndex < affectedFiles.length) {
85011                     var affectedFile = affectedFiles[affectedFilesIndex];
85012                     if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
85013                         state.affectedFilesIndex = affectedFilesIndex;
85014                         handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash);
85015                         return affectedFile;
85016                     }
85017                     affectedFilesIndex++;
85018                 }
85019                 state.changedFilesSet.delete(state.currentChangedFilePath);
85020                 state.currentChangedFilePath = undefined;
85021                 ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures);
85022                 state.currentAffectedFilesSignatures.clear();
85023                 ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
85024                 state.affectedFiles = undefined;
85025             }
85026             var nextKey = state.changedFilesSet.keys().next();
85027             if (nextKey.done) {
85028                 return undefined;
85029             }
85030             var program = ts.Debug.checkDefined(state.program);
85031             var compilerOptions = program.getCompilerOptions();
85032             if (compilerOptions.outFile || compilerOptions.out) {
85033                 ts.Debug.assert(!state.semanticDiagnosticsPerFile);
85034                 return program;
85035             }
85036             state.currentAffectedFilesSignatures = state.currentAffectedFilesSignatures || ts.createMap();
85037             if (state.exportedModulesMap) {
85038                 state.currentAffectedFilesExportedModulesMap = state.currentAffectedFilesExportedModulesMap || ts.createMap();
85039             }
85040             state.affectedFiles = ts.BuilderState.getFilesAffectedBy(state, program, nextKey.value, cancellationToken, computeHash, state.currentAffectedFilesSignatures, state.currentAffectedFilesExportedModulesMap);
85041             state.currentChangedFilePath = nextKey.value;
85042             state.affectedFilesIndex = 0;
85043             state.seenAffectedFiles = state.seenAffectedFiles || ts.createMap();
85044         }
85045     }
85046     function getNextAffectedFilePendingEmit(state) {
85047         var affectedFilesPendingEmit = state.affectedFilesPendingEmit;
85048         if (affectedFilesPendingEmit) {
85049             var seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap());
85050             for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) {
85051                 var affectedFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]);
85052                 if (affectedFile) {
85053                     var seenKind = seenEmittedFiles.get(affectedFile.resolvedPath);
85054                     var emitKind = ts.Debug.checkDefined(ts.Debug.checkDefined(state.affectedFilesPendingEmitKind).get(affectedFile.resolvedPath));
85055                     if (seenKind === undefined || seenKind < emitKind) {
85056                         state.affectedFilesPendingEmitIndex = i;
85057                         return { affectedFile: affectedFile, emitKind: emitKind };
85058                     }
85059                 }
85060             }
85061             state.affectedFilesPendingEmit = undefined;
85062             state.affectedFilesPendingEmitKind = undefined;
85063             state.affectedFilesPendingEmitIndex = undefined;
85064         }
85065         return undefined;
85066     }
85067     function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) {
85068         removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
85069         if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
85070             if (!state.cleanedDiagnosticsOfLibFiles) {
85071                 state.cleanedDiagnosticsOfLibFiles = true;
85072                 var program_1 = ts.Debug.checkDefined(state.program);
85073                 var options_2 = program_1.getCompilerOptions();
85074                 ts.forEach(program_1.getSourceFiles(), function (f) {
85075                     return program_1.isSourceFileDefaultLibrary(f) &&
85076                         !ts.skipTypeChecking(f, options_2, program_1) &&
85077                         removeSemanticDiagnosticsOf(state, f.resolvedPath);
85078                 });
85079             }
85080             return;
85081         }
85082         if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
85083             forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); });
85084         }
85085     }
85086     function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) {
85087         removeSemanticDiagnosticsOf(state, path);
85088         if (!state.changedFilesSet.has(path)) {
85089             var program = ts.Debug.checkDefined(state.program);
85090             var sourceFile = program.getSourceFileByPath(path);
85091             if (sourceFile) {
85092                 ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
85093                 if (ts.getEmitDeclarations(state.compilerOptions)) {
85094                     addToAffectedFilesPendingEmit(state, path, 0);
85095                 }
85096             }
85097         }
85098         return false;
85099     }
85100     function removeSemanticDiagnosticsOf(state, path) {
85101         if (!state.semanticDiagnosticsFromOldState) {
85102             return true;
85103         }
85104         state.semanticDiagnosticsFromOldState.delete(path);
85105         state.semanticDiagnosticsPerFile.delete(path);
85106         return !state.semanticDiagnosticsFromOldState.size;
85107     }
85108     function isChangedSignagure(state, path) {
85109         var newSignature = ts.Debug.checkDefined(state.currentAffectedFilesSignatures).get(path);
85110         var oldSignagure = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
85111         return newSignature !== oldSignagure;
85112     }
85113     function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) {
85114         if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) {
85115             return;
85116         }
85117         if (!isChangedSignagure(state, affectedFile.resolvedPath))
85118             return;
85119         if (state.compilerOptions.isolatedModules) {
85120             var seenFileNamesMap = ts.createMap();
85121             seenFileNamesMap.set(affectedFile.resolvedPath, true);
85122             var queue = ts.BuilderState.getReferencedByPaths(state, affectedFile.resolvedPath);
85123             while (queue.length > 0) {
85124                 var currentPath = queue.pop();
85125                 if (!seenFileNamesMap.has(currentPath)) {
85126                     seenFileNamesMap.set(currentPath, true);
85127                     var result = fn(state, currentPath);
85128                     if (result && isChangedSignagure(state, currentPath)) {
85129                         var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
85130                         queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
85131                     }
85132                 }
85133             }
85134         }
85135         ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
85136         var seenFileAndExportsOfFile = ts.createMap();
85137         if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) {
85138             return exportedModules &&
85139                 exportedModules.has(affectedFile.resolvedPath) &&
85140                 forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
85141         })) {
85142             return;
85143         }
85144         ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) {
85145             return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) &&
85146                 exportedModules.has(affectedFile.resolvedPath) &&
85147                 forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
85148         });
85149     }
85150     function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) {
85151         return ts.forEachEntry(state.referencedMap, function (referencesInFile, filePath) {
85152             return referencesInFile.has(referencedPath) && forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn);
85153         });
85154     }
85155     function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) {
85156         if (!ts.addToSeen(seenFileAndExportsOfFile, filePath)) {
85157             return false;
85158         }
85159         if (fn(state, filePath)) {
85160             return true;
85161         }
85162         ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
85163         if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) {
85164             return exportedModules &&
85165                 exportedModules.has(filePath) &&
85166                 forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
85167         })) {
85168             return true;
85169         }
85170         if (ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) {
85171             return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) &&
85172                 exportedModules.has(filePath) &&
85173                 forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
85174         })) {
85175             return true;
85176         }
85177         return !!ts.forEachEntry(state.referencedMap, function (referencesInFile, referencingFilePath) {
85178             return referencesInFile.has(filePath) &&
85179                 !seenFileAndExportsOfFile.has(referencingFilePath) &&
85180                 fn(state, referencingFilePath);
85181         });
85182     }
85183     function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) {
85184         if (isBuildInfoEmit) {
85185             state.emittedBuildInfo = true;
85186         }
85187         else if (affected === state.program) {
85188             state.changedFilesSet.clear();
85189             state.programEmitComplete = true;
85190         }
85191         else {
85192             state.seenAffectedFiles.set(affected.resolvedPath, true);
85193             if (emitKind !== undefined) {
85194                 (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.resolvedPath, emitKind);
85195             }
85196             if (isPendingEmit) {
85197                 state.affectedFilesPendingEmitIndex++;
85198             }
85199             else {
85200                 state.affectedFilesIndex++;
85201             }
85202         }
85203     }
85204     function toAffectedFileResult(state, result, affected) {
85205         doneWithAffectedFile(state, affected);
85206         return { result: result, affected: affected };
85207     }
85208     function toAffectedFileEmitResult(state, result, affected, emitKind, isPendingEmit, isBuildInfoEmit) {
85209         doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit);
85210         return { result: result, affected: affected };
85211     }
85212     function getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken) {
85213         return ts.concatenate(getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken), ts.Debug.checkDefined(state.program).getProgramDiagnostics(sourceFile));
85214     }
85215     function getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken) {
85216         var path = sourceFile.resolvedPath;
85217         if (state.semanticDiagnosticsPerFile) {
85218             var cachedDiagnostics = state.semanticDiagnosticsPerFile.get(path);
85219             if (cachedDiagnostics) {
85220                 return cachedDiagnostics;
85221             }
85222         }
85223         var diagnostics = ts.Debug.checkDefined(state.program).getBindAndCheckDiagnostics(sourceFile, cancellationToken);
85224         if (state.semanticDiagnosticsPerFile) {
85225             state.semanticDiagnosticsPerFile.set(path, diagnostics);
85226         }
85227         return diagnostics;
85228     }
85229     function getProgramBuildInfo(state, getCanonicalFileName) {
85230         if (state.compilerOptions.outFile || state.compilerOptions.out)
85231             return undefined;
85232         var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
85233         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
85234         var fileInfos = {};
85235         state.fileInfos.forEach(function (value, key) {
85236             var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
85237             fileInfos[relativeToBuildInfo(key)] = signature === undefined ? value : { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope };
85238         });
85239         var result = {
85240             fileInfos: fileInfos,
85241             options: convertToReusableCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath)
85242         };
85243         if (state.referencedMap) {
85244             var referencedMap = {};
85245             for (var _i = 0, _a = ts.arrayFrom(state.referencedMap.keys()).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
85246                 var key = _a[_i];
85247                 referencedMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.referencedMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive);
85248             }
85249             result.referencedMap = referencedMap;
85250         }
85251         if (state.exportedModulesMap) {
85252             var exportedModulesMap = {};
85253             for (var _b = 0, _c = ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) {
85254                 var key = _c[_b];
85255                 var newValue = state.currentAffectedFilesExportedModulesMap && state.currentAffectedFilesExportedModulesMap.get(key);
85256                 if (newValue === undefined)
85257                     exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.exportedModulesMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive);
85258                 else if (newValue)
85259                     exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(newValue.keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive);
85260             }
85261             result.exportedModulesMap = exportedModulesMap;
85262         }
85263         if (state.semanticDiagnosticsPerFile) {
85264             var semanticDiagnosticsPerFile = [];
85265             for (var _d = 0, _e = ts.arrayFrom(state.semanticDiagnosticsPerFile.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) {
85266                 var key = _e[_d];
85267                 var value = state.semanticDiagnosticsPerFile.get(key);
85268                 semanticDiagnosticsPerFile.push(value.length ?
85269                     [
85270                         relativeToBuildInfo(key),
85271                         state.hasReusableDiagnostic ?
85272                             value :
85273                             convertToReusableDiagnostics(value, relativeToBuildInfo)
85274                     ] :
85275                     relativeToBuildInfo(key));
85276             }
85277             result.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile;
85278         }
85279         return result;
85280         function relativeToBuildInfoEnsuringAbsolutePath(path) {
85281             return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory));
85282         }
85283         function relativeToBuildInfo(path) {
85284             return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, getCanonicalFileName));
85285         }
85286     }
85287     function convertToReusableCompilerOptions(options, relativeToBuildInfo) {
85288         var result = {};
85289         var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
85290         for (var name in options) {
85291             if (ts.hasProperty(options, name)) {
85292                 result[name] = convertToReusableCompilerOptionValue(optionsNameMap.get(name.toLowerCase()), options[name], relativeToBuildInfo);
85293             }
85294         }
85295         if (result.configFilePath) {
85296             result.configFilePath = relativeToBuildInfo(result.configFilePath);
85297         }
85298         return result;
85299     }
85300     function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) {
85301         if (option) {
85302             if (option.type === "list") {
85303                 var values = value;
85304                 if (option.element.isFilePath && values.length) {
85305                     return values.map(relativeToBuildInfo);
85306                 }
85307             }
85308             else if (option.isFilePath) {
85309                 return relativeToBuildInfo(value);
85310             }
85311         }
85312         return value;
85313     }
85314     function convertToReusableDiagnostics(diagnostics, relativeToBuildInfo) {
85315         ts.Debug.assert(!!diagnostics.length);
85316         return diagnostics.map(function (diagnostic) {
85317             var result = convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo);
85318             result.reportsUnnecessary = diagnostic.reportsUnnecessary;
85319             result.source = diagnostic.source;
85320             var relatedInformation = diagnostic.relatedInformation;
85321             result.relatedInformation = relatedInformation ?
85322                 relatedInformation.length ?
85323                     relatedInformation.map(function (r) { return convertToReusableDiagnosticRelatedInformation(r, relativeToBuildInfo); }) :
85324                     ts.emptyArray :
85325                 undefined;
85326             return result;
85327         });
85328     }
85329     function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) {
85330         var file = diagnostic.file;
85331         return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.resolvedPath) : undefined });
85332     }
85333     var BuilderProgramKind;
85334     (function (BuilderProgramKind) {
85335         BuilderProgramKind[BuilderProgramKind["SemanticDiagnosticsBuilderProgram"] = 0] = "SemanticDiagnosticsBuilderProgram";
85336         BuilderProgramKind[BuilderProgramKind["EmitAndSemanticDiagnosticsBuilderProgram"] = 1] = "EmitAndSemanticDiagnosticsBuilderProgram";
85337     })(BuilderProgramKind = ts.BuilderProgramKind || (ts.BuilderProgramKind = {}));
85338     function getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
85339         var host;
85340         var newProgram;
85341         var oldProgram;
85342         if (newProgramOrRootNames === undefined) {
85343             ts.Debug.assert(hostOrOptions === undefined);
85344             host = oldProgramOrHost;
85345             oldProgram = configFileParsingDiagnosticsOrOldProgram;
85346             ts.Debug.assert(!!oldProgram);
85347             newProgram = oldProgram.getProgram();
85348         }
85349         else if (ts.isArray(newProgramOrRootNames)) {
85350             oldProgram = configFileParsingDiagnosticsOrOldProgram;
85351             newProgram = ts.createProgram({
85352                 rootNames: newProgramOrRootNames,
85353                 options: hostOrOptions,
85354                 host: oldProgramOrHost,
85355                 oldProgram: oldProgram && oldProgram.getProgramOrUndefined(),
85356                 configFileParsingDiagnostics: configFileParsingDiagnostics,
85357                 projectReferences: projectReferences
85358             });
85359             host = oldProgramOrHost;
85360         }
85361         else {
85362             newProgram = newProgramOrRootNames;
85363             host = hostOrOptions;
85364             oldProgram = oldProgramOrHost;
85365             configFileParsingDiagnostics = configFileParsingDiagnosticsOrOldProgram;
85366         }
85367         return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray };
85368     }
85369     ts.getBuilderCreationParameters = getBuilderCreationParameters;
85370     function createBuilderProgram(kind, _a) {
85371         var newProgram = _a.newProgram, host = _a.host, oldProgram = _a.oldProgram, configFileParsingDiagnostics = _a.configFileParsingDiagnostics;
85372         var oldState = oldProgram && oldProgram.getState();
85373         if (oldState && newProgram === oldState.program && configFileParsingDiagnostics === newProgram.getConfigFileParsingDiagnostics()) {
85374             newProgram = undefined;
85375             oldState = undefined;
85376             return oldProgram;
85377         }
85378         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
85379         var computeHash = host.createHash || ts.generateDjb2Hash;
85380         var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState);
85381         var backupState;
85382         newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
85383         newProgram = undefined;
85384         oldProgram = undefined;
85385         oldState = undefined;
85386         var builderProgram = createRedirectedBuilderProgram(state, configFileParsingDiagnostics);
85387         builderProgram.getState = function () { return state; };
85388         builderProgram.backupState = function () {
85389             ts.Debug.assert(backupState === undefined);
85390             backupState = cloneBuilderProgramState(state);
85391         };
85392         builderProgram.restoreState = function () {
85393             state = ts.Debug.checkDefined(backupState);
85394             backupState = undefined;
85395         };
85396         builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); };
85397         builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
85398         builderProgram.emit = emit;
85399         builderProgram.releaseProgram = function () {
85400             releaseCache(state);
85401             backupState = undefined;
85402         };
85403         if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
85404             builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
85405         }
85406         else if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
85407             builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
85408             builderProgram.emitNextAffectedFile = emitNextAffectedFile;
85409         }
85410         else {
85411             ts.notImplemented();
85412         }
85413         return builderProgram;
85414         function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
85415             var affected = getNextAffectedFile(state, cancellationToken, computeHash);
85416             var emitKind = 1;
85417             var isPendingEmitFile = false;
85418             if (!affected) {
85419                 if (!state.compilerOptions.out && !state.compilerOptions.outFile) {
85420                     var pendingAffectedFile = getNextAffectedFilePendingEmit(state);
85421                     if (!pendingAffectedFile) {
85422                         if (state.emittedBuildInfo) {
85423                             return undefined;
85424                         }
85425                         var affected_1 = ts.Debug.checkDefined(state.program);
85426                         return toAffectedFileEmitResult(state, affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1, false, true);
85427                     }
85428                     (affected = pendingAffectedFile.affectedFile, emitKind = pendingAffectedFile.emitKind);
85429                     isPendingEmitFile = true;
85430                 }
85431                 else {
85432                     var program = ts.Debug.checkDefined(state.program);
85433                     if (state.programEmitComplete)
85434                         return undefined;
85435                     affected = program;
85436                 }
85437             }
85438             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);
85439         }
85440         function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
85441             if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
85442                 assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile);
85443                 var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, cancellationToken);
85444                 if (result)
85445                     return result;
85446                 if (!targetSourceFile) {
85447                     var sourceMaps = [];
85448                     var emitSkipped = false;
85449                     var diagnostics = void 0;
85450                     var emittedFiles = [];
85451                     var affectedEmitResult = void 0;
85452                     while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
85453                         emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
85454                         diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
85455                         emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
85456                         sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
85457                     }
85458                     return {
85459                         emitSkipped: emitSkipped,
85460                         diagnostics: diagnostics || ts.emptyArray,
85461                         emittedFiles: emittedFiles,
85462                         sourceMaps: sourceMaps
85463                     };
85464                 }
85465             }
85466             return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
85467         }
85468         function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
85469             while (true) {
85470                 var affected = getNextAffectedFile(state, cancellationToken, computeHash);
85471                 if (!affected) {
85472                     return undefined;
85473                 }
85474                 else if (affected === state.program) {
85475                     return toAffectedFileResult(state, state.program.getSemanticDiagnostics(undefined, cancellationToken), affected);
85476                 }
85477                 if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
85478                     addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1);
85479                 }
85480                 if (ignoreSourceFile && ignoreSourceFile(affected)) {
85481                     doneWithAffectedFile(state, affected);
85482                     continue;
85483                 }
85484                 return toAffectedFileResult(state, getSemanticDiagnosticsOfFile(state, affected, cancellationToken), affected);
85485             }
85486         }
85487         function getSemanticDiagnostics(sourceFile, cancellationToken) {
85488             assertSourceFileOkWithoutNextAffectedCall(state, sourceFile);
85489             var compilerOptions = ts.Debug.checkDefined(state.program).getCompilerOptions();
85490             if (compilerOptions.outFile || compilerOptions.out) {
85491                 ts.Debug.assert(!state.semanticDiagnosticsPerFile);
85492                 return ts.Debug.checkDefined(state.program).getSemanticDiagnostics(sourceFile, cancellationToken);
85493             }
85494             if (sourceFile) {
85495                 return getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken);
85496             }
85497             while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) {
85498             }
85499             var diagnostics;
85500             for (var _i = 0, _a = ts.Debug.checkDefined(state.program).getSourceFiles(); _i < _a.length; _i++) {
85501                 var sourceFile_1 = _a[_i];
85502                 diagnostics = ts.addRange(diagnostics, getSemanticDiagnosticsOfFile(state, sourceFile_1, cancellationToken));
85503             }
85504             return diagnostics || ts.emptyArray;
85505         }
85506     }
85507     ts.createBuilderProgram = createBuilderProgram;
85508     function addToAffectedFilesPendingEmit(state, affectedFilePendingEmit, kind) {
85509         if (!state.affectedFilesPendingEmit)
85510             state.affectedFilesPendingEmit = [];
85511         if (!state.affectedFilesPendingEmitKind)
85512             state.affectedFilesPendingEmitKind = ts.createMap();
85513         var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit);
85514         state.affectedFilesPendingEmit.push(affectedFilePendingEmit);
85515         state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind);
85516         if (state.affectedFilesPendingEmitIndex === undefined) {
85517             state.affectedFilesPendingEmitIndex = 0;
85518         }
85519     }
85520     function getMapOfReferencedSet(mapLike, toPath) {
85521         if (!mapLike)
85522             return undefined;
85523         var map = ts.createMap();
85524         for (var key in mapLike) {
85525             if (ts.hasProperty(mapLike, key)) {
85526                 map.set(toPath(key), ts.arrayToSet(mapLike[key], toPath));
85527             }
85528         }
85529         return map;
85530     }
85531     function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
85532         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
85533         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
85534         var fileInfos = ts.createMap();
85535         for (var key in program.fileInfos) {
85536             if (ts.hasProperty(program.fileInfos, key)) {
85537                 fileInfos.set(toPath(key), program.fileInfos[key]);
85538             }
85539         }
85540         var state = {
85541             fileInfos: fileInfos,
85542             compilerOptions: ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath),
85543             referencedMap: getMapOfReferencedSet(program.referencedMap, toPath),
85544             exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath),
85545             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]; }),
85546             hasReusableDiagnostic: true
85547         };
85548         return {
85549             getState: function () { return state; },
85550             backupState: ts.noop,
85551             restoreState: ts.noop,
85552             getProgram: ts.notImplemented,
85553             getProgramOrUndefined: ts.returnUndefined,
85554             releaseProgram: ts.noop,
85555             getCompilerOptions: function () { return state.compilerOptions; },
85556             getSourceFile: ts.notImplemented,
85557             getSourceFiles: ts.notImplemented,
85558             getOptionsDiagnostics: ts.notImplemented,
85559             getGlobalDiagnostics: ts.notImplemented,
85560             getConfigFileParsingDiagnostics: ts.notImplemented,
85561             getSyntacticDiagnostics: ts.notImplemented,
85562             getDeclarationDiagnostics: ts.notImplemented,
85563             getSemanticDiagnostics: ts.notImplemented,
85564             emit: ts.notImplemented,
85565             getAllDependencies: ts.notImplemented,
85566             getCurrentDirectory: ts.notImplemented,
85567             emitNextAffectedFile: ts.notImplemented,
85568             getSemanticDiagnosticsOfNextAffectedFile: ts.notImplemented,
85569             close: ts.noop,
85570         };
85571         function toPath(path) {
85572             return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
85573         }
85574         function toAbsolutePath(path) {
85575             return ts.getNormalizedAbsolutePath(path, buildInfoDirectory);
85576         }
85577     }
85578     ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo;
85579     function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) {
85580         return {
85581             getState: ts.notImplemented,
85582             backupState: ts.noop,
85583             restoreState: ts.noop,
85584             getProgram: getProgram,
85585             getProgramOrUndefined: function () { return state.program; },
85586             releaseProgram: function () { return state.program = undefined; },
85587             getCompilerOptions: function () { return state.compilerOptions; },
85588             getSourceFile: function (fileName) { return getProgram().getSourceFile(fileName); },
85589             getSourceFiles: function () { return getProgram().getSourceFiles(); },
85590             getOptionsDiagnostics: function (cancellationToken) { return getProgram().getOptionsDiagnostics(cancellationToken); },
85591             getGlobalDiagnostics: function (cancellationToken) { return getProgram().getGlobalDiagnostics(cancellationToken); },
85592             getConfigFileParsingDiagnostics: function () { return configFileParsingDiagnostics; },
85593             getSyntacticDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getSyntacticDiagnostics(sourceFile, cancellationToken); },
85594             getDeclarationDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getDeclarationDiagnostics(sourceFile, cancellationToken); },
85595             getSemanticDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getSemanticDiagnostics(sourceFile, cancellationToken); },
85596             emit: function (sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers) { return getProgram().emit(sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers); },
85597             getAllDependencies: ts.notImplemented,
85598             getCurrentDirectory: function () { return getProgram().getCurrentDirectory(); },
85599             close: ts.noop,
85600         };
85601         function getProgram() {
85602             return ts.Debug.checkDefined(state.program);
85603         }
85604     }
85605     ts.createRedirectedBuilderProgram = createRedirectedBuilderProgram;
85606 })(ts || (ts = {}));
85607 var ts;
85608 (function (ts) {
85609     function createSemanticDiagnosticsBuilderProgram(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
85610         return ts.createBuilderProgram(ts.BuilderProgramKind.SemanticDiagnosticsBuilderProgram, ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences));
85611     }
85612     ts.createSemanticDiagnosticsBuilderProgram = createSemanticDiagnosticsBuilderProgram;
85613     function createEmitAndSemanticDiagnosticsBuilderProgram(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
85614         return ts.createBuilderProgram(ts.BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram, ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences));
85615     }
85616     ts.createEmitAndSemanticDiagnosticsBuilderProgram = createEmitAndSemanticDiagnosticsBuilderProgram;
85617     function createAbstractBuilder(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
85618         var _a = ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences), newProgram = _a.newProgram, newConfigFileParsingDiagnostics = _a.configFileParsingDiagnostics;
85619         return ts.createRedirectedBuilderProgram({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }, newConfigFileParsingDiagnostics);
85620     }
85621     ts.createAbstractBuilder = createAbstractBuilder;
85622 })(ts || (ts = {}));
85623 var ts;
85624 (function (ts) {
85625     function removeIgnoredPath(path) {
85626         if (ts.endsWith(path, "/node_modules/.staging")) {
85627             return ts.removeSuffix(path, "/.staging");
85628         }
85629         return ts.some(ts.ignoredPaths, function (searchPath) { return ts.stringContains(path, searchPath); }) ?
85630             undefined :
85631             path;
85632     }
85633     ts.removeIgnoredPath = removeIgnoredPath;
85634     function canWatchDirectory(dirPath) {
85635         var rootLength = ts.getRootLength(dirPath);
85636         if (dirPath.length === rootLength) {
85637             return false;
85638         }
85639         var nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, rootLength);
85640         if (nextDirectorySeparator === -1) {
85641             return false;
85642         }
85643         var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1);
85644         var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47;
85645         if (isNonDirectorySeparatorRoot &&
85646             dirPath.search(/[a-zA-Z]:/) !== 0 &&
85647             pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) {
85648             nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1);
85649             if (nextDirectorySeparator === -1) {
85650                 return false;
85651             }
85652             pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1);
85653         }
85654         if (isNonDirectorySeparatorRoot &&
85655             pathPartForUserCheck.search(/users\//i) !== 0) {
85656             return true;
85657         }
85658         for (var searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) {
85659             searchIndex = dirPath.indexOf(ts.directorySeparator, searchIndex) + 1;
85660             if (searchIndex === 0) {
85661                 return false;
85662             }
85663         }
85664         return true;
85665     }
85666     ts.canWatchDirectory = canWatchDirectory;
85667     function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
85668         var filesWithChangedSetOfUnresolvedImports;
85669         var filesWithInvalidatedResolutions;
85670         var filesWithInvalidatedNonRelativeUnresolvedImports;
85671         var nonRelativeExternalModuleResolutions = ts.createMultiMap();
85672         var resolutionsWithFailedLookups = [];
85673         var resolvedFileToResolution = ts.createMultiMap();
85674         var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); });
85675         var cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost();
85676         var resolvedModuleNames = ts.createMap();
85677         var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects();
85678         var nonRelativeModuleNameCache = ts.createCacheWithRedirects();
85679         var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelativeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName);
85680         var resolvedTypeReferenceDirectives = ts.createMap();
85681         var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects();
85682         var failedLookupDefaultExtensions = [".ts", ".tsx", ".js", ".jsx", ".json"];
85683         var customFailedLookupPaths = ts.createMap();
85684         var directoryWatchesOfFailedLookups = ts.createMap();
85685         var rootDir = rootDirForResolution && ts.removeTrailingDirectorySeparator(ts.getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
85686         var rootPath = (rootDir && resolutionHost.toPath(rootDir));
85687         var rootSplitLength = rootPath !== undefined ? rootPath.split(ts.directorySeparator).length : 0;
85688         var typeRootsWatches = ts.createMap();
85689         return {
85690             startRecordingFilesWithChangedResolutions: startRecordingFilesWithChangedResolutions,
85691             finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions,
85692             startCachingPerDirectoryResolution: clearPerDirectoryResolutions,
85693             finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution,
85694             resolveModuleNames: resolveModuleNames,
85695             getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
85696             resolveTypeReferenceDirectives: resolveTypeReferenceDirectives,
85697             removeResolutionsFromProjectReferenceRedirects: removeResolutionsFromProjectReferenceRedirects,
85698             removeResolutionsOfFile: removeResolutionsOfFile,
85699             invalidateResolutionOfFile: invalidateResolutionOfFile,
85700             setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports,
85701             createHasInvalidatedResolution: createHasInvalidatedResolution,
85702             updateTypeRootsWatch: updateTypeRootsWatch,
85703             closeTypeRootsWatch: closeTypeRootsWatch,
85704             clear: clear
85705         };
85706         function getResolvedModule(resolution) {
85707             return resolution.resolvedModule;
85708         }
85709         function getResolvedTypeReferenceDirective(resolution) {
85710             return resolution.resolvedTypeReferenceDirective;
85711         }
85712         function isInDirectoryPath(dir, file) {
85713             if (dir === undefined || file.length <= dir.length) {
85714                 return false;
85715             }
85716             return ts.startsWith(file, dir) && file[dir.length] === ts.directorySeparator;
85717         }
85718         function clear() {
85719             ts.clearMap(directoryWatchesOfFailedLookups, ts.closeFileWatcherOf);
85720             customFailedLookupPaths.clear();
85721             nonRelativeExternalModuleResolutions.clear();
85722             closeTypeRootsWatch();
85723             resolvedModuleNames.clear();
85724             resolvedTypeReferenceDirectives.clear();
85725             resolvedFileToResolution.clear();
85726             resolutionsWithFailedLookups.length = 0;
85727             clearPerDirectoryResolutions();
85728         }
85729         function startRecordingFilesWithChangedResolutions() {
85730             filesWithChangedSetOfUnresolvedImports = [];
85731         }
85732         function finishRecordingFilesWithChangedResolutions() {
85733             var collected = filesWithChangedSetOfUnresolvedImports;
85734             filesWithChangedSetOfUnresolvedImports = undefined;
85735             return collected;
85736         }
85737         function isFileWithInvalidatedNonRelativeUnresolvedImports(path) {
85738             if (!filesWithInvalidatedNonRelativeUnresolvedImports) {
85739                 return false;
85740             }
85741             var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path);
85742             return !!value && !!value.length;
85743         }
85744         function createHasInvalidatedResolution(forceAllFilesAsInvalidated) {
85745             if (forceAllFilesAsInvalidated) {
85746                 filesWithInvalidatedResolutions = undefined;
85747                 return ts.returnTrue;
85748             }
85749             var collected = filesWithInvalidatedResolutions;
85750             filesWithInvalidatedResolutions = undefined;
85751             return function (path) { return (!!collected && collected.has(path)) ||
85752                 isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
85753         }
85754         function clearPerDirectoryResolutions() {
85755             perDirectoryResolvedModuleNames.clear();
85756             nonRelativeModuleNameCache.clear();
85757             perDirectoryResolvedTypeReferenceDirectives.clear();
85758             nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
85759             nonRelativeExternalModuleResolutions.clear();
85760         }
85761         function finishCachingPerDirectoryResolution() {
85762             filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
85763             clearPerDirectoryResolutions();
85764             directoryWatchesOfFailedLookups.forEach(function (watcher, path) {
85765                 if (watcher.refCount === 0) {
85766                     directoryWatchesOfFailedLookups.delete(path);
85767                     watcher.watcher.close();
85768                 }
85769             });
85770         }
85771         function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference) {
85772             var _a;
85773             var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference);
85774             if (!resolutionHost.getGlobalCache) {
85775                 return primaryResult;
85776             }
85777             var globalCache = resolutionHost.getGlobalCache();
85778             if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) {
85779                 var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations;
85780                 if (resolvedModule) {
85781                     primaryResult.resolvedModule = resolvedModule;
85782                     (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
85783                     return primaryResult;
85784                 }
85785             }
85786             return primaryResult;
85787         }
85788         function resolveNamesWithLocalCache(_a) {
85789             var _b;
85790             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;
85791             var path = resolutionHost.toPath(containingFile);
85792             var resolutionsInFile = cache.get(path) || cache.set(path, ts.createMap()).get(path);
85793             var dirPath = ts.getDirectoryPath(path);
85794             var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
85795             var perDirectoryResolution = perDirectoryCache.get(dirPath);
85796             if (!perDirectoryResolution) {
85797                 perDirectoryResolution = ts.createMap();
85798                 perDirectoryCache.set(dirPath, perDirectoryResolution);
85799             }
85800             var resolvedModules = [];
85801             var compilerOptions = resolutionHost.getCompilationSettings();
85802             var hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path);
85803             var program = resolutionHost.getCurrentProgram();
85804             var oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile);
85805             var unmatchedRedirects = oldRedirect ?
85806                 !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path :
85807                 !!redirectedReference;
85808             var seenNamesInFile = ts.createMap();
85809             for (var _i = 0, names_3 = names; _i < names_3.length; _i++) {
85810                 var name = names_3[_i];
85811                 var resolution = resolutionsInFile.get(name);
85812                 if (!seenNamesInFile.has(name) &&
85813                     unmatchedRedirects || !resolution || resolution.isInvalidated ||
85814                     (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
85815                     var existingResolution = resolution;
85816                     var resolutionInDirectory = perDirectoryResolution.get(name);
85817                     if (resolutionInDirectory) {
85818                         resolution = resolutionInDirectory;
85819                     }
85820                     else {
85821                         resolution = loader(name, containingFile, compilerOptions, ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost, redirectedReference);
85822                         perDirectoryResolution.set(name, resolution);
85823                     }
85824                     resolutionsInFile.set(name, resolution);
85825                     watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
85826                     if (existingResolution) {
85827                         stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName);
85828                     }
85829                     if (logChanges && filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) {
85830                         filesWithChangedSetOfUnresolvedImports.push(path);
85831                         logChanges = false;
85832                     }
85833                 }
85834                 ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated);
85835                 seenNamesInFile.set(name, true);
85836                 resolvedModules.push(getResolutionWithResolvedFileName(resolution));
85837             }
85838             resolutionsInFile.forEach(function (resolution, name) {
85839                 if (!seenNamesInFile.has(name) && !ts.contains(reusedNames, name)) {
85840                     stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
85841                     resolutionsInFile.delete(name);
85842                 }
85843             });
85844             return resolvedModules;
85845             function resolutionIsEqualTo(oldResolution, newResolution) {
85846                 if (oldResolution === newResolution) {
85847                     return true;
85848                 }
85849                 if (!oldResolution || !newResolution) {
85850                     return false;
85851                 }
85852                 var oldResult = getResolutionWithResolvedFileName(oldResolution);
85853                 var newResult = getResolutionWithResolvedFileName(newResolution);
85854                 if (oldResult === newResult) {
85855                     return true;
85856                 }
85857                 if (!oldResult || !newResult) {
85858                     return false;
85859                 }
85860                 return oldResult.resolvedFileName === newResult.resolvedFileName;
85861             }
85862         }
85863         function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference) {
85864             return resolveNamesWithLocalCache({
85865                 names: typeDirectiveNames,
85866                 containingFile: containingFile,
85867                 redirectedReference: redirectedReference,
85868                 cache: resolvedTypeReferenceDirectives,
85869                 perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives,
85870                 loader: ts.resolveTypeReferenceDirective,
85871                 getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
85872                 shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
85873             });
85874         }
85875         function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference) {
85876             return resolveNamesWithLocalCache({
85877                 names: moduleNames,
85878                 containingFile: containingFile,
85879                 redirectedReference: redirectedReference,
85880                 cache: resolvedModuleNames,
85881                 perDirectoryCacheWithRedirects: perDirectoryResolvedModuleNames,
85882                 loader: resolveModuleName,
85883                 getResolutionWithResolvedFileName: getResolvedModule,
85884                 shouldRetryResolution: function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); },
85885                 reusedNames: reusedNames,
85886                 logChanges: logChangesWhenResolvingModule
85887             });
85888         }
85889         function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) {
85890             var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile));
85891             return cache && cache.get(moduleName);
85892         }
85893         function isNodeModulesAtTypesDirectory(dirPath) {
85894             return ts.endsWith(dirPath, "/node_modules/@types");
85895         }
85896         function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath) {
85897             if (isInDirectoryPath(rootPath, failedLookupLocationPath)) {
85898                 failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
85899                 var failedLookupPathSplit = failedLookupLocationPath.split(ts.directorySeparator);
85900                 var failedLookupSplit = failedLookupLocation.split(ts.directorySeparator);
85901                 ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath);
85902                 if (failedLookupPathSplit.length > rootSplitLength + 1) {
85903                     return {
85904                         dir: failedLookupSplit.slice(0, rootSplitLength + 1).join(ts.directorySeparator),
85905                         dirPath: failedLookupPathSplit.slice(0, rootSplitLength + 1).join(ts.directorySeparator)
85906                     };
85907                 }
85908                 else {
85909                     return {
85910                         dir: rootDir,
85911                         dirPath: rootPath,
85912                         nonRecursive: false
85913                     };
85914                 }
85915             }
85916             return getDirectoryToWatchFromFailedLookupLocationDirectory(ts.getDirectoryPath(ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory())), ts.getDirectoryPath(failedLookupLocationPath));
85917         }
85918         function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath) {
85919             while (ts.pathContainsNodeModules(dirPath)) {
85920                 dir = ts.getDirectoryPath(dir);
85921                 dirPath = ts.getDirectoryPath(dirPath);
85922             }
85923             if (ts.isNodeModulesDirectory(dirPath)) {
85924                 return canWatchDirectory(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined;
85925             }
85926             var nonRecursive = true;
85927             var subDirectoryPath, subDirectory;
85928             if (rootPath !== undefined) {
85929                 while (!isInDirectoryPath(dirPath, rootPath)) {
85930                     var parentPath = ts.getDirectoryPath(dirPath);
85931                     if (parentPath === dirPath) {
85932                         break;
85933                     }
85934                     nonRecursive = false;
85935                     subDirectoryPath = dirPath;
85936                     subDirectory = dir;
85937                     dirPath = parentPath;
85938                     dir = ts.getDirectoryPath(dir);
85939                 }
85940             }
85941             return canWatchDirectory(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined;
85942         }
85943         function isPathWithDefaultFailedLookupExtension(path) {
85944             return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
85945         }
85946         function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
85947             if (resolution.refCount) {
85948                 resolution.refCount++;
85949                 ts.Debug.assertDefined(resolution.files);
85950             }
85951             else {
85952                 resolution.refCount = 1;
85953                 ts.Debug.assert(resolution.files === undefined);
85954                 if (ts.isExternalModuleNameRelative(name)) {
85955                     watchFailedLookupLocationOfResolution(resolution);
85956                 }
85957                 else {
85958                     nonRelativeExternalModuleResolutions.add(name, resolution);
85959                 }
85960                 var resolved = getResolutionWithResolvedFileName(resolution);
85961                 if (resolved && resolved.resolvedFileName) {
85962                     resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
85963                 }
85964             }
85965             (resolution.files || (resolution.files = [])).push(filePath);
85966         }
85967         function watchFailedLookupLocationOfResolution(resolution) {
85968             ts.Debug.assert(!!resolution.refCount);
85969             var failedLookupLocations = resolution.failedLookupLocations;
85970             if (!failedLookupLocations.length)
85971                 return;
85972             resolutionsWithFailedLookups.push(resolution);
85973             var setAtRoot = false;
85974             for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) {
85975                 var failedLookupLocation = failedLookupLocations_1[_i];
85976                 var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
85977                 var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
85978                 if (toWatch) {
85979                     var dir = toWatch.dir, dirPath = toWatch.dirPath, nonRecursive = toWatch.nonRecursive;
85980                     if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) {
85981                         var refCount = customFailedLookupPaths.get(failedLookupLocationPath) || 0;
85982                         customFailedLookupPaths.set(failedLookupLocationPath, refCount + 1);
85983                     }
85984                     if (dirPath === rootPath) {
85985                         ts.Debug.assert(!nonRecursive);
85986                         setAtRoot = true;
85987                     }
85988                     else {
85989                         setDirectoryWatcher(dir, dirPath, nonRecursive);
85990                     }
85991                 }
85992             }
85993             if (setAtRoot) {
85994                 setDirectoryWatcher(rootDir, rootPath, true);
85995             }
85996         }
85997         function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
85998             var program = resolutionHost.getCurrentProgram();
85999             if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
86000                 resolutions.forEach(watchFailedLookupLocationOfResolution);
86001             }
86002         }
86003         function setDirectoryWatcher(dir, dirPath, nonRecursive) {
86004             var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
86005             if (dirWatcher) {
86006                 ts.Debug.assert(!!nonRecursive === !!dirWatcher.nonRecursive);
86007                 dirWatcher.refCount++;
86008             }
86009             else {
86010                 directoryWatchesOfFailedLookups.set(dirPath, { watcher: createDirectoryWatcher(dir, dirPath, nonRecursive), refCount: 1, nonRecursive: nonRecursive });
86011             }
86012         }
86013         function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
86014             ts.unorderedRemoveItem(ts.Debug.assertDefined(resolution.files), filePath);
86015             resolution.refCount--;
86016             if (resolution.refCount) {
86017                 return;
86018             }
86019             var resolved = getResolutionWithResolvedFileName(resolution);
86020             if (resolved && resolved.resolvedFileName) {
86021                 resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution);
86022             }
86023             if (!ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
86024                 return;
86025             }
86026             var failedLookupLocations = resolution.failedLookupLocations;
86027             var removeAtRoot = false;
86028             for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) {
86029                 var failedLookupLocation = failedLookupLocations_2[_i];
86030                 var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
86031                 var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
86032                 if (toWatch) {
86033                     var dirPath = toWatch.dirPath;
86034                     var refCount = customFailedLookupPaths.get(failedLookupLocationPath);
86035                     if (refCount) {
86036                         if (refCount === 1) {
86037                             customFailedLookupPaths.delete(failedLookupLocationPath);
86038                         }
86039                         else {
86040                             ts.Debug.assert(refCount > 1);
86041                             customFailedLookupPaths.set(failedLookupLocationPath, refCount - 1);
86042                         }
86043                     }
86044                     if (dirPath === rootPath) {
86045                         removeAtRoot = true;
86046                     }
86047                     else {
86048                         removeDirectoryWatcher(dirPath);
86049                     }
86050                 }
86051             }
86052             if (removeAtRoot) {
86053                 removeDirectoryWatcher(rootPath);
86054             }
86055         }
86056         function removeDirectoryWatcher(dirPath) {
86057             var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
86058             dirWatcher.refCount--;
86059         }
86060         function createDirectoryWatcher(directory, dirPath, nonRecursive) {
86061             return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, function (fileOrDirectory) {
86062                 var fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
86063                 if (cachedDirectoryStructureHost) {
86064                     cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
86065                 }
86066                 if (invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath)) {
86067                     resolutionHost.onInvalidatedResolution();
86068                 }
86069             }, nonRecursive ? 0 : 1);
86070         }
86071         function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) {
86072             var resolutions = cache.get(filePath);
86073             if (resolutions) {
86074                 resolutions.forEach(function (resolution) { return stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName); });
86075                 cache.delete(filePath);
86076             }
86077         }
86078         function removeResolutionsFromProjectReferenceRedirects(filePath) {
86079             if (!ts.fileExtensionIs(filePath, ".json")) {
86080                 return;
86081             }
86082             var program = resolutionHost.getCurrentProgram();
86083             if (!program) {
86084                 return;
86085             }
86086             var resolvedProjectReference = program.getResolvedProjectReferenceByPath(filePath);
86087             if (!resolvedProjectReference) {
86088                 return;
86089             }
86090             resolvedProjectReference.commandLine.fileNames.forEach(function (f) { return removeResolutionsOfFile(resolutionHost.toPath(f)); });
86091         }
86092         function removeResolutionsOfFile(filePath) {
86093             removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModule);
86094             removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirective);
86095         }
86096         function invalidateResolution(resolution) {
86097             resolution.isInvalidated = true;
86098             var changedInAutoTypeReferenced = false;
86099             for (var _i = 0, _a = ts.Debug.assertDefined(resolution.files); _i < _a.length; _i++) {
86100                 var containingFilePath = _a[_i];
86101                 (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = ts.createMap())).set(containingFilePath, true);
86102                 changedInAutoTypeReferenced = changedInAutoTypeReferenced || containingFilePath.endsWith(ts.inferredTypesContainingFile);
86103             }
86104             if (changedInAutoTypeReferenced) {
86105                 resolutionHost.onChangedAutomaticTypeDirectiveNames();
86106             }
86107         }
86108         function invalidateResolutionOfFile(filePath) {
86109             removeResolutionsOfFile(filePath);
86110             ts.forEach(resolvedFileToResolution.get(filePath), invalidateResolution);
86111         }
86112         function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap) {
86113             ts.Debug.assert(filesWithInvalidatedNonRelativeUnresolvedImports === filesMap || filesWithInvalidatedNonRelativeUnresolvedImports === undefined);
86114             filesWithInvalidatedNonRelativeUnresolvedImports = filesMap;
86115         }
86116         function invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, isCreatingWatchedDirectory) {
86117             var isChangedFailedLookupLocation;
86118             if (isCreatingWatchedDirectory) {
86119                 isChangedFailedLookupLocation = function (location) { return isInDirectoryPath(fileOrDirectoryPath, resolutionHost.toPath(location)); };
86120             }
86121             else {
86122                 var updatedPath = removeIgnoredPath(fileOrDirectoryPath);
86123                 if (!updatedPath)
86124                     return false;
86125                 fileOrDirectoryPath = updatedPath;
86126                 if (resolutionHost.fileIsOpen(fileOrDirectoryPath)) {
86127                     return false;
86128                 }
86129                 var dirOfFileOrDirectory = ts.getDirectoryPath(fileOrDirectoryPath);
86130                 if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || ts.isNodeModulesDirectory(fileOrDirectoryPath) ||
86131                     isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || ts.isNodeModulesDirectory(dirOfFileOrDirectory)) {
86132                     isChangedFailedLookupLocation = function (location) {
86133                         var locationPath = resolutionHost.toPath(location);
86134                         return locationPath === fileOrDirectoryPath || ts.startsWith(resolutionHost.toPath(location), fileOrDirectoryPath);
86135                     };
86136                 }
86137                 else {
86138                     if (!isPathWithDefaultFailedLookupExtension(fileOrDirectoryPath) && !customFailedLookupPaths.has(fileOrDirectoryPath)) {
86139                         return false;
86140                     }
86141                     if (ts.isEmittedFileOfProgram(resolutionHost.getCurrentProgram(), fileOrDirectoryPath)) {
86142                         return false;
86143                     }
86144                     isChangedFailedLookupLocation = function (location) { return resolutionHost.toPath(location) === fileOrDirectoryPath; };
86145                 }
86146             }
86147             var invalidated = false;
86148             for (var _i = 0, resolutionsWithFailedLookups_1 = resolutionsWithFailedLookups; _i < resolutionsWithFailedLookups_1.length; _i++) {
86149                 var resolution = resolutionsWithFailedLookups_1[_i];
86150                 if (resolution.failedLookupLocations.some(isChangedFailedLookupLocation)) {
86151                     invalidateResolution(resolution);
86152                     invalidated = true;
86153                 }
86154             }
86155             return invalidated;
86156         }
86157         function closeTypeRootsWatch() {
86158             ts.clearMap(typeRootsWatches, ts.closeFileWatcher);
86159         }
86160         function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath) {
86161             if (isInDirectoryPath(rootPath, typeRootPath)) {
86162                 return rootPath;
86163             }
86164             var toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath);
86165             return toWatch && directoryWatchesOfFailedLookups.has(toWatch.dirPath) ? toWatch.dirPath : undefined;
86166         }
86167         function createTypeRootsWatch(typeRootPath, typeRoot) {
86168             return resolutionHost.watchTypeRootsDirectory(typeRoot, function (fileOrDirectory) {
86169                 var fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
86170                 if (cachedDirectoryStructureHost) {
86171                     cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
86172                 }
86173                 resolutionHost.onChangedAutomaticTypeDirectiveNames();
86174                 var dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath);
86175                 if (dirPath && invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath)) {
86176                     resolutionHost.onInvalidatedResolution();
86177                 }
86178             }, 1);
86179         }
86180         function updateTypeRootsWatch() {
86181             var options = resolutionHost.getCompilationSettings();
86182             if (options.types) {
86183                 closeTypeRootsWatch();
86184                 return;
86185             }
86186             var typeRoots = ts.getEffectiveTypeRoots(options, { directoryExists: directoryExistsForTypeRootWatch, getCurrentDirectory: getCurrentDirectory });
86187             if (typeRoots) {
86188                 ts.mutateMap(typeRootsWatches, ts.arrayToMap(typeRoots, function (tr) { return resolutionHost.toPath(tr); }), {
86189                     createNewValue: createTypeRootsWatch,
86190                     onDeleteValue: ts.closeFileWatcher
86191                 });
86192             }
86193             else {
86194                 closeTypeRootsWatch();
86195             }
86196         }
86197         function directoryExistsForTypeRootWatch(nodeTypesDirectory) {
86198             var dir = ts.getDirectoryPath(ts.getDirectoryPath(nodeTypesDirectory));
86199             var dirPath = resolutionHost.toPath(dir);
86200             return dirPath === rootPath || canWatchDirectory(dirPath);
86201         }
86202     }
86203     ts.createResolutionCache = createResolutionCache;
86204 })(ts || (ts = {}));
86205 var ts;
86206 (function (ts) {
86207     var moduleSpecifiers;
86208     (function (moduleSpecifiers) {
86209         function getPreferences(_a, compilerOptions, importingSourceFile) {
86210             var importModuleSpecifierPreference = _a.importModuleSpecifierPreference, importModuleSpecifierEnding = _a.importModuleSpecifierEnding;
86211             return {
86212                 relativePreference: importModuleSpecifierPreference === "relative" ? 0 : importModuleSpecifierPreference === "non-relative" ? 1 : 2,
86213                 ending: getEnding(),
86214             };
86215             function getEnding() {
86216                 switch (importModuleSpecifierEnding) {
86217                     case "minimal": return 0;
86218                     case "index": return 1;
86219                     case "js": return 2;
86220                     default: return usesJsExtensionOnImports(importingSourceFile) ? 2
86221                         : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 : 0;
86222                 }
86223             }
86224         }
86225         function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) {
86226             return {
86227                 relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 : 1,
86228                 ending: ts.hasJSFileExtension(oldImportSpecifier) ?
86229                     2 :
86230                     ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 : 0,
86231             };
86232         }
86233         function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, oldImportSpecifier) {
86234             var res = getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier));
86235             if (res === oldImportSpecifier)
86236                 return undefined;
86237             return res;
86238         }
86239         moduleSpecifiers.updateModuleSpecifier = updateModuleSpecifier;
86240         function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences) {
86241             if (preferences === void 0) { preferences = {}; }
86242             return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences(preferences, compilerOptions, importingSourceFile));
86243         }
86244         moduleSpecifiers.getModuleSpecifier = getModuleSpecifier;
86245         function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host) {
86246             var info = getInfo(importingSourceFileName, host);
86247             var modulePaths = getAllModulePaths(importingSourceFileName, nodeModulesFileName, host);
86248             return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions, true); });
86249         }
86250         moduleSpecifiers.getNodeModulesPackageName = getNodeModulesPackageName;
86251         function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, preferences) {
86252             var info = getInfo(importingSourceFileName, host);
86253             var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host);
86254             return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }) ||
86255                 getLocalModuleSpecifier(toFileName, info, compilerOptions, preferences);
86256         }
86257         function getModuleSpecifiers(moduleSymbol, compilerOptions, importingSourceFile, host, userPreferences) {
86258             var ambient = tryGetModuleNameFromAmbientModule(moduleSymbol);
86259             if (ambient)
86260                 return [ambient];
86261             var info = getInfo(importingSourceFile.path, host);
86262             var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol));
86263             var modulePaths = getAllModulePaths(importingSourceFile.path, moduleSourceFile.originalFileName, host);
86264             var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile);
86265             var global = ts.mapDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); });
86266             return global.length ? global : modulePaths.map(function (moduleFileName) { return getLocalModuleSpecifier(moduleFileName, info, compilerOptions, preferences); });
86267         }
86268         moduleSpecifiers.getModuleSpecifiers = getModuleSpecifiers;
86269         function getInfo(importingSourceFileName, host) {
86270             var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : true);
86271             var sourceDirectory = ts.getDirectoryPath(importingSourceFileName);
86272             return { getCanonicalFileName: getCanonicalFileName, sourceDirectory: sourceDirectory };
86273         }
86274         function getLocalModuleSpecifier(moduleFileName, _a, compilerOptions, _b) {
86275             var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory;
86276             var ending = _b.ending, relativePreference = _b.relativePreference;
86277             var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs;
86278             var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) ||
86279                 removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions);
86280             if (!baseUrl || relativePreference === 0) {
86281                 return relativePath;
86282             }
86283             var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseUrl, getCanonicalFileName);
86284             if (!relativeToBaseUrl) {
86285                 return relativePath;
86286             }
86287             var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions);
86288             var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths);
86289             var nonRelative = fromPaths === undefined ? importRelativeToBaseUrl : fromPaths;
86290             if (relativePreference === 1) {
86291                 return nonRelative;
86292             }
86293             if (relativePreference !== 2)
86294                 ts.Debug.assertNever(relativePreference);
86295             return isPathRelativeToParent(nonRelative) || countPathComponents(relativePath) < countPathComponents(nonRelative) ? relativePath : nonRelative;
86296         }
86297         function countPathComponents(path) {
86298             var count = 0;
86299             for (var i = ts.startsWith(path, "./") ? 2 : 0; i < path.length; i++) {
86300                 if (path.charCodeAt(i) === 47)
86301                     count++;
86302             }
86303             return count;
86304         }
86305         moduleSpecifiers.countPathComponents = countPathComponents;
86306         function usesJsExtensionOnImports(_a) {
86307             var imports = _a.imports;
86308             return ts.firstDefined(imports, function (_a) {
86309                 var text = _a.text;
86310                 return ts.pathIsRelative(text) ? ts.hasJSFileExtension(text) : undefined;
86311             }) || false;
86312         }
86313         function numberOfDirectorySeparators(str) {
86314             var match = str.match(/\//g);
86315             return match ? match.length : 0;
86316         }
86317         function comparePathsByNumberOfDirectorySeparators(a, b) {
86318             return ts.compareValues(numberOfDirectorySeparators(a), numberOfDirectorySeparators(b));
86319         }
86320         function forEachFileNameOfModule(importingFileName, importedFileName, host, preferSymlinks, cb) {
86321             var getCanonicalFileName = ts.hostGetCanonicalFileName(host);
86322             var cwd = host.getCurrentDirectory();
86323             var referenceRedirect = host.isSourceOfProjectReferenceRedirect(importedFileName) ? host.getProjectReferenceRedirect(importedFileName) : undefined;
86324             var redirects = host.redirectTargetsMap.get(ts.toPath(importedFileName, cwd, getCanonicalFileName)) || ts.emptyArray;
86325             var importedFileNames = __spreadArrays((referenceRedirect ? [referenceRedirect] : ts.emptyArray), [importedFileName], redirects);
86326             var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); });
86327             if (!preferSymlinks) {
86328                 var result_12 = ts.forEach(targets, cb);
86329                 if (result_12)
86330                     return result_12;
86331             }
86332             var links = host.getProbableSymlinks
86333                 ? host.getProbableSymlinks(host.getSourceFiles())
86334                 : ts.discoverProbableSymlinks(host.getSourceFiles(), getCanonicalFileName, cwd);
86335             var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive;
86336             var result = ts.forEachEntry(links, function (resolved, path) {
86337                 if (ts.startsWithDirectory(importingFileName, resolved, getCanonicalFileName)) {
86338                     return undefined;
86339                 }
86340                 var target = ts.find(targets, function (t) { return compareStrings(t.slice(0, resolved.length + 1), resolved + "/") === 0; });
86341                 if (target === undefined)
86342                     return undefined;
86343                 var relative = ts.getRelativePathFromDirectory(resolved, target, getCanonicalFileName);
86344                 var option = ts.resolvePath(path, relative);
86345                 if (!host.fileExists || host.fileExists(option)) {
86346                     var result_13 = cb(option);
86347                     if (result_13)
86348                         return result_13;
86349                 }
86350             });
86351             return result ||
86352                 (preferSymlinks ? ts.forEach(targets, cb) : undefined);
86353         }
86354         moduleSpecifiers.forEachFileNameOfModule = forEachFileNameOfModule;
86355         function getAllModulePaths(importingFileName, importedFileName, host) {
86356             var cwd = host.getCurrentDirectory();
86357             var getCanonicalFileName = ts.hostGetCanonicalFileName(host);
86358             var allFileNames = ts.createMap();
86359             var importedFileFromNodeModules = false;
86360             forEachFileNameOfModule(importingFileName, importedFileName, host, true, function (path) {
86361                 allFileNames.set(path, getCanonicalFileName(path));
86362                 importedFileFromNodeModules = importedFileFromNodeModules || ts.pathContainsNodeModules(path);
86363             });
86364             var sortedPaths = [];
86365             var _loop_20 = function (directory) {
86366                 var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
86367                 var pathsInDirectory;
86368                 allFileNames.forEach(function (canonicalFileName, fileName) {
86369                     if (ts.startsWith(canonicalFileName, directoryStart)) {
86370                         if (!importedFileFromNodeModules || ts.pathContainsNodeModules(fileName)) {
86371                             (pathsInDirectory || (pathsInDirectory = [])).push(fileName);
86372                         }
86373                         allFileNames.delete(fileName);
86374                     }
86375                 });
86376                 if (pathsInDirectory) {
86377                     if (pathsInDirectory.length > 1) {
86378                         pathsInDirectory.sort(comparePathsByNumberOfDirectorySeparators);
86379                     }
86380                     sortedPaths.push.apply(sortedPaths, pathsInDirectory);
86381                 }
86382                 var newDirectory = ts.getDirectoryPath(directory);
86383                 if (newDirectory === directory)
86384                     return out_directory_1 = directory, "break";
86385                 directory = newDirectory;
86386                 out_directory_1 = directory;
86387             };
86388             var out_directory_1;
86389             for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) {
86390                 var state_8 = _loop_20(directory);
86391                 directory = out_directory_1;
86392                 if (state_8 === "break")
86393                     break;
86394             }
86395             if (allFileNames.size) {
86396                 var remainingPaths = ts.arrayFrom(allFileNames.values());
86397                 if (remainingPaths.length > 1)
86398                     remainingPaths.sort(comparePathsByNumberOfDirectorySeparators);
86399                 sortedPaths.push.apply(sortedPaths, remainingPaths);
86400             }
86401             return sortedPaths;
86402         }
86403         function tryGetModuleNameFromAmbientModule(moduleSymbol) {
86404             var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); });
86405             if (decl) {
86406                 return decl.name.text;
86407             }
86408         }
86409         function tryGetModuleNameFromPaths(relativeToBaseUrlWithIndex, relativeToBaseUrl, paths) {
86410             for (var key in paths) {
86411                 for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
86412                     var patternText_1 = _a[_i];
86413                     var pattern = ts.removeFileExtension(ts.normalizePath(patternText_1));
86414                     var indexOfStar = pattern.indexOf("*");
86415                     if (indexOfStar !== -1) {
86416                         var prefix = pattern.substr(0, indexOfStar);
86417                         var suffix = pattern.substr(indexOfStar + 1);
86418                         if (relativeToBaseUrl.length >= prefix.length + suffix.length &&
86419                             ts.startsWith(relativeToBaseUrl, prefix) &&
86420                             ts.endsWith(relativeToBaseUrl, suffix) ||
86421                             !suffix && relativeToBaseUrl === ts.removeTrailingDirectorySeparator(prefix)) {
86422                             var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length);
86423                             return key.replace("*", matchedStar);
86424                         }
86425                     }
86426                     else if (pattern === relativeToBaseUrl || pattern === relativeToBaseUrlWithIndex) {
86427                         return key;
86428                     }
86429                 }
86430             }
86431         }
86432         function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
86433             var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
86434             if (normalizedTargetPath === undefined) {
86435                 return undefined;
86436             }
86437             var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName);
86438             var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath;
86439             return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs
86440                 ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
86441                 : ts.removeFileExtension(relativePath);
86442         }
86443         function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options, packageNameOnly) {
86444             var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory;
86445             if (!host.fileExists || !host.readFile) {
86446                 return undefined;
86447             }
86448             var parts = getNodeModulePathParts(moduleFileName);
86449             if (!parts) {
86450                 return undefined;
86451             }
86452             var moduleSpecifier = moduleFileName;
86453             if (!packageNameOnly) {
86454                 var packageRootIndex = parts.packageRootIndex;
86455                 var moduleFileNameForExtensionless = void 0;
86456                 while (true) {
86457                     var _b = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _b.moduleFileToTry, packageRootPath = _b.packageRootPath;
86458                     if (packageRootPath) {
86459                         moduleSpecifier = packageRootPath;
86460                         break;
86461                     }
86462                     if (!moduleFileNameForExtensionless)
86463                         moduleFileNameForExtensionless = moduleFileToTry;
86464                     packageRootIndex = moduleFileName.indexOf(ts.directorySeparator, packageRootIndex + 1);
86465                     if (packageRootIndex === -1) {
86466                         moduleSpecifier = getExtensionlessFileName(moduleFileNameForExtensionless);
86467                         break;
86468                     }
86469                 }
86470             }
86471             var globalTypingsCacheLocation = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation();
86472             var pathToTopLevelNodeModules = getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex));
86473             if (!(ts.startsWith(sourceDirectory, pathToTopLevelNodeModules) || globalTypingsCacheLocation && ts.startsWith(getCanonicalFileName(globalTypingsCacheLocation), pathToTopLevelNodeModules))) {
86474                 return undefined;
86475             }
86476             var nodeModulesDirectoryName = moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1);
86477             var packageName = ts.getPackageNameFromTypesPackageName(nodeModulesDirectoryName);
86478             return ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs && packageName === nodeModulesDirectoryName ? undefined : packageName;
86479             function tryDirectoryWithPackageJson(packageRootIndex) {
86480                 var packageRootPath = moduleFileName.substring(0, packageRootIndex);
86481                 var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
86482                 var moduleFileToTry = moduleFileName;
86483                 if (host.fileExists(packageJsonPath)) {
86484                     var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
86485                     var versionPaths = packageJsonContent.typesVersions
86486                         ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)
86487                         : undefined;
86488                     if (versionPaths) {
86489                         var subModuleName = moduleFileName.slice(packageRootPath.length + 1);
86490                         var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0, options), versionPaths.paths);
86491                         if (fromPaths !== undefined) {
86492                             moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths);
86493                         }
86494                     }
86495                     var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main;
86496                     if (ts.isString(mainFileRelative)) {
86497                         var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
86498                         if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
86499                             return { packageRootPath: packageRootPath, moduleFileToTry: moduleFileToTry };
86500                         }
86501                     }
86502                 }
86503                 return { moduleFileToTry: moduleFileToTry };
86504             }
86505             function getExtensionlessFileName(path) {
86506                 var fullModulePathWithoutExtension = ts.removeFileExtension(path);
86507                 if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) {
86508                     return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex);
86509                 }
86510                 return fullModulePathWithoutExtension;
86511             }
86512         }
86513         function tryGetAnyFileFromPath(host, path) {
86514             if (!host.fileExists)
86515                 return;
86516             var extensions = ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 }]);
86517             for (var _i = 0, extensions_3 = extensions; _i < extensions_3.length; _i++) {
86518                 var e = extensions_3[_i];
86519                 var fullPath = path + e;
86520                 if (host.fileExists(fullPath)) {
86521                     return fullPath;
86522                 }
86523             }
86524         }
86525         function getNodeModulePathParts(fullPath) {
86526             var topLevelNodeModulesIndex = 0;
86527             var topLevelPackageNameIndex = 0;
86528             var packageRootIndex = 0;
86529             var fileNameIndex = 0;
86530             var partStart = 0;
86531             var partEnd = 0;
86532             var state = 0;
86533             while (partEnd >= 0) {
86534                 partStart = partEnd;
86535                 partEnd = fullPath.indexOf("/", partStart + 1);
86536                 switch (state) {
86537                     case 0:
86538                         if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
86539                             topLevelNodeModulesIndex = partStart;
86540                             topLevelPackageNameIndex = partEnd;
86541                             state = 1;
86542                         }
86543                         break;
86544                     case 1:
86545                     case 2:
86546                         if (state === 1 && fullPath.charAt(partStart + 1) === "@") {
86547                             state = 2;
86548                         }
86549                         else {
86550                             packageRootIndex = partEnd;
86551                             state = 3;
86552                         }
86553                         break;
86554                     case 3:
86555                         if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
86556                             state = 1;
86557                         }
86558                         else {
86559                             state = 3;
86560                         }
86561                         break;
86562                 }
86563             }
86564             fileNameIndex = partStart;
86565             return state > 1 ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
86566         }
86567         function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
86568             return ts.firstDefined(rootDirs, function (rootDir) {
86569                 var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
86570                 return isPathRelativeToParent(relativePath) ? undefined : relativePath;
86571             });
86572         }
86573         function removeExtensionAndIndexPostFix(fileName, ending, options) {
86574             if (ts.fileExtensionIs(fileName, ".json"))
86575                 return fileName;
86576             var noExtension = ts.removeFileExtension(fileName);
86577             switch (ending) {
86578                 case 0:
86579                     return ts.removeSuffix(noExtension, "/index");
86580                 case 1:
86581                     return noExtension;
86582                 case 2:
86583                     return noExtension + getJSExtensionForFile(fileName, options);
86584                 default:
86585                     return ts.Debug.assertNever(ending);
86586             }
86587         }
86588         function getJSExtensionForFile(fileName, options) {
86589             var ext = ts.extensionFromPath(fileName);
86590             switch (ext) {
86591                 case ".ts":
86592                 case ".d.ts":
86593                     return ".js";
86594                 case ".tsx":
86595                     return options.jsx === 1 ? ".jsx" : ".js";
86596                 case ".js":
86597                 case ".jsx":
86598                 case ".json":
86599                     return ext;
86600                 case ".tsbuildinfo":
86601                     return ts.Debug.fail("Extension " + ".tsbuildinfo" + " is unsupported:: FileName:: " + fileName);
86602                 default:
86603                     return ts.Debug.assertNever(ext);
86604             }
86605         }
86606         function getRelativePathIfInDirectory(path, directoryPath, getCanonicalFileName) {
86607             var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false);
86608             return ts.isRootedDiskPath(relativePath) ? undefined : relativePath;
86609         }
86610         function isPathRelativeToParent(path) {
86611             return ts.startsWith(path, "..");
86612         }
86613     })(moduleSpecifiers = ts.moduleSpecifiers || (ts.moduleSpecifiers = {}));
86614 })(ts || (ts = {}));
86615 var ts;
86616 (function (ts) {
86617     var sysFormatDiagnosticsHost = ts.sys ? {
86618         getCurrentDirectory: function () { return ts.sys.getCurrentDirectory(); },
86619         getNewLine: function () { return ts.sys.newLine; },
86620         getCanonicalFileName: ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)
86621     } : undefined;
86622     function createDiagnosticReporter(system, pretty) {
86623         var host = system === ts.sys ? sysFormatDiagnosticsHost : {
86624             getCurrentDirectory: function () { return system.getCurrentDirectory(); },
86625             getNewLine: function () { return system.newLine; },
86626             getCanonicalFileName: ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames),
86627         };
86628         if (!pretty) {
86629             return function (diagnostic) { return system.write(ts.formatDiagnostic(diagnostic, host)); };
86630         }
86631         var diagnostics = new Array(1);
86632         return function (diagnostic) {
86633             diagnostics[0] = diagnostic;
86634             system.write(ts.formatDiagnosticsWithColorAndContext(diagnostics, host) + host.getNewLine());
86635             diagnostics[0] = undefined;
86636         };
86637     }
86638     ts.createDiagnosticReporter = createDiagnosticReporter;
86639     function clearScreenIfNotWatchingForFileChanges(system, diagnostic, options) {
86640         if (system.clearScreen &&
86641             !options.preserveWatchOutput &&
86642             !options.extendedDiagnostics &&
86643             !options.diagnostics &&
86644             ts.contains(ts.screenStartingMessageCodes, diagnostic.code)) {
86645             system.clearScreen();
86646             return true;
86647         }
86648         return false;
86649     }
86650     ts.screenStartingMessageCodes = [
86651         ts.Diagnostics.Starting_compilation_in_watch_mode.code,
86652         ts.Diagnostics.File_change_detected_Starting_incremental_compilation.code,
86653     ];
86654     function getPlainDiagnosticFollowingNewLines(diagnostic, newLine) {
86655         return ts.contains(ts.screenStartingMessageCodes, diagnostic.code)
86656             ? newLine + newLine
86657             : newLine;
86658     }
86659     function getLocaleTimeString(system) {
86660         return !system.now ?
86661             new Date().toLocaleTimeString() :
86662             system.now().toLocaleTimeString("en-US", { timeZone: "UTC" });
86663     }
86664     ts.getLocaleTimeString = getLocaleTimeString;
86665     function createWatchStatusReporter(system, pretty) {
86666         return pretty ?
86667             function (diagnostic, newLine, options) {
86668                 clearScreenIfNotWatchingForFileChanges(system, diagnostic, options);
86669                 var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] ";
86670                 output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine);
86671                 system.write(output);
86672             } :
86673             function (diagnostic, newLine, options) {
86674                 var output = "";
86675                 if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) {
86676                     output += newLine;
86677                 }
86678                 output += getLocaleTimeString(system) + " - ";
86679                 output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine);
86680                 system.write(output);
86681             };
86682     }
86683     ts.createWatchStatusReporter = createWatchStatusReporter;
86684     function parseConfigFileWithSystem(configFileName, optionsToExtend, watchOptionsToExtend, system, reportDiagnostic) {
86685         var host = system;
86686         host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); };
86687         var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, undefined, watchOptionsToExtend);
86688         host.onUnRecoverableConfigFileDiagnostic = undefined;
86689         return result;
86690     }
86691     ts.parseConfigFileWithSystem = parseConfigFileWithSystem;
86692     function getErrorCountForSummary(diagnostics) {
86693         return ts.countWhere(diagnostics, function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; });
86694     }
86695     ts.getErrorCountForSummary = getErrorCountForSummary;
86696     function getWatchErrorSummaryDiagnosticMessage(errorCount) {
86697         return errorCount === 1 ?
86698             ts.Diagnostics.Found_1_error_Watching_for_file_changes :
86699             ts.Diagnostics.Found_0_errors_Watching_for_file_changes;
86700     }
86701     ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage;
86702     function getErrorSummaryText(errorCount, newLine) {
86703         if (errorCount === 0)
86704             return "";
86705         var d = ts.createCompilerDiagnostic(errorCount === 1 ? ts.Diagnostics.Found_1_error : ts.Diagnostics.Found_0_errors, errorCount);
86706         return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine;
86707     }
86708     ts.getErrorSummaryText = getErrorSummaryText;
86709     function listFiles(program, writeFileName) {
86710         if (program.getCompilerOptions().listFiles || program.getCompilerOptions().listFilesOnly) {
86711             ts.forEach(program.getSourceFiles(), function (file) {
86712                 writeFileName(file.fileName);
86713             });
86714         }
86715     }
86716     ts.listFiles = listFiles;
86717     function emitFilesAndReportErrors(program, reportDiagnostic, writeFileName, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
86718         var isListFilesOnly = !!program.getCompilerOptions().listFilesOnly;
86719         var allDiagnostics = program.getConfigFileParsingDiagnostics().slice();
86720         var configFileParsingDiagnosticsLength = allDiagnostics.length;
86721         ts.addRange(allDiagnostics, program.getSyntacticDiagnostics(undefined, cancellationToken));
86722         if (allDiagnostics.length === configFileParsingDiagnosticsLength) {
86723             ts.addRange(allDiagnostics, program.getOptionsDiagnostics(cancellationToken));
86724             if (!isListFilesOnly) {
86725                 ts.addRange(allDiagnostics, program.getGlobalDiagnostics(cancellationToken));
86726                 if (allDiagnostics.length === configFileParsingDiagnosticsLength) {
86727                     ts.addRange(allDiagnostics, program.getSemanticDiagnostics(undefined, cancellationToken));
86728                 }
86729             }
86730         }
86731         var emitResult = isListFilesOnly
86732             ? { emitSkipped: true, diagnostics: ts.emptyArray }
86733             : program.emit(undefined, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers);
86734         var emittedFiles = emitResult.emittedFiles, emitDiagnostics = emitResult.diagnostics;
86735         ts.addRange(allDiagnostics, emitDiagnostics);
86736         var diagnostics = ts.sortAndDeduplicateDiagnostics(allDiagnostics);
86737         diagnostics.forEach(reportDiagnostic);
86738         if (writeFileName) {
86739             var currentDir_1 = program.getCurrentDirectory();
86740             ts.forEach(emittedFiles, function (file) {
86741                 var filepath = ts.getNormalizedAbsolutePath(file, currentDir_1);
86742                 writeFileName("TSFILE: " + filepath);
86743             });
86744             listFiles(program, writeFileName);
86745         }
86746         if (reportSummary) {
86747             reportSummary(getErrorCountForSummary(diagnostics));
86748         }
86749         return {
86750             emitResult: emitResult,
86751             diagnostics: diagnostics,
86752         };
86753     }
86754     ts.emitFilesAndReportErrors = emitFilesAndReportErrors;
86755     function emitFilesAndReportErrorsAndGetExitStatus(program, reportDiagnostic, writeFileName, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
86756         var _a = emitFilesAndReportErrors(program, reportDiagnostic, writeFileName, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers), emitResult = _a.emitResult, diagnostics = _a.diagnostics;
86757         if (emitResult.emitSkipped && diagnostics.length > 0) {
86758             return ts.ExitStatus.DiagnosticsPresent_OutputsSkipped;
86759         }
86760         else if (diagnostics.length > 0) {
86761             return ts.ExitStatus.DiagnosticsPresent_OutputsGenerated;
86762         }
86763         return ts.ExitStatus.Success;
86764     }
86765     ts.emitFilesAndReportErrorsAndGetExitStatus = emitFilesAndReportErrorsAndGetExitStatus;
86766     ts.noopFileWatcher = { close: ts.noop };
86767     function createWatchHost(system, reportWatchStatus) {
86768         if (system === void 0) { system = ts.sys; }
86769         var onWatchStatusChange = reportWatchStatus || createWatchStatusReporter(system);
86770         return {
86771             onWatchStatusChange: onWatchStatusChange,
86772             watchFile: ts.maybeBind(system, system.watchFile) || (function () { return ts.noopFileWatcher; }),
86773             watchDirectory: ts.maybeBind(system, system.watchDirectory) || (function () { return ts.noopFileWatcher; }),
86774             setTimeout: ts.maybeBind(system, system.setTimeout) || ts.noop,
86775             clearTimeout: ts.maybeBind(system, system.clearTimeout) || ts.noop
86776         };
86777     }
86778     ts.createWatchHost = createWatchHost;
86779     ts.WatchType = {
86780         ConfigFile: "Config file",
86781         SourceFile: "Source file",
86782         MissingFile: "Missing file",
86783         WildcardDirectory: "Wild card directory",
86784         FailedLookupLocations: "Failed Lookup Locations",
86785         TypeRoots: "Type roots"
86786     };
86787     function createWatchFactory(host, options) {
86788         var watchLogLevel = host.trace ? options.extendedDiagnostics ? ts.WatchLogLevel.Verbose : options.diagnostics ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None;
86789         var writeLog = watchLogLevel !== ts.WatchLogLevel.None ? (function (s) { return host.trace(s); }) : ts.noop;
86790         var result = ts.getWatchFactory(watchLogLevel, writeLog);
86791         result.writeLog = writeLog;
86792         return result;
86793     }
86794     ts.createWatchFactory = createWatchFactory;
86795     function createCompilerHostFromProgramHost(host, getCompilerOptions, directoryStructureHost) {
86796         if (directoryStructureHost === void 0) { directoryStructureHost = host; }
86797         var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames();
86798         var hostGetNewLine = ts.memoize(function () { return host.getNewLine(); });
86799         return {
86800             getSourceFile: function (fileName, languageVersion, onError) {
86801                 var text;
86802                 try {
86803                     ts.performance.mark("beforeIORead");
86804                     text = host.readFile(fileName, getCompilerOptions().charset);
86805                     ts.performance.mark("afterIORead");
86806                     ts.performance.measure("I/O Read", "beforeIORead", "afterIORead");
86807                 }
86808                 catch (e) {
86809                     if (onError) {
86810                         onError(e.message);
86811                     }
86812                     text = "";
86813                 }
86814                 return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion) : undefined;
86815             },
86816             getDefaultLibLocation: ts.maybeBind(host, host.getDefaultLibLocation),
86817             getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); },
86818             writeFile: writeFile,
86819             getCurrentDirectory: ts.memoize(function () { return host.getCurrentDirectory(); }),
86820             useCaseSensitiveFileNames: function () { return useCaseSensitiveFileNames; },
86821             getCanonicalFileName: ts.createGetCanonicalFileName(useCaseSensitiveFileNames),
86822             getNewLine: function () { return ts.getNewLineCharacter(getCompilerOptions(), hostGetNewLine); },
86823             fileExists: function (f) { return host.fileExists(f); },
86824             readFile: function (f) { return host.readFile(f); },
86825             trace: ts.maybeBind(host, host.trace),
86826             directoryExists: ts.maybeBind(directoryStructureHost, directoryStructureHost.directoryExists),
86827             getDirectories: ts.maybeBind(directoryStructureHost, directoryStructureHost.getDirectories),
86828             realpath: ts.maybeBind(host, host.realpath),
86829             getEnvironmentVariable: ts.maybeBind(host, host.getEnvironmentVariable) || (function () { return ""; }),
86830             createHash: ts.maybeBind(host, host.createHash),
86831             readDirectory: ts.maybeBind(host, host.readDirectory),
86832         };
86833         function writeFile(fileName, text, writeByteOrderMark, onError) {
86834             try {
86835                 ts.performance.mark("beforeIOWrite");
86836                 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); });
86837                 ts.performance.mark("afterIOWrite");
86838                 ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
86839             }
86840             catch (e) {
86841                 if (onError) {
86842                     onError(e.message);
86843                 }
86844             }
86845         }
86846     }
86847     ts.createCompilerHostFromProgramHost = createCompilerHostFromProgramHost;
86848     function setGetSourceFileAsHashVersioned(compilerHost, host) {
86849         var originalGetSourceFile = compilerHost.getSourceFile;
86850         var computeHash = host.createHash || ts.generateDjb2Hash;
86851         compilerHost.getSourceFile = function () {
86852             var args = [];
86853             for (var _i = 0; _i < arguments.length; _i++) {
86854                 args[_i] = arguments[_i];
86855             }
86856             var result = originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args));
86857             if (result) {
86858                 result.version = computeHash.call(host, result.text);
86859             }
86860             return result;
86861         };
86862     }
86863     ts.setGetSourceFileAsHashVersioned = setGetSourceFileAsHashVersioned;
86864     function createProgramHost(system, createProgram) {
86865         var getDefaultLibLocation = ts.memoize(function () { return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath())); });
86866         return {
86867             useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; },
86868             getNewLine: function () { return system.newLine; },
86869             getCurrentDirectory: ts.memoize(function () { return system.getCurrentDirectory(); }),
86870             getDefaultLibLocation: getDefaultLibLocation,
86871             getDefaultLibFileName: function (options) { return ts.combinePaths(getDefaultLibLocation(), ts.getDefaultLibFileName(options)); },
86872             fileExists: function (path) { return system.fileExists(path); },
86873             readFile: function (path, encoding) { return system.readFile(path, encoding); },
86874             directoryExists: function (path) { return system.directoryExists(path); },
86875             getDirectories: function (path) { return system.getDirectories(path); },
86876             readDirectory: function (path, extensions, exclude, include, depth) { return system.readDirectory(path, extensions, exclude, include, depth); },
86877             realpath: ts.maybeBind(system, system.realpath),
86878             getEnvironmentVariable: ts.maybeBind(system, system.getEnvironmentVariable),
86879             trace: function (s) { return system.write(s + system.newLine); },
86880             createDirectory: function (path) { return system.createDirectory(path); },
86881             writeFile: function (path, data, writeByteOrderMark) { return system.writeFile(path, data, writeByteOrderMark); },
86882             createHash: ts.maybeBind(system, system.createHash),
86883             createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram
86884         };
86885     }
86886     ts.createProgramHost = createProgramHost;
86887     function createWatchCompilerHost(system, createProgram, reportDiagnostic, reportWatchStatus) {
86888         if (system === void 0) { system = ts.sys; }
86889         var writeFileName = function (s) { return system.write(s + system.newLine); };
86890         var result = createProgramHost(system, createProgram);
86891         ts.copyProperties(result, createWatchHost(system, reportWatchStatus));
86892         result.afterProgramCreate = function (builderProgram) {
86893             var compilerOptions = builderProgram.getCompilerOptions();
86894             var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; });
86895             emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions, errorCount); });
86896         };
86897         return result;
86898     }
86899     function reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic) {
86900         reportDiagnostic(diagnostic);
86901         system.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
86902     }
86903     function createWatchCompilerHostOfConfigFile(_a) {
86904         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;
86905         var diagnosticReporter = reportDiagnostic || createDiagnosticReporter(system);
86906         var host = createWatchCompilerHost(system, createProgram, diagnosticReporter, reportWatchStatus);
86907         host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, diagnosticReporter, diagnostic); };
86908         host.configFileName = configFileName;
86909         host.optionsToExtend = optionsToExtend;
86910         host.watchOptionsToExtend = watchOptionsToExtend;
86911         host.extraFileExtensions = extraFileExtensions;
86912         return host;
86913     }
86914     ts.createWatchCompilerHostOfConfigFile = createWatchCompilerHostOfConfigFile;
86915     function createWatchCompilerHostOfFilesAndCompilerOptions(_a) {
86916         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;
86917         var host = createWatchCompilerHost(system, createProgram, reportDiagnostic || createDiagnosticReporter(system), reportWatchStatus);
86918         host.rootFiles = rootFiles;
86919         host.options = options;
86920         host.watchOptions = watchOptions;
86921         host.projectReferences = projectReferences;
86922         return host;
86923     }
86924     ts.createWatchCompilerHostOfFilesAndCompilerOptions = createWatchCompilerHostOfFilesAndCompilerOptions;
86925     function performIncrementalCompilation(input) {
86926         var system = input.system || ts.sys;
86927         var host = input.host || (input.host = ts.createIncrementalCompilerHost(input.options, system));
86928         var builderProgram = ts.createIncrementalProgram(input);
86929         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);
86930         if (input.afterProgramEmitAndDiagnostics)
86931             input.afterProgramEmitAndDiagnostics(builderProgram);
86932         return exitStatus;
86933     }
86934     ts.performIncrementalCompilation = performIncrementalCompilation;
86935 })(ts || (ts = {}));
86936 var ts;
86937 (function (ts) {
86938     function readBuilderProgram(compilerOptions, host) {
86939         if (compilerOptions.out || compilerOptions.outFile)
86940             return undefined;
86941         var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
86942         if (!buildInfoPath)
86943             return undefined;
86944         var content = host.readFile(buildInfoPath);
86945         if (!content)
86946             return undefined;
86947         var buildInfo = ts.getBuildInfo(content);
86948         if (buildInfo.version !== ts.version)
86949             return undefined;
86950         if (!buildInfo.program)
86951             return undefined;
86952         return ts.createBuildProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
86953     }
86954     ts.readBuilderProgram = readBuilderProgram;
86955     function createIncrementalCompilerHost(options, system) {
86956         if (system === void 0) { system = ts.sys; }
86957         var host = ts.createCompilerHostWorker(options, undefined, system);
86958         host.createHash = ts.maybeBind(system, system.createHash);
86959         ts.setGetSourceFileAsHashVersioned(host, system);
86960         ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
86961         return host;
86962     }
86963     ts.createIncrementalCompilerHost = createIncrementalCompilerHost;
86964     function createIncrementalProgram(_a) {
86965         var rootNames = _a.rootNames, options = _a.options, configFileParsingDiagnostics = _a.configFileParsingDiagnostics, projectReferences = _a.projectReferences, host = _a.host, createProgram = _a.createProgram;
86966         host = host || createIncrementalCompilerHost(options);
86967         createProgram = createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram;
86968         var oldProgram = readBuilderProgram(options, host);
86969         return createProgram(rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences);
86970     }
86971     ts.createIncrementalProgram = createIncrementalProgram;
86972     function createWatchCompilerHost(rootFilesOrConfigFileName, options, system, createProgram, reportDiagnostic, reportWatchStatus, projectReferencesOrWatchOptionsToExtend, watchOptionsOrExtraFileExtensions) {
86973         if (ts.isArray(rootFilesOrConfigFileName)) {
86974             return ts.createWatchCompilerHostOfFilesAndCompilerOptions({
86975                 rootFiles: rootFilesOrConfigFileName,
86976                 options: options,
86977                 watchOptions: watchOptionsOrExtraFileExtensions,
86978                 projectReferences: projectReferencesOrWatchOptionsToExtend,
86979                 system: system,
86980                 createProgram: createProgram,
86981                 reportDiagnostic: reportDiagnostic,
86982                 reportWatchStatus: reportWatchStatus,
86983             });
86984         }
86985         else {
86986             return ts.createWatchCompilerHostOfConfigFile({
86987                 configFileName: rootFilesOrConfigFileName,
86988                 optionsToExtend: options,
86989                 watchOptionsToExtend: projectReferencesOrWatchOptionsToExtend,
86990                 extraFileExtensions: watchOptionsOrExtraFileExtensions,
86991                 system: system,
86992                 createProgram: createProgram,
86993                 reportDiagnostic: reportDiagnostic,
86994                 reportWatchStatus: reportWatchStatus,
86995             });
86996         }
86997     }
86998     ts.createWatchCompilerHost = createWatchCompilerHost;
86999     function createWatchProgram(host) {
87000         var builderProgram;
87001         var reloadLevel;
87002         var missingFilesMap;
87003         var watchedWildcardDirectories;
87004         var timerToUpdateProgram;
87005         var sourceFilesCache = ts.createMap();
87006         var missingFilePathsRequestedForRelease;
87007         var hasChangedCompilerOptions = false;
87008         var hasChangedAutomaticTypeDirectiveNames = false;
87009         var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames();
87010         var currentDirectory = host.getCurrentDirectory();
87011         var configFileName = host.configFileName, _a = host.optionsToExtend, optionsToExtendForConfigFile = _a === void 0 ? {} : _a, watchOptionsToExtend = host.watchOptionsToExtend, extraFileExtensions = host.extraFileExtensions, createProgram = host.createProgram;
87012         var rootFileNames = host.rootFiles, compilerOptions = host.options, watchOptions = host.watchOptions, projectReferences = host.projectReferences;
87013         var configFileSpecs;
87014         var configFileParsingDiagnostics;
87015         var canConfigFileJsonReportNoInputFiles = false;
87016         var hasChangedConfigFileParsingErrors = false;
87017         var cachedDirectoryStructureHost = configFileName === undefined ? undefined : ts.createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames);
87018         var directoryStructureHost = cachedDirectoryStructureHost || host;
87019         var parseConfigFileHost = ts.parseConfigHostFromCompilerHostLike(host, directoryStructureHost);
87020         var newLine = updateNewLine();
87021         if (configFileName && host.configFileParsingResult) {
87022             setConfigFileParsingResult(host.configFileParsingResult);
87023             newLine = updateNewLine();
87024         }
87025         reportWatchDiagnostic(ts.Diagnostics.Starting_compilation_in_watch_mode);
87026         if (configFileName && !host.configFileParsingResult) {
87027             newLine = ts.getNewLineCharacter(optionsToExtendForConfigFile, function () { return host.getNewLine(); });
87028             ts.Debug.assert(!rootFileNames);
87029             parseConfigFile();
87030             newLine = updateNewLine();
87031         }
87032         var _b = ts.createWatchFactory(host, compilerOptions), watchFile = _b.watchFile, watchFilePath = _b.watchFilePath, watchDirectory = _b.watchDirectory, writeLog = _b.writeLog;
87033         var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
87034         writeLog("Current directory: " + currentDirectory + " CaseSensitiveFileNames: " + useCaseSensitiveFileNames);
87035         var configFileWatcher;
87036         if (configFileName) {
87037             configFileWatcher = watchFile(host, configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile);
87038         }
87039         var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return compilerOptions; }, directoryStructureHost);
87040         ts.setGetSourceFileAsHashVersioned(compilerHost, host);
87041         var getNewSourceFile = compilerHost.getSourceFile;
87042         compilerHost.getSourceFile = function (fileName) {
87043             var args = [];
87044             for (var _i = 1; _i < arguments.length; _i++) {
87045                 args[_i - 1] = arguments[_i];
87046             }
87047             return getVersionedSourceFileByPath.apply(void 0, __spreadArrays([fileName, toPath(fileName)], args));
87048         };
87049         compilerHost.getSourceFileByPath = getVersionedSourceFileByPath;
87050         compilerHost.getNewLine = function () { return newLine; };
87051         compilerHost.fileExists = fileExists;
87052         compilerHost.onReleaseOldSourceFile = onReleaseOldSourceFile;
87053         compilerHost.toPath = toPath;
87054         compilerHost.getCompilationSettings = function () { return compilerOptions; };
87055         compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect);
87056         compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(host, dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); };
87057         compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(host, dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); };
87058         compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; };
87059         compilerHost.onInvalidatedResolution = scheduleProgramUpdate;
87060         compilerHost.onChangedAutomaticTypeDirectiveNames = function () {
87061             hasChangedAutomaticTypeDirectiveNames = true;
87062             scheduleProgramUpdate();
87063         };
87064         compilerHost.fileIsOpen = ts.returnFalse;
87065         compilerHost.getCurrentProgram = getCurrentProgram;
87066         compilerHost.writeLog = writeLog;
87067         var resolutionCache = ts.createResolutionCache(compilerHost, configFileName ?
87068             ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFileName, currentDirectory)) :
87069             currentDirectory, false);
87070         compilerHost.resolveModuleNames = host.resolveModuleNames ?
87071             (function () {
87072                 var args = [];
87073                 for (var _i = 0; _i < arguments.length; _i++) {
87074                     args[_i] = arguments[_i];
87075                 }
87076                 return host.resolveModuleNames.apply(host, args);
87077             }) :
87078             (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); });
87079         compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ?
87080             (function () {
87081                 var args = [];
87082                 for (var _i = 0; _i < arguments.length; _i++) {
87083                     args[_i] = arguments[_i];
87084                 }
87085                 return host.resolveTypeReferenceDirectives.apply(host, args);
87086             }) :
87087             (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); });
87088         var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
87089         builderProgram = readBuilderProgram(compilerOptions, compilerHost);
87090         synchronizeProgram();
87091         watchConfigFileWildCardDirectories();
87092         return configFileName ?
87093             { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, close: close } :
87094             { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, updateRootFileNames: updateRootFileNames, close: close };
87095         function close() {
87096             resolutionCache.clear();
87097             ts.clearMap(sourceFilesCache, function (value) {
87098                 if (value && value.fileWatcher) {
87099                     value.fileWatcher.close();
87100                     value.fileWatcher = undefined;
87101                 }
87102             });
87103             if (configFileWatcher) {
87104                 configFileWatcher.close();
87105                 configFileWatcher = undefined;
87106             }
87107             if (watchedWildcardDirectories) {
87108                 ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf);
87109                 watchedWildcardDirectories = undefined;
87110             }
87111             if (missingFilesMap) {
87112                 ts.clearMap(missingFilesMap, ts.closeFileWatcher);
87113                 missingFilesMap = undefined;
87114             }
87115         }
87116         function getCurrentBuilderProgram() {
87117             return builderProgram;
87118         }
87119         function getCurrentProgram() {
87120             return builderProgram && builderProgram.getProgramOrUndefined();
87121         }
87122         function synchronizeProgram() {
87123             writeLog("Synchronizing program");
87124             var program = getCurrentBuilderProgram();
87125             if (hasChangedCompilerOptions) {
87126                 newLine = updateNewLine();
87127                 if (program && ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) {
87128                     resolutionCache.clear();
87129                 }
87130             }
87131             var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
87132             if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences)) {
87133                 if (hasChangedConfigFileParsingErrors) {
87134                     builderProgram = createProgram(undefined, undefined, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
87135                     hasChangedConfigFileParsingErrors = false;
87136                 }
87137             }
87138             else {
87139                 createNewProgram(hasInvalidatedResolution);
87140             }
87141             if (host.afterProgramCreate && program !== builderProgram) {
87142                 host.afterProgramCreate(builderProgram);
87143             }
87144             return builderProgram;
87145         }
87146         function createNewProgram(hasInvalidatedResolution) {
87147             writeLog("CreatingProgramWith::");
87148             writeLog("  roots: " + JSON.stringify(rootFileNames));
87149             writeLog("  options: " + JSON.stringify(compilerOptions));
87150             var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram();
87151             hasChangedCompilerOptions = false;
87152             hasChangedConfigFileParsingErrors = false;
87153             resolutionCache.startCachingPerDirectoryResolution();
87154             compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
87155             compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
87156             hasChangedAutomaticTypeDirectiveNames = false;
87157             builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
87158             resolutionCache.finishCachingPerDirectoryResolution();
87159             ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = ts.createMap()), watchMissingFilePath);
87160             if (needsUpdateInTypeRootWatch) {
87161                 resolutionCache.updateTypeRootsWatch();
87162             }
87163             if (missingFilePathsRequestedForRelease) {
87164                 for (var _i = 0, missingFilePathsRequestedForRelease_1 = missingFilePathsRequestedForRelease; _i < missingFilePathsRequestedForRelease_1.length; _i++) {
87165                     var missingFilePath = missingFilePathsRequestedForRelease_1[_i];
87166                     if (!missingFilesMap.has(missingFilePath)) {
87167                         sourceFilesCache.delete(missingFilePath);
87168                     }
87169                 }
87170                 missingFilePathsRequestedForRelease = undefined;
87171             }
87172         }
87173         function updateRootFileNames(files) {
87174             ts.Debug.assert(!configFileName, "Cannot update root file names with config file watch mode");
87175             rootFileNames = files;
87176             scheduleProgramUpdate();
87177         }
87178         function updateNewLine() {
87179             return ts.getNewLineCharacter(compilerOptions || optionsToExtendForConfigFile, function () { return host.getNewLine(); });
87180         }
87181         function toPath(fileName) {
87182             return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
87183         }
87184         function isFileMissingOnHost(hostSourceFile) {
87185             return typeof hostSourceFile === "boolean";
87186         }
87187         function isFilePresenceUnknownOnHost(hostSourceFile) {
87188             return typeof hostSourceFile.version === "boolean";
87189         }
87190         function fileExists(fileName) {
87191             var path = toPath(fileName);
87192             if (isFileMissingOnHost(sourceFilesCache.get(path))) {
87193                 return false;
87194             }
87195             return directoryStructureHost.fileExists(fileName);
87196         }
87197         function getVersionedSourceFileByPath(fileName, path, languageVersion, onError, shouldCreateNewSourceFile) {
87198             var hostSourceFile = sourceFilesCache.get(path);
87199             if (isFileMissingOnHost(hostSourceFile)) {
87200                 return undefined;
87201             }
87202             if (hostSourceFile === undefined || shouldCreateNewSourceFile || isFilePresenceUnknownOnHost(hostSourceFile)) {
87203                 var sourceFile = getNewSourceFile(fileName, languageVersion, onError);
87204                 if (hostSourceFile) {
87205                     if (sourceFile) {
87206                         hostSourceFile.sourceFile = sourceFile;
87207                         hostSourceFile.version = sourceFile.version;
87208                         if (!hostSourceFile.fileWatcher) {
87209                             hostSourceFile.fileWatcher = watchFilePath(host, fileName, onSourceFileChange, ts.PollingInterval.Low, watchOptions, path, ts.WatchType.SourceFile);
87210                         }
87211                     }
87212                     else {
87213                         if (hostSourceFile.fileWatcher) {
87214                             hostSourceFile.fileWatcher.close();
87215                         }
87216                         sourceFilesCache.set(path, false);
87217                     }
87218                 }
87219                 else {
87220                     if (sourceFile) {
87221                         var fileWatcher = watchFilePath(host, fileName, onSourceFileChange, ts.PollingInterval.Low, watchOptions, path, ts.WatchType.SourceFile);
87222                         sourceFilesCache.set(path, { sourceFile: sourceFile, version: sourceFile.version, fileWatcher: fileWatcher });
87223                     }
87224                     else {
87225                         sourceFilesCache.set(path, false);
87226                     }
87227                 }
87228                 return sourceFile;
87229             }
87230             return hostSourceFile.sourceFile;
87231         }
87232         function nextSourceFileVersion(path) {
87233             var hostSourceFile = sourceFilesCache.get(path);
87234             if (hostSourceFile !== undefined) {
87235                 if (isFileMissingOnHost(hostSourceFile)) {
87236                     sourceFilesCache.set(path, { version: false });
87237                 }
87238                 else {
87239                     hostSourceFile.version = false;
87240                 }
87241             }
87242         }
87243         function getSourceVersion(path) {
87244             var hostSourceFile = sourceFilesCache.get(path);
87245             return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version;
87246         }
87247         function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) {
87248             var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath);
87249             if (hostSourceFileInfo !== undefined) {
87250                 if (isFileMissingOnHost(hostSourceFileInfo)) {
87251                     (missingFilePathsRequestedForRelease || (missingFilePathsRequestedForRelease = [])).push(oldSourceFile.path);
87252                 }
87253                 else if (hostSourceFileInfo.sourceFile === oldSourceFile) {
87254                     if (hostSourceFileInfo.fileWatcher) {
87255                         hostSourceFileInfo.fileWatcher.close();
87256                     }
87257                     sourceFilesCache.delete(oldSourceFile.resolvedPath);
87258                     if (!hasSourceFileByPath) {
87259                         resolutionCache.removeResolutionsOfFile(oldSourceFile.path);
87260                     }
87261                 }
87262             }
87263         }
87264         function reportWatchDiagnostic(message) {
87265             if (host.onWatchStatusChange) {
87266                 host.onWatchStatusChange(ts.createCompilerDiagnostic(message), newLine, compilerOptions || optionsToExtendForConfigFile);
87267             }
87268         }
87269         function scheduleProgramUpdate() {
87270             if (!host.setTimeout || !host.clearTimeout) {
87271                 return;
87272             }
87273             if (timerToUpdateProgram) {
87274                 host.clearTimeout(timerToUpdateProgram);
87275             }
87276             writeLog("Scheduling update");
87277             timerToUpdateProgram = host.setTimeout(updateProgramWithWatchStatus, 250);
87278         }
87279         function scheduleProgramReload() {
87280             ts.Debug.assert(!!configFileName);
87281             reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
87282             scheduleProgramUpdate();
87283         }
87284         function updateProgramWithWatchStatus() {
87285             timerToUpdateProgram = undefined;
87286             reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
87287             updateProgram();
87288         }
87289         function updateProgram() {
87290             switch (reloadLevel) {
87291                 case ts.ConfigFileProgramReloadLevel.Partial:
87292                     ts.perfLogger.logStartUpdateProgram("PartialConfigReload");
87293                     reloadFileNamesFromConfigFile();
87294                     break;
87295                 case ts.ConfigFileProgramReloadLevel.Full:
87296                     ts.perfLogger.logStartUpdateProgram("FullConfigReload");
87297                     reloadConfigFile();
87298                     break;
87299                 default:
87300                     ts.perfLogger.logStartUpdateProgram("SynchronizeProgram");
87301                     synchronizeProgram();
87302                     break;
87303             }
87304             ts.perfLogger.logStopUpdateProgram("Done");
87305             return getCurrentBuilderProgram();
87306         }
87307         function reloadFileNamesFromConfigFile() {
87308             writeLog("Reloading new file names and options");
87309             var result = ts.getFileNamesFromConfigSpecs(configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost);
87310             if (ts.updateErrorForNoInputFiles(result, ts.getNormalizedAbsolutePath(configFileName, currentDirectory), configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) {
87311                 hasChangedConfigFileParsingErrors = true;
87312             }
87313             rootFileNames = result.fileNames;
87314             synchronizeProgram();
87315         }
87316         function reloadConfigFile() {
87317             writeLog("Reloading config file: " + configFileName);
87318             reloadLevel = ts.ConfigFileProgramReloadLevel.None;
87319             if (cachedDirectoryStructureHost) {
87320                 cachedDirectoryStructureHost.clearCache();
87321             }
87322             parseConfigFile();
87323             hasChangedCompilerOptions = true;
87324             synchronizeProgram();
87325             watchConfigFileWildCardDirectories();
87326         }
87327         function parseConfigFile() {
87328             setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost, undefined, watchOptionsToExtend, extraFileExtensions));
87329         }
87330         function setConfigFileParsingResult(configFileParseResult) {
87331             rootFileNames = configFileParseResult.fileNames;
87332             compilerOptions = configFileParseResult.options;
87333             watchOptions = configFileParseResult.watchOptions;
87334             configFileSpecs = configFileParseResult.configFileSpecs;
87335             projectReferences = configFileParseResult.projectReferences;
87336             configFileParsingDiagnostics = ts.getConfigFileParsingDiagnostics(configFileParseResult).slice();
87337             canConfigFileJsonReportNoInputFiles = ts.canJsonReportNoInutFiles(configFileParseResult.raw);
87338             hasChangedConfigFileParsingErrors = true;
87339         }
87340         function onSourceFileChange(fileName, eventKind, path) {
87341             updateCachedSystemWithFile(fileName, path, eventKind);
87342             if (eventKind === ts.FileWatcherEventKind.Deleted && sourceFilesCache.has(path)) {
87343                 resolutionCache.invalidateResolutionOfFile(path);
87344             }
87345             resolutionCache.removeResolutionsFromProjectReferenceRedirects(path);
87346             nextSourceFileVersion(path);
87347             scheduleProgramUpdate();
87348         }
87349         function updateCachedSystemWithFile(fileName, path, eventKind) {
87350             if (cachedDirectoryStructureHost) {
87351                 cachedDirectoryStructureHost.addOrDeleteFile(fileName, path, eventKind);
87352             }
87353         }
87354         function watchMissingFilePath(missingFilePath) {
87355             return watchFilePath(host, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, missingFilePath, ts.WatchType.MissingFile);
87356         }
87357         function onMissingFileChange(fileName, eventKind, missingFilePath) {
87358             updateCachedSystemWithFile(fileName, missingFilePath, eventKind);
87359             if (eventKind === ts.FileWatcherEventKind.Created && missingFilesMap.has(missingFilePath)) {
87360                 missingFilesMap.get(missingFilePath).close();
87361                 missingFilesMap.delete(missingFilePath);
87362                 nextSourceFileVersion(missingFilePath);
87363                 scheduleProgramUpdate();
87364             }
87365         }
87366         function watchConfigFileWildCardDirectories() {
87367             if (configFileSpecs) {
87368                 ts.updateWatchingWildcardDirectories(watchedWildcardDirectories || (watchedWildcardDirectories = ts.createMap()), ts.createMapFromTemplate(configFileSpecs.wildcardDirectories), watchWildcardDirectory);
87369             }
87370             else if (watchedWildcardDirectories) {
87371                 ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf);
87372             }
87373         }
87374         function watchWildcardDirectory(directory, flags) {
87375             return watchDirectory(host, directory, function (fileOrDirectory) {
87376                 ts.Debug.assert(!!configFileName);
87377                 var fileOrDirectoryPath = toPath(fileOrDirectory);
87378                 if (cachedDirectoryStructureHost) {
87379                     cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
87380                 }
87381                 nextSourceFileVersion(fileOrDirectoryPath);
87382                 fileOrDirectoryPath = ts.removeIgnoredPath(fileOrDirectoryPath);
87383                 if (!fileOrDirectoryPath)
87384                     return;
87385                 if (fileOrDirectoryPath !== directory && ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, compilerOptions)) {
87386                     writeLog("Project: " + configFileName + " Detected file add/remove of non supported extension: " + fileOrDirectory);
87387                     return;
87388                 }
87389                 if (reloadLevel !== ts.ConfigFileProgramReloadLevel.Full) {
87390                     reloadLevel = ts.ConfigFileProgramReloadLevel.Partial;
87391                     scheduleProgramUpdate();
87392                 }
87393             }, flags, watchOptions, ts.WatchType.WildcardDirectory);
87394         }
87395     }
87396     ts.createWatchProgram = createWatchProgram;
87397 })(ts || (ts = {}));
87398 var ts;
87399 (function (ts) {
87400     var UpToDateStatusType;
87401     (function (UpToDateStatusType) {
87402         UpToDateStatusType[UpToDateStatusType["Unbuildable"] = 0] = "Unbuildable";
87403         UpToDateStatusType[UpToDateStatusType["UpToDate"] = 1] = "UpToDate";
87404         UpToDateStatusType[UpToDateStatusType["UpToDateWithUpstreamTypes"] = 2] = "UpToDateWithUpstreamTypes";
87405         UpToDateStatusType[UpToDateStatusType["OutOfDateWithPrepend"] = 3] = "OutOfDateWithPrepend";
87406         UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing";
87407         UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf";
87408         UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream";
87409         UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 7] = "UpstreamOutOfDate";
87410         UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 8] = "UpstreamBlocked";
87411         UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 9] = "ComputingUpstream";
87412         UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 10] = "TsVersionOutputOfDate";
87413         UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 11] = "ContainerOnly";
87414     })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {}));
87415     function resolveConfigFileProjectName(project) {
87416         if (ts.fileExtensionIs(project, ".json")) {
87417             return project;
87418         }
87419         return ts.combinePaths(project, "tsconfig.json");
87420     }
87421     ts.resolveConfigFileProjectName = resolveConfigFileProjectName;
87422 })(ts || (ts = {}));
87423 var ts;
87424 (function (ts) {
87425     var minimumDate = new Date(-8640000000000000);
87426     var maximumDate = new Date(8640000000000000);
87427     var BuildResultFlags;
87428     (function (BuildResultFlags) {
87429         BuildResultFlags[BuildResultFlags["None"] = 0] = "None";
87430         BuildResultFlags[BuildResultFlags["Success"] = 1] = "Success";
87431         BuildResultFlags[BuildResultFlags["DeclarationOutputUnchanged"] = 2] = "DeclarationOutputUnchanged";
87432         BuildResultFlags[BuildResultFlags["ConfigFileErrors"] = 4] = "ConfigFileErrors";
87433         BuildResultFlags[BuildResultFlags["SyntaxErrors"] = 8] = "SyntaxErrors";
87434         BuildResultFlags[BuildResultFlags["TypeErrors"] = 16] = "TypeErrors";
87435         BuildResultFlags[BuildResultFlags["DeclarationEmitErrors"] = 32] = "DeclarationEmitErrors";
87436         BuildResultFlags[BuildResultFlags["EmitErrors"] = 64] = "EmitErrors";
87437         BuildResultFlags[BuildResultFlags["AnyErrors"] = 124] = "AnyErrors";
87438     })(BuildResultFlags || (BuildResultFlags = {}));
87439     function createConfigFileMap() {
87440         return ts.createMap();
87441     }
87442     function getOrCreateValueFromConfigFileMap(configFileMap, resolved, createT) {
87443         var existingValue = configFileMap.get(resolved);
87444         var newValue;
87445         if (!existingValue) {
87446             newValue = createT();
87447             configFileMap.set(resolved, newValue);
87448         }
87449         return existingValue || newValue;
87450     }
87451     function getOrCreateValueMapFromConfigFileMap(configFileMap, resolved) {
87452         return getOrCreateValueFromConfigFileMap(configFileMap, resolved, ts.createMap);
87453     }
87454     function newer(date1, date2) {
87455         return date2 > date1 ? date2 : date1;
87456     }
87457     function isDeclarationFile(fileName) {
87458         return ts.fileExtensionIs(fileName, ".d.ts");
87459     }
87460     function isCircularBuildOrder(buildOrder) {
87461         return !!buildOrder && !!buildOrder.buildOrder;
87462     }
87463     ts.isCircularBuildOrder = isCircularBuildOrder;
87464     function getBuildOrderFromAnyBuildOrder(anyBuildOrder) {
87465         return isCircularBuildOrder(anyBuildOrder) ? anyBuildOrder.buildOrder : anyBuildOrder;
87466     }
87467     ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder;
87468     function createBuilderStatusReporter(system, pretty) {
87469         return function (diagnostic) {
87470             var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - ";
87471             output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine);
87472             system.write(output);
87473         };
87474     }
87475     ts.createBuilderStatusReporter = createBuilderStatusReporter;
87476     function createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus) {
87477         var host = ts.createProgramHost(system, createProgram);
87478         host.getModifiedTime = system.getModifiedTime ? function (path) { return system.getModifiedTime(path); } : ts.returnUndefined;
87479         host.setModifiedTime = system.setModifiedTime ? function (path, date) { return system.setModifiedTime(path, date); } : ts.noop;
87480         host.deleteFile = system.deleteFile ? function (path) { return system.deleteFile(path); } : ts.noop;
87481         host.reportDiagnostic = reportDiagnostic || ts.createDiagnosticReporter(system);
87482         host.reportSolutionBuilderStatus = reportSolutionBuilderStatus || createBuilderStatusReporter(system);
87483         host.now = ts.maybeBind(system, system.now);
87484         return host;
87485     }
87486     function createSolutionBuilderHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportErrorSummary) {
87487         if (system === void 0) { system = ts.sys; }
87488         var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus);
87489         host.reportErrorSummary = reportErrorSummary;
87490         return host;
87491     }
87492     ts.createSolutionBuilderHost = createSolutionBuilderHost;
87493     function createSolutionBuilderWithWatchHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportWatchStatus) {
87494         if (system === void 0) { system = ts.sys; }
87495         var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus);
87496         var watchHost = ts.createWatchHost(system, reportWatchStatus);
87497         ts.copyProperties(host, watchHost);
87498         return host;
87499     }
87500     ts.createSolutionBuilderWithWatchHost = createSolutionBuilderWithWatchHost;
87501     function getCompilerOptionsOfBuildOptions(buildOptions) {
87502         var result = {};
87503         ts.commonOptionsWithBuild.forEach(function (option) {
87504             if (ts.hasProperty(buildOptions, option.name))
87505                 result[option.name] = buildOptions[option.name];
87506         });
87507         return result;
87508     }
87509     function createSolutionBuilder(host, rootNames, defaultOptions) {
87510         return createSolutionBuilderWorker(false, host, rootNames, defaultOptions);
87511     }
87512     ts.createSolutionBuilder = createSolutionBuilder;
87513     function createSolutionBuilderWithWatch(host, rootNames, defaultOptions, baseWatchOptions) {
87514         return createSolutionBuilderWorker(true, host, rootNames, defaultOptions, baseWatchOptions);
87515     }
87516     ts.createSolutionBuilderWithWatch = createSolutionBuilderWithWatch;
87517     function createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions) {
87518         var host = hostOrHostWithWatch;
87519         var hostWithWatch = hostOrHostWithWatch;
87520         var currentDirectory = host.getCurrentDirectory();
87521         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
87522         var baseCompilerOptions = getCompilerOptionsOfBuildOptions(options);
87523         var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return state.projectCompilerOptions; });
87524         ts.setGetSourceFileAsHashVersioned(compilerHost, host);
87525         compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); };
87526         compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames);
87527         compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives);
87528         var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
87529         if (!compilerHost.resolveModuleNames) {
87530             var loader_3 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule; };
87531             compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference) {
87532                 return ts.loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_3);
87533             };
87534         }
87535         var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchFilePath = _a.watchFilePath, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
87536         var state = {
87537             host: host,
87538             hostWithWatch: hostWithWatch,
87539             currentDirectory: currentDirectory,
87540             getCanonicalFileName: getCanonicalFileName,
87541             parseConfigFileHost: ts.parseConfigHostFromCompilerHostLike(host),
87542             writeFileName: host.trace ? function (s) { return host.trace(s); } : undefined,
87543             options: options,
87544             baseCompilerOptions: baseCompilerOptions,
87545             rootNames: rootNames,
87546             baseWatchOptions: baseWatchOptions,
87547             resolvedConfigFilePaths: ts.createMap(),
87548             configFileCache: createConfigFileMap(),
87549             projectStatus: createConfigFileMap(),
87550             buildInfoChecked: createConfigFileMap(),
87551             extendedConfigCache: ts.createMap(),
87552             builderPrograms: createConfigFileMap(),
87553             diagnostics: createConfigFileMap(),
87554             projectPendingBuild: createConfigFileMap(),
87555             projectErrorsReported: createConfigFileMap(),
87556             compilerHost: compilerHost,
87557             moduleResolutionCache: moduleResolutionCache,
87558             buildOrder: undefined,
87559             readFileWithCache: function (f) { return host.readFile(f); },
87560             projectCompilerOptions: baseCompilerOptions,
87561             cache: undefined,
87562             allProjectBuildPending: true,
87563             needsSummary: true,
87564             watchAllProjectsPending: watch,
87565             currentInvalidatedProject: undefined,
87566             watch: watch,
87567             allWatchedWildcardDirectories: createConfigFileMap(),
87568             allWatchedInputFiles: createConfigFileMap(),
87569             allWatchedConfigFiles: createConfigFileMap(),
87570             timerToBuildInvalidatedProject: undefined,
87571             reportFileChangeDetected: false,
87572             watchFile: watchFile,
87573             watchFilePath: watchFilePath,
87574             watchDirectory: watchDirectory,
87575             writeLog: writeLog,
87576         };
87577         return state;
87578     }
87579     function toPath(state, fileName) {
87580         return ts.toPath(fileName, state.currentDirectory, state.getCanonicalFileName);
87581     }
87582     function toResolvedConfigFilePath(state, fileName) {
87583         var resolvedConfigFilePaths = state.resolvedConfigFilePaths;
87584         var path = resolvedConfigFilePaths.get(fileName);
87585         if (path !== undefined)
87586             return path;
87587         var resolvedPath = toPath(state, fileName);
87588         resolvedConfigFilePaths.set(fileName, resolvedPath);
87589         return resolvedPath;
87590     }
87591     function isParsedCommandLine(entry) {
87592         return !!entry.options;
87593     }
87594     function parseConfigFile(state, configFileName, configFilePath) {
87595         var configFileCache = state.configFileCache;
87596         var value = configFileCache.get(configFilePath);
87597         if (value) {
87598             return isParsedCommandLine(value) ? value : undefined;
87599         }
87600         var diagnostic;
87601         var parseConfigFileHost = state.parseConfigFileHost, baseCompilerOptions = state.baseCompilerOptions, baseWatchOptions = state.baseWatchOptions, extendedConfigCache = state.extendedConfigCache, host = state.host;
87602         var parsed;
87603         if (host.getParsedCommandLine) {
87604             parsed = host.getParsedCommandLine(configFileName);
87605             if (!parsed)
87606                 diagnostic = ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, configFileName);
87607         }
87608         else {
87609             parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = function (d) { return diagnostic = d; };
87610             parsed = ts.getParsedCommandLineOfConfigFile(configFileName, baseCompilerOptions, parseConfigFileHost, extendedConfigCache, baseWatchOptions);
87611             parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = ts.noop;
87612         }
87613         configFileCache.set(configFilePath, parsed || diagnostic);
87614         return parsed;
87615     }
87616     function resolveProjectName(state, name) {
87617         return ts.resolveConfigFileProjectName(ts.resolvePath(state.currentDirectory, name));
87618     }
87619     function createBuildOrder(state, roots) {
87620         var temporaryMarks = ts.createMap();
87621         var permanentMarks = ts.createMap();
87622         var circularityReportStack = [];
87623         var buildOrder;
87624         var circularDiagnostics;
87625         for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) {
87626             var root = roots_1[_i];
87627             visit(root);
87628         }
87629         return circularDiagnostics ?
87630             { buildOrder: buildOrder || ts.emptyArray, circularDiagnostics: circularDiagnostics } :
87631             buildOrder || ts.emptyArray;
87632         function visit(configFileName, inCircularContext) {
87633             var projPath = toResolvedConfigFilePath(state, configFileName);
87634             if (permanentMarks.has(projPath))
87635                 return;
87636             if (temporaryMarks.has(projPath)) {
87637                 if (!inCircularContext) {
87638                     (circularDiagnostics || (circularDiagnostics = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n")));
87639                 }
87640                 return;
87641             }
87642             temporaryMarks.set(projPath, true);
87643             circularityReportStack.push(configFileName);
87644             var parsed = parseConfigFile(state, configFileName, projPath);
87645             if (parsed && parsed.projectReferences) {
87646                 for (var _i = 0, _a = parsed.projectReferences; _i < _a.length; _i++) {
87647                     var ref = _a[_i];
87648                     var resolvedRefPath = resolveProjectName(state, ref.path);
87649                     visit(resolvedRefPath, inCircularContext || ref.circular);
87650                 }
87651             }
87652             circularityReportStack.pop();
87653             permanentMarks.set(projPath, true);
87654             (buildOrder || (buildOrder = [])).push(configFileName);
87655         }
87656     }
87657     function getBuildOrder(state) {
87658         return state.buildOrder || createStateBuildOrder(state);
87659     }
87660     function createStateBuildOrder(state) {
87661         var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }));
87662         state.resolvedConfigFilePaths.clear();
87663         var currentProjects = ts.arrayToSet(getBuildOrderFromAnyBuildOrder(buildOrder), function (resolved) { return toResolvedConfigFilePath(state, resolved); });
87664         var noopOnDelete = { onDeleteValue: ts.noop };
87665         ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete);
87666         ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete);
87667         ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete);
87668         ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete);
87669         ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete);
87670         ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete);
87671         ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete);
87672         if (state.watch) {
87673             ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher });
87674             ts.mutateMapSkippingNewValues(state.allWatchedWildcardDirectories, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcherOf); } });
87675             ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } });
87676         }
87677         return state.buildOrder = buildOrder;
87678     }
87679     function getBuildOrderFor(state, project, onlyReferences) {
87680         var resolvedProject = project && resolveProjectName(state, project);
87681         var buildOrderFromState = getBuildOrder(state);
87682         if (isCircularBuildOrder(buildOrderFromState))
87683             return buildOrderFromState;
87684         if (resolvedProject) {
87685             var projectPath_1 = toResolvedConfigFilePath(state, resolvedProject);
87686             var projectIndex = ts.findIndex(buildOrderFromState, function (configFileName) { return toResolvedConfigFilePath(state, configFileName) === projectPath_1; });
87687             if (projectIndex === -1)
87688                 return undefined;
87689         }
87690         var buildOrder = resolvedProject ? createBuildOrder(state, [resolvedProject]) : buildOrderFromState;
87691         ts.Debug.assert(!isCircularBuildOrder(buildOrder));
87692         ts.Debug.assert(!onlyReferences || resolvedProject !== undefined);
87693         ts.Debug.assert(!onlyReferences || buildOrder[buildOrder.length - 1] === resolvedProject);
87694         return onlyReferences ? buildOrder.slice(0, buildOrder.length - 1) : buildOrder;
87695     }
87696     function enableCache(state) {
87697         if (state.cache) {
87698             disableCache(state);
87699         }
87700         var compilerHost = state.compilerHost, host = state.host;
87701         var originalReadFileWithCache = state.readFileWithCache;
87702         var originalGetSourceFile = compilerHost.getSourceFile;
87703         var _a = ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return toPath(state, fileName); }, function () {
87704             var args = [];
87705             for (var _i = 0; _i < arguments.length; _i++) {
87706                 args[_i] = arguments[_i];
87707             }
87708             return originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArrays([compilerHost], args));
87709         }), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, getSourceFileWithCache = _a.getSourceFileWithCache, readFileWithCache = _a.readFileWithCache;
87710         state.readFileWithCache = readFileWithCache;
87711         compilerHost.getSourceFile = getSourceFileWithCache;
87712         state.cache = {
87713             originalReadFile: originalReadFile,
87714             originalFileExists: originalFileExists,
87715             originalDirectoryExists: originalDirectoryExists,
87716             originalCreateDirectory: originalCreateDirectory,
87717             originalWriteFile: originalWriteFile,
87718             originalReadFileWithCache: originalReadFileWithCache,
87719             originalGetSourceFile: originalGetSourceFile,
87720         };
87721     }
87722     function disableCache(state) {
87723         if (!state.cache)
87724             return;
87725         var cache = state.cache, host = state.host, compilerHost = state.compilerHost, extendedConfigCache = state.extendedConfigCache, moduleResolutionCache = state.moduleResolutionCache;
87726         host.readFile = cache.originalReadFile;
87727         host.fileExists = cache.originalFileExists;
87728         host.directoryExists = cache.originalDirectoryExists;
87729         host.createDirectory = cache.originalCreateDirectory;
87730         host.writeFile = cache.originalWriteFile;
87731         compilerHost.getSourceFile = cache.originalGetSourceFile;
87732         state.readFileWithCache = cache.originalReadFileWithCache;
87733         extendedConfigCache.clear();
87734         if (moduleResolutionCache) {
87735             moduleResolutionCache.directoryToModuleNameMap.clear();
87736             moduleResolutionCache.moduleNameToDirectoryMap.clear();
87737         }
87738         state.cache = undefined;
87739     }
87740     function clearProjectStatus(state, resolved) {
87741         state.projectStatus.delete(resolved);
87742         state.diagnostics.delete(resolved);
87743     }
87744     function addProjToQueue(_a, proj, reloadLevel) {
87745         var projectPendingBuild = _a.projectPendingBuild;
87746         var value = projectPendingBuild.get(proj);
87747         if (value === undefined) {
87748             projectPendingBuild.set(proj, reloadLevel);
87749         }
87750         else if (value < reloadLevel) {
87751             projectPendingBuild.set(proj, reloadLevel);
87752         }
87753     }
87754     function setupInitialBuild(state, cancellationToken) {
87755         if (!state.allProjectBuildPending)
87756             return;
87757         state.allProjectBuildPending = false;
87758         if (state.options.watch) {
87759             reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode);
87760         }
87761         enableCache(state);
87762         var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state));
87763         buildOrder.forEach(function (configFileName) {
87764             return state.projectPendingBuild.set(toResolvedConfigFilePath(state, configFileName), ts.ConfigFileProgramReloadLevel.None);
87765         });
87766         if (cancellationToken) {
87767             cancellationToken.throwIfCancellationRequested();
87768         }
87769     }
87770     var InvalidatedProjectKind;
87771     (function (InvalidatedProjectKind) {
87772         InvalidatedProjectKind[InvalidatedProjectKind["Build"] = 0] = "Build";
87773         InvalidatedProjectKind[InvalidatedProjectKind["UpdateBundle"] = 1] = "UpdateBundle";
87774         InvalidatedProjectKind[InvalidatedProjectKind["UpdateOutputFileStamps"] = 2] = "UpdateOutputFileStamps";
87775     })(InvalidatedProjectKind = ts.InvalidatedProjectKind || (ts.InvalidatedProjectKind = {}));
87776     function doneInvalidatedProject(state, projectPath) {
87777         state.projectPendingBuild.delete(projectPath);
87778         state.currentInvalidatedProject = undefined;
87779         return state.diagnostics.has(projectPath) ?
87780             ts.ExitStatus.DiagnosticsPresent_OutputsSkipped :
87781             ts.ExitStatus.Success;
87782     }
87783     function createUpdateOutputFileStampsProject(state, project, projectPath, config, buildOrder) {
87784         var updateOutputFileStampsPending = true;
87785         return {
87786             kind: InvalidatedProjectKind.UpdateOutputFileStamps,
87787             project: project,
87788             projectPath: projectPath,
87789             buildOrder: buildOrder,
87790             getCompilerOptions: function () { return config.options; },
87791             getCurrentDirectory: function () { return state.currentDirectory; },
87792             updateOutputFileStatmps: function () {
87793                 updateOutputTimestamps(state, config, projectPath);
87794                 updateOutputFileStampsPending = false;
87795             },
87796             done: function () {
87797                 if (updateOutputFileStampsPending) {
87798                     updateOutputTimestamps(state, config, projectPath);
87799                 }
87800                 return doneInvalidatedProject(state, projectPath);
87801             }
87802         };
87803     }
87804     function createBuildOrUpdateInvalidedProject(kind, state, project, projectPath, projectIndex, config, buildOrder) {
87805         var Step;
87806         (function (Step) {
87807             Step[Step["CreateProgram"] = 0] = "CreateProgram";
87808             Step[Step["SyntaxDiagnostics"] = 1] = "SyntaxDiagnostics";
87809             Step[Step["SemanticDiagnostics"] = 2] = "SemanticDiagnostics";
87810             Step[Step["Emit"] = 3] = "Emit";
87811             Step[Step["EmitBundle"] = 4] = "EmitBundle";
87812             Step[Step["BuildInvalidatedProjectOfBundle"] = 5] = "BuildInvalidatedProjectOfBundle";
87813             Step[Step["QueueReferencingProjects"] = 6] = "QueueReferencingProjects";
87814             Step[Step["Done"] = 7] = "Done";
87815         })(Step || (Step = {}));
87816         var step = kind === InvalidatedProjectKind.Build ? Step.CreateProgram : Step.EmitBundle;
87817         var program;
87818         var buildResult;
87819         var invalidatedProjectOfBundle;
87820         return kind === InvalidatedProjectKind.Build ?
87821             {
87822                 kind: kind,
87823                 project: project,
87824                 projectPath: projectPath,
87825                 buildOrder: buildOrder,
87826                 getCompilerOptions: function () { return config.options; },
87827                 getCurrentDirectory: function () { return state.currentDirectory; },
87828                 getBuilderProgram: function () { return withProgramOrUndefined(ts.identity); },
87829                 getProgram: function () {
87830                     return withProgramOrUndefined(function (program) { return program.getProgramOrUndefined(); });
87831                 },
87832                 getSourceFile: function (fileName) {
87833                     return withProgramOrUndefined(function (program) { return program.getSourceFile(fileName); });
87834                 },
87835                 getSourceFiles: function () {
87836                     return withProgramOrEmptyArray(function (program) { return program.getSourceFiles(); });
87837                 },
87838                 getOptionsDiagnostics: function (cancellationToken) {
87839                     return withProgramOrEmptyArray(function (program) { return program.getOptionsDiagnostics(cancellationToken); });
87840                 },
87841                 getGlobalDiagnostics: function (cancellationToken) {
87842                     return withProgramOrEmptyArray(function (program) { return program.getGlobalDiagnostics(cancellationToken); });
87843                 },
87844                 getConfigFileParsingDiagnostics: function () {
87845                     return withProgramOrEmptyArray(function (program) { return program.getConfigFileParsingDiagnostics(); });
87846                 },
87847                 getSyntacticDiagnostics: function (sourceFile, cancellationToken) {
87848                     return withProgramOrEmptyArray(function (program) { return program.getSyntacticDiagnostics(sourceFile, cancellationToken); });
87849                 },
87850                 getAllDependencies: function (sourceFile) {
87851                     return withProgramOrEmptyArray(function (program) { return program.getAllDependencies(sourceFile); });
87852                 },
87853                 getSemanticDiagnostics: function (sourceFile, cancellationToken) {
87854                     return withProgramOrEmptyArray(function (program) { return program.getSemanticDiagnostics(sourceFile, cancellationToken); });
87855                 },
87856                 getSemanticDiagnosticsOfNextAffectedFile: function (cancellationToken, ignoreSourceFile) {
87857                     return withProgramOrUndefined(function (program) {
87858                         return (program.getSemanticDiagnosticsOfNextAffectedFile) &&
87859                             program.getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile);
87860                     });
87861                 },
87862                 emit: function (targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
87863                     if (targetSourceFile || emitOnlyDtsFiles) {
87864                         return withProgramOrUndefined(function (program) { return program.emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); });
87865                     }
87866                     executeSteps(Step.SemanticDiagnostics, cancellationToken);
87867                     if (step !== Step.Emit)
87868                         return undefined;
87869                     return emit(writeFile, cancellationToken, customTransformers);
87870                 },
87871                 done: done
87872             } :
87873             {
87874                 kind: kind,
87875                 project: project,
87876                 projectPath: projectPath,
87877                 buildOrder: buildOrder,
87878                 getCompilerOptions: function () { return config.options; },
87879                 getCurrentDirectory: function () { return state.currentDirectory; },
87880                 emit: function (writeFile, customTransformers) {
87881                     if (step !== Step.EmitBundle)
87882                         return invalidatedProjectOfBundle;
87883                     return emitBundle(writeFile, customTransformers);
87884                 },
87885                 done: done,
87886             };
87887         function done(cancellationToken, writeFile, customTransformers) {
87888             executeSteps(Step.Done, cancellationToken, writeFile, customTransformers);
87889             return doneInvalidatedProject(state, projectPath);
87890         }
87891         function withProgramOrUndefined(action) {
87892             executeSteps(Step.CreateProgram);
87893             return program && action(program);
87894         }
87895         function withProgramOrEmptyArray(action) {
87896             return withProgramOrUndefined(action) || ts.emptyArray;
87897         }
87898         function createProgram() {
87899             ts.Debug.assert(program === undefined);
87900             if (state.options.dry) {
87901                 reportStatus(state, ts.Diagnostics.A_non_dry_build_would_build_project_0, project);
87902                 buildResult = BuildResultFlags.Success;
87903                 step = Step.QueueReferencingProjects;
87904                 return;
87905             }
87906             if (state.options.verbose)
87907                 reportStatus(state, ts.Diagnostics.Building_project_0, project);
87908             if (config.fileNames.length === 0) {
87909                 reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
87910                 buildResult = BuildResultFlags.None;
87911                 step = Step.QueueReferencingProjects;
87912                 return;
87913             }
87914             var host = state.host, compilerHost = state.compilerHost;
87915             state.projectCompilerOptions = config.options;
87916             updateModuleResolutionCache(state, project, config);
87917             program = host.createProgram(config.fileNames, config.options, compilerHost, getOldProgram(state, projectPath, config), ts.getConfigFileParsingDiagnostics(config), config.projectReferences);
87918             step++;
87919         }
87920         function handleDiagnostics(diagnostics, errorFlags, errorType) {
87921             if (diagnostics.length) {
87922                 buildResult = buildErrors(state, projectPath, program, config, diagnostics, errorFlags, errorType);
87923                 step = Step.QueueReferencingProjects;
87924             }
87925             else {
87926                 step++;
87927             }
87928         }
87929         function getSyntaxDiagnostics(cancellationToken) {
87930             ts.Debug.assertIsDefined(program);
87931             handleDiagnostics(__spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic");
87932         }
87933         function getSemanticDiagnostics(cancellationToken) {
87934             handleDiagnostics(ts.Debug.checkDefined(program).getSemanticDiagnostics(undefined, cancellationToken), BuildResultFlags.TypeErrors, "Semantic");
87935         }
87936         function emit(writeFileCallback, cancellationToken, customTransformers) {
87937             ts.Debug.assertIsDefined(program);
87938             ts.Debug.assert(step === Step.Emit);
87939             program.backupState();
87940             var declDiagnostics;
87941             var reportDeclarationDiagnostics = function (d) { return (declDiagnostics || (declDiagnostics = [])).push(d); };
87942             var outputFiles = [];
87943             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;
87944             if (declDiagnostics) {
87945                 program.restoreState();
87946                 buildResult = buildErrors(state, projectPath, program, config, declDiagnostics, BuildResultFlags.DeclarationEmitErrors, "Declaration file");
87947                 step = Step.QueueReferencingProjects;
87948                 return {
87949                     emitSkipped: true,
87950                     diagnostics: emitResult.diagnostics
87951                 };
87952             }
87953             var host = state.host, compilerHost = state.compilerHost;
87954             var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
87955             var newestDeclarationFileContentChangedTime = minimumDate;
87956             var anyDtsChanged = false;
87957             var emitterDiagnostics = ts.createDiagnosticCollection();
87958             var emittedOutputs = ts.createMap();
87959             outputFiles.forEach(function (_a) {
87960                 var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
87961                 var priorChangeTime;
87962                 if (!anyDtsChanged && isDeclarationFile(name)) {
87963                     if (host.fileExists(name) && state.readFileWithCache(name) === text) {
87964                         priorChangeTime = host.getModifiedTime(name);
87965                     }
87966                     else {
87967                         resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
87968                         anyDtsChanged = true;
87969                     }
87970                 }
87971                 emittedOutputs.set(toPath(state, name), name);
87972                 ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
87973                 if (priorChangeTime !== undefined) {
87974                     newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime);
87975                 }
87976             });
87977             finishEmit(emitterDiagnostics, emittedOutputs, newestDeclarationFileContentChangedTime, anyDtsChanged, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
87978             return emitResult;
87979         }
87980         function finishEmit(emitterDiagnostics, emittedOutputs, priorNewestUpdateTime, newestDeclarationFileContentChangedTimeIsMaximumDate, oldestOutputFileName, resultFlags) {
87981             var emitDiagnostics = emitterDiagnostics.getDiagnostics();
87982             if (emitDiagnostics.length) {
87983                 buildResult = buildErrors(state, projectPath, program, config, emitDiagnostics, BuildResultFlags.EmitErrors, "Emit");
87984                 step = Step.QueueReferencingProjects;
87985                 return emitDiagnostics;
87986             }
87987             if (state.writeFileName) {
87988                 emittedOutputs.forEach(function (name) { return listEmittedFile(state, config, name); });
87989                 if (program)
87990                     ts.listFiles(program, state.writeFileName);
87991             }
87992             var newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(state, config, priorNewestUpdateTime, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
87993             state.diagnostics.delete(projectPath);
87994             state.projectStatus.set(projectPath, {
87995                 type: ts.UpToDateStatusType.UpToDate,
87996                 newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTimeIsMaximumDate ?
87997                     maximumDate :
87998                     newestDeclarationFileContentChangedTime,
87999                 oldestOutputFileName: oldestOutputFileName
88000             });
88001             afterProgramDone(state, projectPath, program, config);
88002             state.projectCompilerOptions = state.baseCompilerOptions;
88003             step = Step.QueueReferencingProjects;
88004             buildResult = resultFlags;
88005             return emitDiagnostics;
88006         }
88007         function emitBundle(writeFileCallback, customTransformers) {
88008             ts.Debug.assert(kind === InvalidatedProjectKind.UpdateBundle);
88009             if (state.options.dry) {
88010                 reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_output_of_project_0, project);
88011                 buildResult = BuildResultFlags.Success;
88012                 step = Step.QueueReferencingProjects;
88013                 return undefined;
88014             }
88015             if (state.options.verbose)
88016                 reportStatus(state, ts.Diagnostics.Updating_output_of_project_0, project);
88017             var compilerHost = state.compilerHost;
88018             state.projectCompilerOptions = config.options;
88019             var outputFiles = ts.emitUsingBuildInfo(config, compilerHost, function (ref) {
88020                 var refName = resolveProjectName(state, ref.path);
88021                 return parseConfigFile(state, refName, toResolvedConfigFilePath(state, refName));
88022             }, customTransformers);
88023             if (ts.isString(outputFiles)) {
88024                 reportStatus(state, ts.Diagnostics.Cannot_update_output_of_project_0_because_there_was_error_reading_file_1, project, relName(state, outputFiles));
88025                 step = Step.BuildInvalidatedProjectOfBundle;
88026                 return invalidatedProjectOfBundle = createBuildOrUpdateInvalidedProject(InvalidatedProjectKind.Build, state, project, projectPath, projectIndex, config, buildOrder);
88027             }
88028             ts.Debug.assert(!!outputFiles.length);
88029             var emitterDiagnostics = ts.createDiagnosticCollection();
88030             var emittedOutputs = ts.createMap();
88031             outputFiles.forEach(function (_a) {
88032                 var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
88033                 emittedOutputs.set(toPath(state, name), name);
88034                 ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
88035             });
88036             var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, minimumDate, false, outputFiles[0].name, BuildResultFlags.DeclarationOutputUnchanged);
88037             return { emitSkipped: false, diagnostics: emitDiagnostics };
88038         }
88039         function executeSteps(till, cancellationToken, writeFile, customTransformers) {
88040             while (step <= till && step < Step.Done) {
88041                 var currentStep = step;
88042                 switch (step) {
88043                     case Step.CreateProgram:
88044                         createProgram();
88045                         break;
88046                     case Step.SyntaxDiagnostics:
88047                         getSyntaxDiagnostics(cancellationToken);
88048                         break;
88049                     case Step.SemanticDiagnostics:
88050                         getSemanticDiagnostics(cancellationToken);
88051                         break;
88052                     case Step.Emit:
88053                         emit(writeFile, cancellationToken, customTransformers);
88054                         break;
88055                     case Step.EmitBundle:
88056                         emitBundle(writeFile, customTransformers);
88057                         break;
88058                     case Step.BuildInvalidatedProjectOfBundle:
88059                         ts.Debug.checkDefined(invalidatedProjectOfBundle).done(cancellationToken);
88060                         step = Step.Done;
88061                         break;
88062                     case Step.QueueReferencingProjects:
88063                         queueReferencingProjects(state, project, projectPath, projectIndex, config, buildOrder, ts.Debug.checkDefined(buildResult));
88064                         step++;
88065                         break;
88066                     case Step.Done:
88067                     default:
88068                         ts.assertType(step);
88069                 }
88070                 ts.Debug.assert(step > currentStep);
88071             }
88072         }
88073     }
88074     function needsBuild(_a, status, config) {
88075         var options = _a.options;
88076         if (status.type !== ts.UpToDateStatusType.OutOfDateWithPrepend || options.force)
88077             return true;
88078         return config.fileNames.length === 0 ||
88079             !!ts.getConfigFileParsingDiagnostics(config).length ||
88080             !ts.isIncrementalCompilation(config.options);
88081     }
88082     function getNextInvalidatedProject(state, buildOrder, reportQueue) {
88083         if (!state.projectPendingBuild.size)
88084             return undefined;
88085         if (isCircularBuildOrder(buildOrder))
88086             return undefined;
88087         if (state.currentInvalidatedProject) {
88088             return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ?
88089                 state.currentInvalidatedProject :
88090                 undefined;
88091         }
88092         var options = state.options, projectPendingBuild = state.projectPendingBuild;
88093         for (var projectIndex = 0; projectIndex < buildOrder.length; projectIndex++) {
88094             var project = buildOrder[projectIndex];
88095             var projectPath = toResolvedConfigFilePath(state, project);
88096             var reloadLevel = state.projectPendingBuild.get(projectPath);
88097             if (reloadLevel === undefined)
88098                 continue;
88099             if (reportQueue) {
88100                 reportQueue = false;
88101                 reportBuildQueue(state, buildOrder);
88102             }
88103             var config = parseConfigFile(state, project, projectPath);
88104             if (!config) {
88105                 reportParseConfigFileDiagnostic(state, projectPath);
88106                 projectPendingBuild.delete(projectPath);
88107                 continue;
88108             }
88109             if (reloadLevel === ts.ConfigFileProgramReloadLevel.Full) {
88110                 watchConfigFile(state, project, projectPath, config);
88111                 watchWildCardDirectories(state, project, projectPath, config);
88112                 watchInputFiles(state, project, projectPath, config);
88113             }
88114             else if (reloadLevel === ts.ConfigFileProgramReloadLevel.Partial) {
88115                 var result = ts.getFileNamesFromConfigSpecs(config.configFileSpecs, ts.getDirectoryPath(project), config.options, state.parseConfigFileHost);
88116                 ts.updateErrorForNoInputFiles(result, project, config.configFileSpecs, config.errors, ts.canJsonReportNoInutFiles(config.raw));
88117                 config.fileNames = result.fileNames;
88118                 watchInputFiles(state, project, projectPath, config);
88119             }
88120             var status = getUpToDateStatus(state, config, projectPath);
88121             verboseReportProjectStatus(state, project, status);
88122             if (!options.force) {
88123                 if (status.type === ts.UpToDateStatusType.UpToDate) {
88124                     reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
88125                     projectPendingBuild.delete(projectPath);
88126                     if (options.dry) {
88127                         reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date, project);
88128                     }
88129                     continue;
88130                 }
88131                 if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes) {
88132                     reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
88133                     return createUpdateOutputFileStampsProject(state, project, projectPath, config, buildOrder);
88134                 }
88135             }
88136             if (status.type === ts.UpToDateStatusType.UpstreamBlocked) {
88137                 reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
88138                 projectPendingBuild.delete(projectPath);
88139                 if (options.verbose) {
88140                     reportStatus(state, status.upstreamProjectBlocked ?
88141                         ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built :
88142                         ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName);
88143                 }
88144                 continue;
88145             }
88146             if (status.type === ts.UpToDateStatusType.ContainerOnly) {
88147                 reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
88148                 projectPendingBuild.delete(projectPath);
88149                 continue;
88150             }
88151             return createBuildOrUpdateInvalidedProject(needsBuild(state, status, config) ?
88152                 InvalidatedProjectKind.Build :
88153                 InvalidatedProjectKind.UpdateBundle, state, project, projectPath, projectIndex, config, buildOrder);
88154         }
88155         return undefined;
88156     }
88157     function listEmittedFile(_a, proj, file) {
88158         var writeFileName = _a.writeFileName;
88159         if (writeFileName && proj.options.listEmittedFiles) {
88160             writeFileName("TSFILE: " + file);
88161         }
88162     }
88163     function getOldProgram(_a, proj, parsed) {
88164         var options = _a.options, builderPrograms = _a.builderPrograms, compilerHost = _a.compilerHost;
88165         if (options.force)
88166             return undefined;
88167         var value = builderPrograms.get(proj);
88168         if (value)
88169             return value;
88170         return ts.readBuilderProgram(parsed.options, compilerHost);
88171     }
88172     function afterProgramDone(_a, proj, program, config) {
88173         var host = _a.host, watch = _a.watch, builderPrograms = _a.builderPrograms;
88174         if (program) {
88175             if (host.afterProgramEmitAndDiagnostics) {
88176                 host.afterProgramEmitAndDiagnostics(program);
88177             }
88178             if (watch) {
88179                 program.releaseProgram();
88180                 builderPrograms.set(proj, program);
88181             }
88182         }
88183         else if (host.afterEmitBundle) {
88184             host.afterEmitBundle(config);
88185         }
88186     }
88187     function buildErrors(state, resolvedPath, program, config, diagnostics, errorFlags, errorType) {
88188         reportAndStoreErrors(state, resolvedPath, diagnostics);
88189         if (program && state.writeFileName)
88190             ts.listFiles(program, state.writeFileName);
88191         state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" });
88192         afterProgramDone(state, resolvedPath, program, config);
88193         state.projectCompilerOptions = state.baseCompilerOptions;
88194         return errorFlags;
88195     }
88196     function updateModuleResolutionCache(state, proj, config) {
88197         if (!state.moduleResolutionCache)
88198             return;
88199         var moduleResolutionCache = state.moduleResolutionCache;
88200         var projPath = toPath(state, proj);
88201         if (moduleResolutionCache.directoryToModuleNameMap.redirectsMap.size === 0) {
88202             ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size === 0);
88203             moduleResolutionCache.directoryToModuleNameMap.redirectsMap.set(projPath, moduleResolutionCache.directoryToModuleNameMap.ownMap);
88204             moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.set(projPath, moduleResolutionCache.moduleNameToDirectoryMap.ownMap);
88205         }
88206         else {
88207             ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size > 0);
88208             var ref = {
88209                 sourceFile: config.options.configFile,
88210                 commandLine: config
88211             };
88212             moduleResolutionCache.directoryToModuleNameMap.setOwnMap(moduleResolutionCache.directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref));
88213             moduleResolutionCache.moduleNameToDirectoryMap.setOwnMap(moduleResolutionCache.moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref));
88214         }
88215         moduleResolutionCache.directoryToModuleNameMap.setOwnOptions(config.options);
88216         moduleResolutionCache.moduleNameToDirectoryMap.setOwnOptions(config.options);
88217     }
88218     function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName) {
88219         var tsconfigTime = state.host.getModifiedTime(configFile) || ts.missingFileModifiedTime;
88220         if (oldestOutputFileTime < tsconfigTime) {
88221             return {
88222                 type: ts.UpToDateStatusType.OutOfDateWithSelf,
88223                 outOfDateOutputFileName: oldestOutputFileName,
88224                 newerInputFileName: configFile
88225             };
88226         }
88227     }
88228     function getUpToDateStatusWorker(state, project, resolvedPath) {
88229         var newestInputFileName = undefined;
88230         var newestInputFileTime = minimumDate;
88231         var host = state.host;
88232         for (var _i = 0, _a = project.fileNames; _i < _a.length; _i++) {
88233             var inputFile = _a[_i];
88234             if (!host.fileExists(inputFile)) {
88235                 return {
88236                     type: ts.UpToDateStatusType.Unbuildable,
88237                     reason: inputFile + " does not exist"
88238                 };
88239             }
88240             var inputTime = host.getModifiedTime(inputFile) || ts.missingFileModifiedTime;
88241             if (inputTime > newestInputFileTime) {
88242                 newestInputFileName = inputFile;
88243                 newestInputFileTime = inputTime;
88244             }
88245         }
88246         if (!project.fileNames.length && !ts.canJsonReportNoInutFiles(project.raw)) {
88247             return {
88248                 type: ts.UpToDateStatusType.ContainerOnly
88249             };
88250         }
88251         var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
88252         var oldestOutputFileName = "(none)";
88253         var oldestOutputFileTime = maximumDate;
88254         var newestOutputFileName = "(none)";
88255         var newestOutputFileTime = minimumDate;
88256         var missingOutputFileName;
88257         var newestDeclarationFileContentChangedTime = minimumDate;
88258         var isOutOfDateWithInputs = false;
88259         for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) {
88260             var output = outputs_1[_b];
88261             if (!host.fileExists(output)) {
88262                 missingOutputFileName = output;
88263                 break;
88264             }
88265             var outputTime = host.getModifiedTime(output) || ts.missingFileModifiedTime;
88266             if (outputTime < oldestOutputFileTime) {
88267                 oldestOutputFileTime = outputTime;
88268                 oldestOutputFileName = output;
88269             }
88270             if (outputTime < newestInputFileTime) {
88271                 isOutOfDateWithInputs = true;
88272                 break;
88273             }
88274             if (outputTime > newestOutputFileTime) {
88275                 newestOutputFileTime = outputTime;
88276                 newestOutputFileName = output;
88277             }
88278             if (isDeclarationFile(output)) {
88279                 var outputModifiedTime = host.getModifiedTime(output) || ts.missingFileModifiedTime;
88280                 newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
88281             }
88282         }
88283         var pseudoUpToDate = false;
88284         var usesPrepend = false;
88285         var upstreamChangedProject;
88286         if (project.projectReferences) {
88287             state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream });
88288             for (var _c = 0, _d = project.projectReferences; _c < _d.length; _c++) {
88289                 var ref = _d[_c];
88290                 usesPrepend = usesPrepend || !!(ref.prepend);
88291                 var resolvedRef = ts.resolveProjectReferencePath(ref);
88292                 var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef);
88293                 var refStatus = getUpToDateStatus(state, parseConfigFile(state, resolvedRef, resolvedRefPath), resolvedRefPath);
88294                 if (refStatus.type === ts.UpToDateStatusType.ComputingUpstream ||
88295                     refStatus.type === ts.UpToDateStatusType.ContainerOnly) {
88296                     continue;
88297                 }
88298                 if (refStatus.type === ts.UpToDateStatusType.Unbuildable ||
88299                     refStatus.type === ts.UpToDateStatusType.UpstreamBlocked) {
88300                     return {
88301                         type: ts.UpToDateStatusType.UpstreamBlocked,
88302                         upstreamProjectName: ref.path,
88303                         upstreamProjectBlocked: refStatus.type === ts.UpToDateStatusType.UpstreamBlocked
88304                     };
88305                 }
88306                 if (refStatus.type !== ts.UpToDateStatusType.UpToDate) {
88307                     return {
88308                         type: ts.UpToDateStatusType.UpstreamOutOfDate,
88309                         upstreamProjectName: ref.path
88310                     };
88311                 }
88312                 if (!missingOutputFileName) {
88313                     if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
88314                         continue;
88315                     }
88316                     if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
88317                         pseudoUpToDate = true;
88318                         upstreamChangedProject = ref.path;
88319                         continue;
88320                     }
88321                     ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here");
88322                     return {
88323                         type: ts.UpToDateStatusType.OutOfDateWithUpstream,
88324                         outOfDateOutputFileName: oldestOutputFileName,
88325                         newerProjectName: ref.path
88326                     };
88327                 }
88328             }
88329         }
88330         if (missingOutputFileName !== undefined) {
88331             return {
88332                 type: ts.UpToDateStatusType.OutputMissing,
88333                 missingOutputFileName: missingOutputFileName
88334             };
88335         }
88336         if (isOutOfDateWithInputs) {
88337             return {
88338                 type: ts.UpToDateStatusType.OutOfDateWithSelf,
88339                 outOfDateOutputFileName: oldestOutputFileName,
88340                 newerInputFileName: newestInputFileName
88341             };
88342         }
88343         else {
88344             var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
88345             if (configStatus)
88346                 return configStatus;
88347             var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
88348             if (extendedConfigStatus)
88349                 return extendedConfigStatus;
88350         }
88351         if (!state.buildInfoChecked.has(resolvedPath)) {
88352             state.buildInfoChecked.set(resolvedPath, true);
88353             var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
88354             if (buildInfoPath) {
88355                 var value = state.readFileWithCache(buildInfoPath);
88356                 var buildInfo = value && ts.getBuildInfo(value);
88357                 if (buildInfo && (buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
88358                     return {
88359                         type: ts.UpToDateStatusType.TsVersionOutputOfDate,
88360                         version: buildInfo.version
88361                     };
88362                 }
88363             }
88364         }
88365         if (usesPrepend && pseudoUpToDate) {
88366             return {
88367                 type: ts.UpToDateStatusType.OutOfDateWithPrepend,
88368                 outOfDateOutputFileName: oldestOutputFileName,
88369                 newerProjectName: upstreamChangedProject
88370             };
88371         }
88372         return {
88373             type: pseudoUpToDate ? ts.UpToDateStatusType.UpToDateWithUpstreamTypes : ts.UpToDateStatusType.UpToDate,
88374             newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime,
88375             newestInputFileTime: newestInputFileTime,
88376             newestOutputFileTime: newestOutputFileTime,
88377             newestInputFileName: newestInputFileName,
88378             newestOutputFileName: newestOutputFileName,
88379             oldestOutputFileName: oldestOutputFileName
88380         };
88381     }
88382     function getUpToDateStatus(state, project, resolvedPath) {
88383         if (project === undefined) {
88384             return { type: ts.UpToDateStatusType.Unbuildable, reason: "File deleted mid-build" };
88385         }
88386         var prior = state.projectStatus.get(resolvedPath);
88387         if (prior !== undefined) {
88388             return prior;
88389         }
88390         var actual = getUpToDateStatusWorker(state, project, resolvedPath);
88391         state.projectStatus.set(resolvedPath, actual);
88392         return actual;
88393     }
88394     function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) {
88395         var host = state.host;
88396         var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
88397         if (!skipOutputs || outputs.length !== skipOutputs.size) {
88398             var reportVerbose = !!state.options.verbose;
88399             var now = host.now ? host.now() : new Date();
88400             for (var _i = 0, outputs_2 = outputs; _i < outputs_2.length; _i++) {
88401                 var file = outputs_2[_i];
88402                 if (skipOutputs && skipOutputs.has(toPath(state, file))) {
88403                     continue;
88404                 }
88405                 if (reportVerbose) {
88406                     reportVerbose = false;
88407                     reportStatus(state, verboseMessage, proj.options.configFilePath);
88408                 }
88409                 if (isDeclarationFile(file)) {
88410                     priorNewestUpdateTime = newer(priorNewestUpdateTime, host.getModifiedTime(file) || ts.missingFileModifiedTime);
88411                 }
88412                 host.setModifiedTime(file, now);
88413             }
88414         }
88415         return priorNewestUpdateTime;
88416     }
88417     function updateOutputTimestamps(state, proj, resolvedPath) {
88418         if (state.options.dry) {
88419             return reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath);
88420         }
88421         var priorNewestUpdateTime = updateOutputTimestampsWorker(state, proj, minimumDate, ts.Diagnostics.Updating_output_timestamps_of_project_0);
88422         state.projectStatus.set(resolvedPath, {
88423             type: ts.UpToDateStatusType.UpToDate,
88424             newestDeclarationFileContentChangedTime: priorNewestUpdateTime,
88425             oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames())
88426         });
88427     }
88428     function queueReferencingProjects(state, project, projectPath, projectIndex, config, buildOrder, buildResult) {
88429         if (buildResult & BuildResultFlags.AnyErrors)
88430             return;
88431         if (!config.options.composite)
88432             return;
88433         for (var index = projectIndex + 1; index < buildOrder.length; index++) {
88434             var nextProject = buildOrder[index];
88435             var nextProjectPath = toResolvedConfigFilePath(state, nextProject);
88436             if (state.projectPendingBuild.has(nextProjectPath))
88437                 continue;
88438             var nextProjectConfig = parseConfigFile(state, nextProject, nextProjectPath);
88439             if (!nextProjectConfig || !nextProjectConfig.projectReferences)
88440                 continue;
88441             for (var _i = 0, _a = nextProjectConfig.projectReferences; _i < _a.length; _i++) {
88442                 var ref = _a[_i];
88443                 var resolvedRefPath = resolveProjectName(state, ref.path);
88444                 if (toResolvedConfigFilePath(state, resolvedRefPath) !== projectPath)
88445                     continue;
88446                 var status = state.projectStatus.get(nextProjectPath);
88447                 if (status) {
88448                     switch (status.type) {
88449                         case ts.UpToDateStatusType.UpToDate:
88450                             if (buildResult & BuildResultFlags.DeclarationOutputUnchanged) {
88451                                 if (ref.prepend) {
88452                                     state.projectStatus.set(nextProjectPath, {
88453                                         type: ts.UpToDateStatusType.OutOfDateWithPrepend,
88454                                         outOfDateOutputFileName: status.oldestOutputFileName,
88455                                         newerProjectName: project
88456                                     });
88457                                 }
88458                                 else {
88459                                     status.type = ts.UpToDateStatusType.UpToDateWithUpstreamTypes;
88460                                 }
88461                                 break;
88462                             }
88463                         case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
88464                         case ts.UpToDateStatusType.OutOfDateWithPrepend:
88465                             if (!(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) {
88466                                 state.projectStatus.set(nextProjectPath, {
88467                                     type: ts.UpToDateStatusType.OutOfDateWithUpstream,
88468                                     outOfDateOutputFileName: status.type === ts.UpToDateStatusType.OutOfDateWithPrepend ? status.outOfDateOutputFileName : status.oldestOutputFileName,
88469                                     newerProjectName: project
88470                                 });
88471                             }
88472                             break;
88473                         case ts.UpToDateStatusType.UpstreamBlocked:
88474                             if (toResolvedConfigFilePath(state, resolveProjectName(state, status.upstreamProjectName)) === projectPath) {
88475                                 clearProjectStatus(state, nextProjectPath);
88476                             }
88477                             break;
88478                     }
88479                 }
88480                 addProjToQueue(state, nextProjectPath, ts.ConfigFileProgramReloadLevel.None);
88481                 break;
88482             }
88483         }
88484     }
88485     function build(state, project, cancellationToken, onlyReferences) {
88486         var buildOrder = getBuildOrderFor(state, project, onlyReferences);
88487         if (!buildOrder)
88488             return ts.ExitStatus.InvalidProject_OutputsSkipped;
88489         setupInitialBuild(state, cancellationToken);
88490         var reportQueue = true;
88491         var successfulProjects = 0;
88492         while (true) {
88493             var invalidatedProject = getNextInvalidatedProject(state, buildOrder, reportQueue);
88494             if (!invalidatedProject)
88495                 break;
88496             reportQueue = false;
88497             invalidatedProject.done(cancellationToken);
88498             if (!state.diagnostics.has(invalidatedProject.projectPath))
88499                 successfulProjects++;
88500         }
88501         disableCache(state);
88502         reportErrorSummary(state, buildOrder);
88503         startWatching(state, buildOrder);
88504         return isCircularBuildOrder(buildOrder)
88505             ? ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped
88506             : !buildOrder.some(function (p) { return state.diagnostics.has(toResolvedConfigFilePath(state, p)); })
88507                 ? ts.ExitStatus.Success
88508                 : successfulProjects
88509                     ? ts.ExitStatus.DiagnosticsPresent_OutputsGenerated
88510                     : ts.ExitStatus.DiagnosticsPresent_OutputsSkipped;
88511     }
88512     function clean(state, project, onlyReferences) {
88513         var buildOrder = getBuildOrderFor(state, project, onlyReferences);
88514         if (!buildOrder)
88515             return ts.ExitStatus.InvalidProject_OutputsSkipped;
88516         if (isCircularBuildOrder(buildOrder)) {
88517             reportErrors(state, buildOrder.circularDiagnostics);
88518             return ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped;
88519         }
88520         var options = state.options, host = state.host;
88521         var filesToDelete = options.dry ? [] : undefined;
88522         for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) {
88523             var proj = buildOrder_1[_i];
88524             var resolvedPath = toResolvedConfigFilePath(state, proj);
88525             var parsed = parseConfigFile(state, proj, resolvedPath);
88526             if (parsed === undefined) {
88527                 reportParseConfigFileDiagnostic(state, resolvedPath);
88528                 continue;
88529             }
88530             var outputs = ts.getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames());
88531             for (var _a = 0, outputs_3 = outputs; _a < outputs_3.length; _a++) {
88532                 var output = outputs_3[_a];
88533                 if (host.fileExists(output)) {
88534                     if (filesToDelete) {
88535                         filesToDelete.push(output);
88536                     }
88537                     else {
88538                         host.deleteFile(output);
88539                         invalidateProject(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None);
88540                     }
88541                 }
88542             }
88543         }
88544         if (filesToDelete) {
88545             reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * " + f; }).join(""));
88546         }
88547         return ts.ExitStatus.Success;
88548     }
88549     function invalidateProject(state, resolved, reloadLevel) {
88550         if (state.host.getParsedCommandLine && reloadLevel === ts.ConfigFileProgramReloadLevel.Partial) {
88551             reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
88552         }
88553         if (reloadLevel === ts.ConfigFileProgramReloadLevel.Full) {
88554             state.configFileCache.delete(resolved);
88555             state.buildOrder = undefined;
88556         }
88557         state.needsSummary = true;
88558         clearProjectStatus(state, resolved);
88559         addProjToQueue(state, resolved, reloadLevel);
88560         enableCache(state);
88561     }
88562     function invalidateProjectAndScheduleBuilds(state, resolvedPath, reloadLevel) {
88563         state.reportFileChangeDetected = true;
88564         invalidateProject(state, resolvedPath, reloadLevel);
88565         scheduleBuildInvalidatedProject(state);
88566     }
88567     function scheduleBuildInvalidatedProject(state) {
88568         var hostWithWatch = state.hostWithWatch;
88569         if (!hostWithWatch.setTimeout || !hostWithWatch.clearTimeout) {
88570             return;
88571         }
88572         if (state.timerToBuildInvalidatedProject) {
88573             hostWithWatch.clearTimeout(state.timerToBuildInvalidatedProject);
88574         }
88575         state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject, 250, state);
88576     }
88577     function buildNextInvalidatedProject(state) {
88578         state.timerToBuildInvalidatedProject = undefined;
88579         if (state.reportFileChangeDetected) {
88580             state.reportFileChangeDetected = false;
88581             state.projectErrorsReported.clear();
88582             reportWatchStatus(state, ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
88583         }
88584         var buildOrder = getBuildOrder(state);
88585         var invalidatedProject = getNextInvalidatedProject(state, buildOrder, false);
88586         if (invalidatedProject) {
88587             invalidatedProject.done();
88588             if (state.projectPendingBuild.size) {
88589                 if (state.watch && !state.timerToBuildInvalidatedProject) {
88590                     scheduleBuildInvalidatedProject(state);
88591                 }
88592                 return;
88593             }
88594         }
88595         disableCache(state);
88596         reportErrorSummary(state, buildOrder);
88597     }
88598     function watchConfigFile(state, resolved, resolvedPath, parsed) {
88599         if (!state.watch || state.allWatchedConfigFiles.has(resolvedPath))
88600             return;
88601         state.allWatchedConfigFiles.set(resolvedPath, state.watchFile(state.hostWithWatch, resolved, function () {
88602             invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full);
88603         }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ConfigFile, resolved));
88604     }
88605     function isSameFile(state, file1, file2) {
88606         return ts.comparePaths(file1, file2, state.currentDirectory, !state.host.useCaseSensitiveFileNames()) === 0;
88607     }
88608     function isOutputFile(state, fileName, configFile) {
88609         if (configFile.options.noEmit)
88610             return false;
88611         if (!ts.fileExtensionIs(fileName, ".d.ts") &&
88612             (ts.fileExtensionIs(fileName, ".ts") || ts.fileExtensionIs(fileName, ".tsx"))) {
88613             return false;
88614         }
88615         var out = configFile.options.outFile || configFile.options.out;
88616         if (out && (isSameFile(state, fileName, out) || isSameFile(state, fileName, ts.removeFileExtension(out) + ".d.ts"))) {
88617             return true;
88618         }
88619         if (configFile.options.declarationDir && ts.containsPath(configFile.options.declarationDir, fileName, state.currentDirectory, !state.host.useCaseSensitiveFileNames())) {
88620             return true;
88621         }
88622         if (configFile.options.outDir && ts.containsPath(configFile.options.outDir, fileName, state.currentDirectory, !state.host.useCaseSensitiveFileNames())) {
88623             return true;
88624         }
88625         return !ts.forEach(configFile.fileNames, function (inputFile) { return isSameFile(state, fileName, inputFile); });
88626     }
88627     function watchWildCardDirectories(state, resolved, resolvedPath, parsed) {
88628         if (!state.watch)
88629             return;
88630         ts.updateWatchingWildcardDirectories(getOrCreateValueMapFromConfigFileMap(state.allWatchedWildcardDirectories, resolvedPath), ts.createMapFromTemplate(parsed.configFileSpecs.wildcardDirectories), function (dir, flags) { return state.watchDirectory(state.hostWithWatch, dir, function (fileOrDirectory) {
88631             var fileOrDirectoryPath = toPath(state, fileOrDirectory);
88632             if (fileOrDirectoryPath !== toPath(state, dir) && ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, parsed.options)) {
88633                 state.writeLog("Project: " + resolved + " Detected file add/remove of non supported extension: " + fileOrDirectory);
88634                 return;
88635             }
88636             if (isOutputFile(state, fileOrDirectory, parsed)) {
88637                 state.writeLog(fileOrDirectory + " is output file");
88638                 return;
88639             }
88640             invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Partial);
88641         }, flags, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.WildcardDirectory, resolved); });
88642     }
88643     function watchInputFiles(state, resolved, resolvedPath, parsed) {
88644         if (!state.watch)
88645             return;
88646         ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedInputFiles, resolvedPath), ts.arrayToMap(parsed.fileNames, function (fileName) { return toPath(state, fileName); }), {
88647             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); },
88648             onDeleteValue: ts.closeFileWatcher,
88649         });
88650     }
88651     function startWatching(state, buildOrder) {
88652         if (!state.watchAllProjectsPending)
88653             return;
88654         state.watchAllProjectsPending = false;
88655         for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) {
88656             var resolved = _a[_i];
88657             var resolvedPath = toResolvedConfigFilePath(state, resolved);
88658             var cfg = parseConfigFile(state, resolved, resolvedPath);
88659             watchConfigFile(state, resolved, resolvedPath, cfg);
88660             if (cfg) {
88661                 watchWildCardDirectories(state, resolved, resolvedPath, cfg);
88662                 watchInputFiles(state, resolved, resolvedPath, cfg);
88663             }
88664         }
88665     }
88666     function stopWatching(state) {
88667         ts.clearMap(state.allWatchedConfigFiles, ts.closeFileWatcher);
88668         ts.clearMap(state.allWatchedWildcardDirectories, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf); });
88669         ts.clearMap(state.allWatchedInputFiles, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcher); });
88670     }
88671     function createSolutionBuilderWorker(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions) {
88672         var state = createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions);
88673         return {
88674             build: function (project, cancellationToken) { return build(state, project, cancellationToken); },
88675             clean: function (project) { return clean(state, project); },
88676             buildReferences: function (project, cancellationToken) { return build(state, project, cancellationToken, true); },
88677             cleanReferences: function (project) { return clean(state, project, true); },
88678             getNextInvalidatedProject: function (cancellationToken) {
88679                 setupInitialBuild(state, cancellationToken);
88680                 return getNextInvalidatedProject(state, getBuildOrder(state), false);
88681             },
88682             getBuildOrder: function () { return getBuildOrder(state); },
88683             getUpToDateStatusOfProject: function (project) {
88684                 var configFileName = resolveProjectName(state, project);
88685                 var configFilePath = toResolvedConfigFilePath(state, configFileName);
88686                 return getUpToDateStatus(state, parseConfigFile(state, configFileName, configFilePath), configFilePath);
88687             },
88688             invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); },
88689             buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); },
88690             getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); },
88691             close: function () { return stopWatching(state); },
88692         };
88693     }
88694     function relName(state, path) {
88695         return ts.convertToRelativePath(path, state.currentDirectory, function (f) { return state.getCanonicalFileName(f); });
88696     }
88697     function reportStatus(state, message) {
88698         var args = [];
88699         for (var _i = 2; _i < arguments.length; _i++) {
88700             args[_i - 2] = arguments[_i];
88701         }
88702         state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)));
88703     }
88704     function reportWatchStatus(state, message) {
88705         var args = [];
88706         for (var _i = 2; _i < arguments.length; _i++) {
88707             args[_i - 2] = arguments[_i];
88708         }
88709         if (state.hostWithWatch.onWatchStatusChange) {
88710             state.hostWithWatch.onWatchStatusChange(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)), state.host.getNewLine(), state.baseCompilerOptions);
88711         }
88712     }
88713     function reportErrors(_a, errors) {
88714         var host = _a.host;
88715         errors.forEach(function (err) { return host.reportDiagnostic(err); });
88716     }
88717     function reportAndStoreErrors(state, proj, errors) {
88718         reportErrors(state, errors);
88719         state.projectErrorsReported.set(proj, true);
88720         if (errors.length) {
88721             state.diagnostics.set(proj, errors);
88722         }
88723     }
88724     function reportParseConfigFileDiagnostic(state, proj) {
88725         reportAndStoreErrors(state, proj, [state.configFileCache.get(proj)]);
88726     }
88727     function reportErrorSummary(state, buildOrder) {
88728         if (!state.needsSummary)
88729             return;
88730         state.needsSummary = false;
88731         var canReportSummary = state.watch || !!state.host.reportErrorSummary;
88732         var diagnostics = state.diagnostics;
88733         var totalErrors = 0;
88734         if (isCircularBuildOrder(buildOrder)) {
88735             reportBuildQueue(state, buildOrder.buildOrder);
88736             reportErrors(state, buildOrder.circularDiagnostics);
88737             if (canReportSummary)
88738                 totalErrors += ts.getErrorCountForSummary(buildOrder.circularDiagnostics);
88739         }
88740         else {
88741             buildOrder.forEach(function (project) {
88742                 var projectPath = toResolvedConfigFilePath(state, project);
88743                 if (!state.projectErrorsReported.has(projectPath)) {
88744                     reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray);
88745                 }
88746             });
88747             if (canReportSummary)
88748                 diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); });
88749         }
88750         if (state.watch) {
88751             reportWatchStatus(state, ts.getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors);
88752         }
88753         else if (state.host.reportErrorSummary) {
88754             state.host.reportErrorSummary(totalErrors);
88755         }
88756     }
88757     function reportBuildQueue(state, buildQueue) {
88758         if (state.options.verbose) {
88759             reportStatus(state, ts.Diagnostics.Projects_in_this_build_Colon_0, buildQueue.map(function (s) { return "\r\n    * " + relName(state, s); }).join(""));
88760         }
88761     }
88762     function reportUpToDateStatus(state, configFileName, status) {
88763         switch (status.type) {
88764             case ts.UpToDateStatusType.OutOfDateWithSelf:
88765                 return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relName(state, configFileName), relName(state, status.outOfDateOutputFileName), relName(state, status.newerInputFileName));
88766             case ts.UpToDateStatusType.OutOfDateWithUpstream:
88767                 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));
88768             case ts.UpToDateStatusType.OutputMissing:
88769                 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));
88770             case ts.UpToDateStatusType.UpToDate:
88771                 if (status.newestInputFileTime !== undefined) {
88772                     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 || ""));
88773                 }
88774                 break;
88775             case ts.UpToDateStatusType.OutOfDateWithPrepend:
88776                 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));
88777             case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
88778                 return reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, relName(state, configFileName));
88779             case ts.UpToDateStatusType.UpstreamOutOfDate:
88780                 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));
88781             case ts.UpToDateStatusType.UpstreamBlocked:
88782                 return reportStatus(state, status.upstreamProjectBlocked ?
88783                     ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built :
88784                     ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName));
88785             case ts.UpToDateStatusType.Unbuildable:
88786                 return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason);
88787             case ts.UpToDateStatusType.TsVersionOutputOfDate:
88788                 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);
88789             case ts.UpToDateStatusType.ContainerOnly:
88790             case ts.UpToDateStatusType.ComputingUpstream:
88791                 break;
88792             default:
88793                 ts.assertType(status);
88794         }
88795     }
88796     function verboseReportProjectStatus(state, configFileName, status) {
88797         if (state.options.verbose) {
88798             reportUpToDateStatus(state, configFileName, status);
88799         }
88800     }
88801 })(ts || (ts = {}));
88802 var ts;
88803 (function (ts) {
88804     function countLines(program) {
88805         var count = 0;
88806         ts.forEach(program.getSourceFiles(), function (file) {
88807             count += ts.getLineStarts(file).length;
88808         });
88809         return count;
88810     }
88811     function updateReportDiagnostic(sys, existing, options) {
88812         return shouldBePretty(sys, options) ?
88813             ts.createDiagnosticReporter(sys, true) :
88814             existing;
88815     }
88816     function defaultIsPretty(sys) {
88817         return !!sys.writeOutputIsTTY && sys.writeOutputIsTTY();
88818     }
88819     function shouldBePretty(sys, options) {
88820         if (!options || typeof options.pretty === "undefined") {
88821             return defaultIsPretty(sys);
88822         }
88823         return options.pretty;
88824     }
88825     function getOptionsForHelp(commandLine) {
88826         return !!commandLine.options.all ?
88827             ts.sort(ts.optionDeclarations, function (a, b) { return ts.compareStringsCaseInsensitive(a.name, b.name); }) :
88828             ts.filter(ts.optionDeclarations.slice(), function (v) { return !!v.showInSimplifiedHelpView; });
88829     }
88830     function printVersion(sys) {
88831         sys.write(ts.getDiagnosticText(ts.Diagnostics.Version_0, ts.version) + sys.newLine);
88832     }
88833     function printHelp(sys, optionsList, syntaxPrefix) {
88834         if (syntaxPrefix === void 0) { syntaxPrefix = ""; }
88835         var output = [];
88836         var syntaxLength = ts.getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, "").length;
88837         var examplesLength = ts.getDiagnosticText(ts.Diagnostics.Examples_Colon_0, "").length;
88838         var marginLength = Math.max(syntaxLength, examplesLength);
88839         var syntax = makePadding(marginLength - syntaxLength);
88840         syntax += "tsc " + syntaxPrefix + "[" + ts.getDiagnosticText(ts.Diagnostics.options) + "] [" + ts.getDiagnosticText(ts.Diagnostics.file) + "...]";
88841         output.push(ts.getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, syntax));
88842         output.push(sys.newLine + sys.newLine);
88843         var padding = makePadding(marginLength);
88844         output.push(ts.getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + sys.newLine);
88845         output.push(padding + "tsc --outFile file.js file.ts" + sys.newLine);
88846         output.push(padding + "tsc @args.txt" + sys.newLine);
88847         output.push(padding + "tsc --build tsconfig.json" + sys.newLine);
88848         output.push(sys.newLine);
88849         output.push(ts.getDiagnosticText(ts.Diagnostics.Options_Colon) + sys.newLine);
88850         marginLength = 0;
88851         var usageColumn = [];
88852         var descriptionColumn = [];
88853         var optionsDescriptionMap = ts.createMap();
88854         for (var _i = 0, optionsList_1 = optionsList; _i < optionsList_1.length; _i++) {
88855             var option = optionsList_1[_i];
88856             if (!option.description) {
88857                 continue;
88858             }
88859             var usageText_1 = " ";
88860             if (option.shortName) {
88861                 usageText_1 += "-" + option.shortName;
88862                 usageText_1 += getParamType(option);
88863                 usageText_1 += ", ";
88864             }
88865             usageText_1 += "--" + option.name;
88866             usageText_1 += getParamType(option);
88867             usageColumn.push(usageText_1);
88868             var description = void 0;
88869             if (option.name === "lib") {
88870                 description = ts.getDiagnosticText(option.description);
88871                 var element = option.element;
88872                 var typeMap = element.type;
88873                 optionsDescriptionMap.set(description, ts.arrayFrom(typeMap.keys()).map(function (key) { return "'" + key + "'"; }));
88874             }
88875             else {
88876                 description = ts.getDiagnosticText(option.description);
88877             }
88878             descriptionColumn.push(description);
88879             marginLength = Math.max(usageText_1.length, marginLength);
88880         }
88881         var usageText = " @<" + ts.getDiagnosticText(ts.Diagnostics.file) + ">";
88882         usageColumn.push(usageText);
88883         descriptionColumn.push(ts.getDiagnosticText(ts.Diagnostics.Insert_command_line_options_and_files_from_a_file));
88884         marginLength = Math.max(usageText.length, marginLength);
88885         for (var i = 0; i < usageColumn.length; i++) {
88886             var usage = usageColumn[i];
88887             var description = descriptionColumn[i];
88888             var kindsList = optionsDescriptionMap.get(description);
88889             output.push(usage + makePadding(marginLength - usage.length + 2) + description + sys.newLine);
88890             if (kindsList) {
88891                 output.push(makePadding(marginLength + 4));
88892                 for (var _a = 0, kindsList_1 = kindsList; _a < kindsList_1.length; _a++) {
88893                     var kind = kindsList_1[_a];
88894                     output.push(kind + " ");
88895                 }
88896                 output.push(sys.newLine);
88897             }
88898         }
88899         for (var _b = 0, output_1 = output; _b < output_1.length; _b++) {
88900             var line = output_1[_b];
88901             sys.write(line);
88902         }
88903         return;
88904         function getParamType(option) {
88905             if (option.paramType !== undefined) {
88906                 return " " + ts.getDiagnosticText(option.paramType);
88907             }
88908             return "";
88909         }
88910         function makePadding(paddingLength) {
88911             return Array(paddingLength + 1).join(" ");
88912         }
88913     }
88914     function executeCommandLineWorker(sys, cb, commandLine) {
88915         var reportDiagnostic = ts.createDiagnosticReporter(sys);
88916         if (commandLine.options.build) {
88917             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Option_build_must_be_the_first_command_line_argument));
88918             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88919         }
88920         var configFileName;
88921         if (commandLine.options.locale) {
88922             ts.validateLocaleAndSetLanguage(commandLine.options.locale, sys, commandLine.errors);
88923         }
88924         if (commandLine.errors.length > 0) {
88925             commandLine.errors.forEach(reportDiagnostic);
88926             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88927         }
88928         if (commandLine.options.init) {
88929             writeConfigFile(sys, reportDiagnostic, commandLine.options, commandLine.fileNames);
88930             return sys.exit(ts.ExitStatus.Success);
88931         }
88932         if (commandLine.options.version) {
88933             printVersion(sys);
88934             return sys.exit(ts.ExitStatus.Success);
88935         }
88936         if (commandLine.options.help || commandLine.options.all) {
88937             printVersion(sys);
88938             printHelp(sys, getOptionsForHelp(commandLine));
88939             return sys.exit(ts.ExitStatus.Success);
88940         }
88941         if (commandLine.options.watch && commandLine.options.listFilesOnly) {
88942             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "watch", "listFilesOnly"));
88943             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88944         }
88945         if (commandLine.options.project) {
88946             if (commandLine.fileNames.length !== 0) {
88947                 reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line));
88948                 return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88949             }
88950             var fileOrDirectory = ts.normalizePath(commandLine.options.project);
88951             if (!fileOrDirectory || sys.directoryExists(fileOrDirectory)) {
88952                 configFileName = ts.combinePaths(fileOrDirectory, "tsconfig.json");
88953                 if (!sys.fileExists(configFileName)) {
88954                     reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0, commandLine.options.project));
88955                     return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88956                 }
88957             }
88958             else {
88959                 configFileName = fileOrDirectory;
88960                 if (!sys.fileExists(configFileName)) {
88961                     reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_specified_path_does_not_exist_Colon_0, commandLine.options.project));
88962                     return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88963                 }
88964             }
88965         }
88966         else if (commandLine.fileNames.length === 0) {
88967             var searchPath = ts.normalizePath(sys.getCurrentDirectory());
88968             configFileName = ts.findConfigFile(searchPath, function (fileName) { return sys.fileExists(fileName); });
88969         }
88970         if (commandLine.fileNames.length === 0 && !configFileName) {
88971             if (commandLine.options.showConfig) {
88972                 reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0, ts.normalizePath(sys.getCurrentDirectory())));
88973             }
88974             else {
88975                 printVersion(sys);
88976                 printHelp(sys, getOptionsForHelp(commandLine));
88977             }
88978             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88979         }
88980         var currentDirectory = sys.getCurrentDirectory();
88981         var commandLineOptions = ts.convertToOptionsWithAbsolutePaths(commandLine.options, function (fileName) { return ts.getNormalizedAbsolutePath(fileName, currentDirectory); });
88982         if (configFileName) {
88983             var configParseResult = ts.parseConfigFileWithSystem(configFileName, commandLineOptions, commandLine.watchOptions, sys, reportDiagnostic);
88984             if (commandLineOptions.showConfig) {
88985                 if (configParseResult.errors.length !== 0) {
88986                     reportDiagnostic = updateReportDiagnostic(sys, reportDiagnostic, configParseResult.options);
88987                     configParseResult.errors.forEach(reportDiagnostic);
88988                     return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
88989                 }
88990                 sys.write(JSON.stringify(ts.convertToTSConfig(configParseResult, configFileName, sys), null, 4) + sys.newLine);
88991                 return sys.exit(ts.ExitStatus.Success);
88992             }
88993             reportDiagnostic = updateReportDiagnostic(sys, reportDiagnostic, configParseResult.options);
88994             if (ts.isWatchSet(configParseResult.options)) {
88995                 if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic))
88996                     return;
88997                 return createWatchOfConfigFile(sys, cb, reportDiagnostic, configParseResult, commandLineOptions, commandLine.watchOptions);
88998             }
88999             else if (ts.isIncrementalCompilation(configParseResult.options)) {
89000                 performIncrementalCompilation(sys, cb, reportDiagnostic, configParseResult);
89001             }
89002             else {
89003                 performCompilation(sys, cb, reportDiagnostic, configParseResult);
89004             }
89005         }
89006         else {
89007             if (commandLineOptions.showConfig) {
89008                 sys.write(JSON.stringify(ts.convertToTSConfig(commandLine, ts.combinePaths(currentDirectory, "tsconfig.json"), sys), null, 4) + sys.newLine);
89009                 return sys.exit(ts.ExitStatus.Success);
89010             }
89011             reportDiagnostic = updateReportDiagnostic(sys, reportDiagnostic, commandLineOptions);
89012             if (ts.isWatchSet(commandLineOptions)) {
89013                 if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic))
89014                     return;
89015                 return createWatchOfFilesAndCompilerOptions(sys, cb, reportDiagnostic, commandLine.fileNames, commandLineOptions, commandLine.watchOptions);
89016             }
89017             else if (ts.isIncrementalCompilation(commandLineOptions)) {
89018                 performIncrementalCompilation(sys, cb, reportDiagnostic, __assign(__assign({}, commandLine), { options: commandLineOptions }));
89019             }
89020             else {
89021                 performCompilation(sys, cb, reportDiagnostic, __assign(__assign({}, commandLine), { options: commandLineOptions }));
89022             }
89023         }
89024     }
89025     function isBuild(commandLineArgs) {
89026         if (commandLineArgs.length > 0 && commandLineArgs[0].charCodeAt(0) === 45) {
89027             var firstOption = commandLineArgs[0].slice(commandLineArgs[0].charCodeAt(1) === 45 ? 2 : 1).toLowerCase();
89028             return firstOption === "build" || firstOption === "b";
89029         }
89030         return false;
89031     }
89032     ts.isBuild = isBuild;
89033     function executeCommandLine(system, cb, commandLineArgs) {
89034         if (isBuild(commandLineArgs)) {
89035             var _a = ts.parseBuildCommand(commandLineArgs.slice(1)), buildOptions_1 = _a.buildOptions, watchOptions_1 = _a.watchOptions, projects_1 = _a.projects, errors_1 = _a.errors;
89036             if (buildOptions_1.generateCpuProfile && system.enableCPUProfiler) {
89037                 system.enableCPUProfiler(buildOptions_1.generateCpuProfile, function () { return performBuild(system, cb, buildOptions_1, watchOptions_1, projects_1, errors_1); });
89038             }
89039             else {
89040                 return performBuild(system, cb, buildOptions_1, watchOptions_1, projects_1, errors_1);
89041             }
89042         }
89043         var commandLine = ts.parseCommandLine(commandLineArgs, function (path) { return system.readFile(path); });
89044         if (commandLine.options.generateCpuProfile && system.enableCPUProfiler) {
89045             system.enableCPUProfiler(commandLine.options.generateCpuProfile, function () { return executeCommandLineWorker(system, cb, commandLine); });
89046         }
89047         else {
89048             return executeCommandLineWorker(system, cb, commandLine);
89049         }
89050     }
89051     ts.executeCommandLine = executeCommandLine;
89052     function reportWatchModeWithoutSysSupport(sys, reportDiagnostic) {
89053         if (!sys.watchFile || !sys.watchDirectory) {
89054             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"));
89055             sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
89056             return true;
89057         }
89058         return false;
89059     }
89060     function performBuild(sys, cb, buildOptions, watchOptions, projects, errors) {
89061         var reportDiagnostic = updateReportDiagnostic(sys, ts.createDiagnosticReporter(sys), buildOptions);
89062         if (buildOptions.locale) {
89063             ts.validateLocaleAndSetLanguage(buildOptions.locale, sys, errors);
89064         }
89065         if (errors.length > 0) {
89066             errors.forEach(reportDiagnostic);
89067             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
89068         }
89069         if (buildOptions.help) {
89070             printVersion(sys);
89071             printHelp(sys, ts.buildOpts, "--build ");
89072             return sys.exit(ts.ExitStatus.Success);
89073         }
89074         if (projects.length === 0) {
89075             printVersion(sys);
89076             printHelp(sys, ts.buildOpts, "--build ");
89077             return sys.exit(ts.ExitStatus.Success);
89078         }
89079         if (!sys.getModifiedTime || !sys.setModifiedTime || (buildOptions.clean && !sys.deleteFile)) {
89080             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--build"));
89081             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
89082         }
89083         if (buildOptions.watch) {
89084             if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic))
89085                 return;
89086             var buildHost_1 = ts.createSolutionBuilderWithWatchHost(sys, undefined, reportDiagnostic, ts.createBuilderStatusReporter(sys, shouldBePretty(sys, buildOptions)), createWatchStatusReporter(sys, buildOptions));
89087             updateSolutionBuilderHost(sys, cb, buildHost_1);
89088             var builder_1 = ts.createSolutionBuilderWithWatch(buildHost_1, projects, buildOptions, watchOptions);
89089             builder_1.build();
89090             return builder_1;
89091         }
89092         var buildHost = ts.createSolutionBuilderHost(sys, undefined, reportDiagnostic, ts.createBuilderStatusReporter(sys, shouldBePretty(sys, buildOptions)), createReportErrorSummary(sys, buildOptions));
89093         updateSolutionBuilderHost(sys, cb, buildHost);
89094         var builder = ts.createSolutionBuilder(buildHost, projects, buildOptions);
89095         var exitStatus = buildOptions.clean ? builder.clean() : builder.build();
89096         return sys.exit(exitStatus);
89097     }
89098     function createReportErrorSummary(sys, options) {
89099         return shouldBePretty(sys, options) ?
89100             function (errorCount) { return sys.write(ts.getErrorSummaryText(errorCount, sys.newLine)); } :
89101             undefined;
89102     }
89103     function performCompilation(sys, cb, reportDiagnostic, config) {
89104         var fileNames = config.fileNames, options = config.options, projectReferences = config.projectReferences;
89105         var host = ts.createCompilerHostWorker(options, undefined, sys);
89106         var currentDirectory = host.getCurrentDirectory();
89107         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
89108         ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); });
89109         enableStatistics(sys, options);
89110         var programOptions = {
89111             rootNames: fileNames,
89112             options: options,
89113             projectReferences: projectReferences,
89114             host: host,
89115             configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics(config)
89116         };
89117         var program = ts.createProgram(programOptions);
89118         var exitStatus = ts.emitFilesAndReportErrorsAndGetExitStatus(program, reportDiagnostic, function (s) { return sys.write(s + sys.newLine); }, createReportErrorSummary(sys, options));
89119         reportStatistics(sys, program);
89120         cb(program);
89121         return sys.exit(exitStatus);
89122     }
89123     function performIncrementalCompilation(sys, cb, reportDiagnostic, config) {
89124         var options = config.options, fileNames = config.fileNames, projectReferences = config.projectReferences;
89125         enableStatistics(sys, options);
89126         var host = ts.createIncrementalCompilerHost(options, sys);
89127         var exitStatus = ts.performIncrementalCompilation({
89128             host: host,
89129             system: sys,
89130             rootNames: fileNames,
89131             options: options,
89132             configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics(config),
89133             projectReferences: projectReferences,
89134             reportDiagnostic: reportDiagnostic,
89135             reportErrorSummary: createReportErrorSummary(sys, options),
89136             afterProgramEmitAndDiagnostics: function (builderProgram) {
89137                 reportStatistics(sys, builderProgram.getProgram());
89138                 cb(builderProgram);
89139             }
89140         });
89141         return sys.exit(exitStatus);
89142     }
89143     function updateSolutionBuilderHost(sys, cb, buildHost) {
89144         updateCreateProgram(sys, buildHost);
89145         buildHost.afterProgramEmitAndDiagnostics = function (program) {
89146             reportStatistics(sys, program.getProgram());
89147             cb(program);
89148         };
89149         buildHost.afterEmitBundle = cb;
89150     }
89151     function updateCreateProgram(sys, host) {
89152         var compileUsingBuilder = host.createProgram;
89153         host.createProgram = function (rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences) {
89154             ts.Debug.assert(rootNames !== undefined || (options === undefined && !!oldProgram));
89155             if (options !== undefined) {
89156                 enableStatistics(sys, options);
89157             }
89158             return compileUsingBuilder(rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences);
89159         };
89160     }
89161     function updateWatchCompilationHost(sys, cb, watchCompilerHost) {
89162         updateCreateProgram(sys, watchCompilerHost);
89163         var emitFilesUsingBuilder = watchCompilerHost.afterProgramCreate;
89164         watchCompilerHost.afterProgramCreate = function (builderProgram) {
89165             emitFilesUsingBuilder(builderProgram);
89166             reportStatistics(sys, builderProgram.getProgram());
89167             cb(builderProgram);
89168         };
89169     }
89170     function createWatchStatusReporter(sys, options) {
89171         return ts.createWatchStatusReporter(sys, shouldBePretty(sys, options));
89172     }
89173     function createWatchOfConfigFile(system, cb, reportDiagnostic, configParseResult, optionsToExtend, watchOptionsToExtend) {
89174         var watchCompilerHost = ts.createWatchCompilerHostOfConfigFile({
89175             configFileName: configParseResult.options.configFilePath,
89176             optionsToExtend: optionsToExtend,
89177             watchOptionsToExtend: watchOptionsToExtend,
89178             system: system,
89179             reportDiagnostic: reportDiagnostic,
89180             reportWatchStatus: createWatchStatusReporter(system, configParseResult.options)
89181         });
89182         updateWatchCompilationHost(system, cb, watchCompilerHost);
89183         watchCompilerHost.configFileParsingResult = configParseResult;
89184         return ts.createWatchProgram(watchCompilerHost);
89185     }
89186     function createWatchOfFilesAndCompilerOptions(system, cb, reportDiagnostic, rootFiles, options, watchOptions) {
89187         var watchCompilerHost = ts.createWatchCompilerHostOfFilesAndCompilerOptions({
89188             rootFiles: rootFiles,
89189             options: options,
89190             watchOptions: watchOptions,
89191             system: system,
89192             reportDiagnostic: reportDiagnostic,
89193             reportWatchStatus: createWatchStatusReporter(system, options)
89194         });
89195         updateWatchCompilationHost(system, cb, watchCompilerHost);
89196         return ts.createWatchProgram(watchCompilerHost);
89197     }
89198     function canReportDiagnostics(system, compilerOptions) {
89199         return system === ts.sys && (compilerOptions.diagnostics || compilerOptions.extendedDiagnostics);
89200     }
89201     function enableStatistics(sys, compilerOptions) {
89202         if (canReportDiagnostics(sys, compilerOptions)) {
89203             ts.performance.enable();
89204         }
89205     }
89206     function reportStatistics(sys, program) {
89207         var statistics;
89208         var compilerOptions = program.getCompilerOptions();
89209         if (canReportDiagnostics(sys, compilerOptions)) {
89210             statistics = [];
89211             var memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1;
89212             reportCountStatistic("Files", program.getSourceFiles().length);
89213             reportCountStatistic("Lines", countLines(program));
89214             reportCountStatistic("Nodes", program.getNodeCount());
89215             reportCountStatistic("Identifiers", program.getIdentifierCount());
89216             reportCountStatistic("Symbols", program.getSymbolCount());
89217             reportCountStatistic("Types", program.getTypeCount());
89218             reportCountStatistic("Instantiations", program.getInstantiationCount());
89219             if (memoryUsed >= 0) {
89220                 reportStatisticalValue("Memory used", Math.round(memoryUsed / 1000) + "K");
89221             }
89222             var programTime = ts.performance.getDuration("Program");
89223             var bindTime = ts.performance.getDuration("Bind");
89224             var checkTime = ts.performance.getDuration("Check");
89225             var emitTime = ts.performance.getDuration("Emit");
89226             if (compilerOptions.extendedDiagnostics) {
89227                 var caches = program.getRelationCacheSizes();
89228                 reportCountStatistic("Assignability cache size", caches.assignable);
89229                 reportCountStatistic("Identity cache size", caches.identity);
89230                 reportCountStatistic("Subtype cache size", caches.subtype);
89231                 reportCountStatistic("Strict subtype cache size", caches.strictSubtype);
89232                 ts.performance.forEachMeasure(function (name, duration) { return reportTimeStatistic(name + " time", duration); });
89233             }
89234             else {
89235                 reportTimeStatistic("I/O read", ts.performance.getDuration("I/O Read"));
89236                 reportTimeStatistic("I/O write", ts.performance.getDuration("I/O Write"));
89237                 reportTimeStatistic("Parse time", programTime);
89238                 reportTimeStatistic("Bind time", bindTime);
89239                 reportTimeStatistic("Check time", checkTime);
89240                 reportTimeStatistic("Emit time", emitTime);
89241             }
89242             reportTimeStatistic("Total time", programTime + bindTime + checkTime + emitTime);
89243             reportStatistics();
89244             ts.performance.disable();
89245         }
89246         function reportStatistics() {
89247             var nameSize = 0;
89248             var valueSize = 0;
89249             for (var _i = 0, statistics_1 = statistics; _i < statistics_1.length; _i++) {
89250                 var _a = statistics_1[_i], name = _a.name, value = _a.value;
89251                 if (name.length > nameSize) {
89252                     nameSize = name.length;
89253                 }
89254                 if (value.length > valueSize) {
89255                     valueSize = value.length;
89256                 }
89257             }
89258             for (var _b = 0, statistics_2 = statistics; _b < statistics_2.length; _b++) {
89259                 var _c = statistics_2[_b], name = _c.name, value = _c.value;
89260                 sys.write(ts.padRight(name + ":", nameSize + 2) + ts.padLeft(value.toString(), valueSize) + sys.newLine);
89261             }
89262         }
89263         function reportStatisticalValue(name, value) {
89264             statistics.push({ name: name, value: value });
89265         }
89266         function reportCountStatistic(name, count) {
89267             reportStatisticalValue(name, "" + count);
89268         }
89269         function reportTimeStatistic(name, time) {
89270             reportStatisticalValue(name, (time / 1000).toFixed(2) + "s");
89271         }
89272     }
89273     function writeConfigFile(sys, reportDiagnostic, options, fileNames) {
89274         var currentDirectory = sys.getCurrentDirectory();
89275         var file = ts.normalizePath(ts.combinePaths(currentDirectory, "tsconfig.json"));
89276         if (sys.fileExists(file)) {
89277             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file));
89278         }
89279         else {
89280             sys.writeFile(file, ts.generateTSConfig(options, fileNames, sys.newLine));
89281             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Successfully_created_a_tsconfig_json_file));
89282         }
89283         return;
89284     }
89285 })(ts || (ts = {}));
89286 // This file actually uses arguments passed on commandline and executes it
89287 if (ts.Debug.isDebugging) {
89288     ts.Debug.enableDebugInfo();
89289 }
89290 if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))) {
89291     ts.sys.tryEnableSourceMapsForHost();
89292 }
89293 if (ts.sys.setBlocking) {
89294     ts.sys.setBlocking();
89295 }
89296 ts.executeCommandLine(ts.sys, ts.noop, ts.sys.args);